// // m68kDecoderTests.m // Clock Signal // // Created by Thomas Harte on 18/04/2022. // Copyright 2022 Thomas Harte. All rights reserved. // #import #include "../../../InstructionSets/68k/Decoder.hpp" using namespace InstructionSet::M68k; @interface m68kDecoderTests : XCTestCase @end @implementation m68kDecoderTests - (void)testInstructionSpecs { NSData *const testData = [NSData dataWithContentsOfURL: [[NSBundle bundleForClass:[self class]] URLForResource:@"68000ops" withExtension:@"json" subdirectory:@"68000 Decoding"]]; NSDictionary *const decodings = [NSJSONSerialization JSONObjectWithData:testData options:0 error:nil]; XCTAssertNotNil(decodings); Predecoder decoder; for(int instr = 0; instr < 65536; instr++) { NSString *const instrName = [NSString stringWithFormat:@"%04x", instr]; NSString *const expected = decodings[instrName]; XCTAssertNotNil(expected); const auto found = decoder.decode(uint16_t(instr)); // Hatch off no-instruction as a special case, // at least temporarily. if(found.operation == Operation::Undefined) { XCTAssertEqualObjects(@"None", expected); continue; } } } @end