3 // This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
4 // Copyright (C) 1997-2019 Steve Nygard.
6 #import <XCTest/XCTest.h>
10 #import "CDMachOFile.h"
12 @interface TestThinFile_Intel64_lib64 : XCTestCase
15 @implementation TestThinFile_Intel64_lib64
17 CDMachOFile *_macho_x86_64;
25 _macho_x86_64 = [[CDMachOFile alloc] init];
26 _macho_x86_64.cputype = CPU_TYPE_X86_64;
27 _macho_x86_64.cpusubtype = CPU_SUBTYPE_386 | CPU_SUBTYPE_LIB64; // For example, /Applications/Utilities/Grab.app on 10.8
32 // Tear-down code here.
40 - (void)test_bestMatchIntel64;
42 CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
44 BOOL result = [_macho_x86_64 bestMatchForArch:&arch];
45 XCTAssertTrue(result, @"Didn't find a best match for x86_64");
46 XCTAssertTrue(arch.cputype == CPU_TYPE_X86_64, @"Best match cputype should be CPU_TYPE_X86_64");
47 XCTAssertTrue(arch.cpusubtype == (cpu_subtype_t)(CPU_SUBTYPE_386 | CPU_SUBTYPE_LIB64), @"Best match cpusubtype should be CPU_SUBTYPE_386");
50 - (void)test_machOFileWithArch_x86_64;
52 CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
53 CDMachOFile *machOFile = [_macho_x86_64 machOFileWithArch:arch];
54 XCTAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil", NULL);
55 XCTAssertEqual(machOFile, _macho_x86_64, @"Didn't find correct Mach-O file", NULL);
58 - (void)test_machOFileWithArch_i386;
60 CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };
61 CDMachOFile *machOFile = [_macho_x86_64 machOFileWithArch:arch];
62 XCTAssertNil(machOFile, @"The Mach-O file should be nil", NULL);