Use 10 (not 6) bits in source version fields B-E.
[class-dump.git] / UnitTests / TestThinFile_Intel64_lib64.m
blobc37afa8c5b4821ccab26aa1d50cdbd9e530374ff
1 // -*- mode: ObjC -*-
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>
8 #import "CDFatArch.h"
9 #import "CDFatFile.h"
10 #import "CDMachOFile.h"
12 @interface TestThinFile_Intel64_lib64 : XCTestCase
13 @end
15 @implementation TestThinFile_Intel64_lib64
17     CDMachOFile *_macho_x86_64;
20 - (void)setUp;
22     [super setUp];
23     
24     // Set-up code here.
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
30 - (void)tearDown;
32     // Tear-down code here.
33     _macho_x86_64  = nil;
34     
35     [super tearDown];
38 #pragma mark -
40 - (void)test_bestMatchIntel64;
42     CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
43     
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);
65 @end