// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. //! Test that asserts the whole library cannot panic due to overflow in arithmetic operations. use m68000::addressing_modes::{AddressingMode, BriefExtensionWord}; use m68000::assembler::*; use m68000::instruction::{Direction, Size}; #[should_panic(expected = "attempt to add with overflow")] #[test] fn must_overflow() { #[allow(arithmetic_overflow)] let _ = u8::MAX + 1; } #[test] fn library_overflow() { } macro_rules! u { ($f:expr) => {{ let op = $f; code.push((op >> 8) as u8); code.push(op as u8); }} } fn generate_code() -> Vec { let code = Vec::new(); // u!(abcd(0, Direction::RegisterToRegister, 0)); code } // D2 = 0xFFFFFFFF, D3 = 1; // const BEW: BriefExtensionWord = BriefExtensionWord::new(true, 0, false, -128); // const AM0: AddressingMode = AddressingMode::Drd(0); // const AM1: AddressingMode = AddressingMode::Ard(0); // const AM2: AddressingMode = AddressingMode::Ari(0); // const AM3: AddressingMode = AddressingMode::Ariwpo(0); // const AM4: AddressingMode = AddressingMode::Ariwpr(0); // const AM5: AddressingMode = AddressingMode::Ariwd(0, -32768); // const AM6: AddressingMode = AddressingMode::Ariwi8(0, BEW); // const AM72: AddressingMode = AddressingMode::Pciwd(0, -32768); // const AM73: AddressingMode = AddressingMode::Pciwi8(0, BEW); // const AM74: AddressingMode = AddressingMode::Immediate(0xFFFFFFFF); // abcd(0, Direction::RegisterToRegister, 0); // add(0, Direction::DstReg, Size::Byte, AM0); // add(0, Direction::DstReg, Size::Byte, AM1); // add(0, Direction::DstReg, Size::Byte, AM2); // add(0, Direction::DstReg, Size::Byte, AM3); // add(0, Direction::DstReg, Size::Byte, AM4); // add(0, Direction::DstReg, Size::Byte, AM5); // add(0, Direction::DstReg, Size::Byte, AM6); // add(0, Direction::DstReg, Size::Byte, AM72); // add(0, Direction::DstReg, Size::Byte, AM73); // add(0, Direction::DstReg, Size::Byte, AM74);