Skip to content

Commit

Permalink
Convert to XCTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Nov 16, 2013
1 parent 7763d75 commit 5c9dae2
Show file tree
Hide file tree
Showing 29 changed files with 323 additions and 504 deletions.
10 changes: 0 additions & 10 deletions UnitTests/TestBlockSignature.h

This file was deleted.

15 changes: 9 additions & 6 deletions UnitTests/TestBlockSignature.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

#import "TestBlockSignature.h"
#import <XCTest/XCTest.h>

#import "CDType.h"
#import "CDTypeName.h"
Expand All @@ -12,6 +12,9 @@ @interface CDType (UnitTests)
- (NSString *)blockSignatureString;
@end

@interface TestBlockSignature : XCTestCase
@end

@implementation TestBlockSignature

- (void)testZeroArguments;
Expand All @@ -21,7 +24,7 @@ - (void)testZeroArguments;
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
STAssertEqualObjects(blockSignatureString, @"void (^)(void)", nil);
XCTAssertEqualObjects(blockSignatureString, @"void (^)(void)", @"");
}

- (void)testOneArgument;
Expand All @@ -34,7 +37,7 @@ - (void)testOneArgument;
[types addObject:[[CDType alloc] initIDType:typeName]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
STAssertEqualObjects(blockSignatureString, @"void (^)(NSData *)", nil);
XCTAssertEqualObjects(blockSignatureString, @"void (^)(NSData *)", @"");
}

- (void)testTwoArguments;
Expand All @@ -48,7 +51,7 @@ - (void)testTwoArguments;
[types addObject:[[CDType alloc] initIDType:typeName]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
STAssertEqualObjects(blockSignatureString, @"void (^)(id, NSError *)", nil);
XCTAssertEqualObjects(blockSignatureString, @"void (^)(id, NSError *)", @"");
}

- (void)testBlockArgument;
Expand All @@ -59,7 +62,7 @@ - (void)testBlockArgument;
[types addObject:[[CDType alloc] initBlockTypeWithTypes:[types copy]]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
STAssertEqualObjects(blockSignatureString, @"void (^)(void (^)(void))", nil);
XCTAssertEqualObjects(blockSignatureString, @"void (^)(void (^)(void))", @"");
}

- (void)testBOOLArgument;
Expand All @@ -70,7 +73,7 @@ - (void)testBOOLArgument;
[types addObject:[[CDType alloc] initSimpleType:'c']];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
STAssertEqualObjects(blockSignatureString, @"void (^)(BOOL)", nil);
XCTAssertEqualObjects(blockSignatureString, @"void (^)(BOOL)", @"");
}

@end
10 changes: 0 additions & 10 deletions UnitTests/TestCDArchFromName.h

This file was deleted.

29 changes: 16 additions & 13 deletions UnitTests/TestCDArchFromName.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

#import "TestCDArchFromName.h"
#import <XCTest/XCTest.h>

#import "CDFile.h"

@interface TestCDArchFromName : XCTestCase
@end

@implementation TestCDArchFromName

- (void)setUp;
Expand All @@ -28,45 +31,45 @@ - (void)tearDown;
- (void)test_armv6;
{
CDArch arch = CDArchFromName(@"armv6");
STAssertEquals(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv6' should be ARM");
STAssertEquals(arch.cpusubtype, CPU_SUBTYPE_ARM_V6, @"The cpusubtype for 'armv6' should be ARM_V6");
XCTAssertEqual(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv6' should be ARM");
XCTAssertEqual(arch.cpusubtype, CPU_SUBTYPE_ARM_V6, @"The cpusubtype for 'armv6' should be ARM_V6");
}

- (void)test_armv7;
{
CDArch arch = CDArchFromName(@"armv7");
STAssertEquals(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv7' should be ARM");
STAssertEquals(arch.cpusubtype, CPU_SUBTYPE_ARM_V7, @"The cpusubtype for 'armv7' should be ARM_V7");
XCTAssertEqual(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv7' should be ARM");
XCTAssertEqual(arch.cpusubtype, CPU_SUBTYPE_ARM_V7, @"The cpusubtype for 'armv7' should be ARM_V7");
}

- (void)test_armv7s;
{
CDArch arch = CDArchFromName(@"armv7s");
STAssertEquals(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv7s' should be ARM");
STAssertEquals(arch.cpusubtype, 11, @"The cpusubtype for 'armv7s' should be 11");
XCTAssertEqual(arch.cputype, CPU_TYPE_ARM, @"The cputype for 'armv7s' should be ARM");
XCTAssertEqual(arch.cpusubtype, 11, @"The cpusubtype for 'armv7s' should be 11");
}

- (void)test_arm64;
{
CDArch arch = CDArchFromName(@"arm64");
STAssertEquals(arch.cputype, CPU_TYPE_ARM | CPU_ARCH_ABI64, @"The cputype for 'arm64' should be ARM with 64-bit mask");
STAssertEquals(arch.cpusubtype, CPU_SUBTYPE_ARM_ALL, @"The cpusubtype for 'arm64' should be CPU_SUBTYPE_ARM_ALL");
XCTAssertEqual(arch.cputype, CPU_TYPE_ARM | CPU_ARCH_ABI64, @"The cputype for 'arm64' should be ARM with 64-bit mask");
XCTAssertEqual(arch.cpusubtype, CPU_SUBTYPE_ARM_ALL, @"The cpusubtype for 'arm64' should be CPU_SUBTYPE_ARM_ALL");
}

#pragma mark - Intel x86

- (void)test_i386;
{
CDArch arch = CDArchFromName(@"i386");
STAssertEquals(arch.cputype, CPU_TYPE_X86, @"The cputype for 'i386' should be X86");
STAssertEquals(arch.cpusubtype, CPU_SUBTYPE_386, @"The cpusubtype for 'i386' should be 386");
XCTAssertEqual(arch.cputype, CPU_TYPE_X86, @"The cputype for 'i386' should be X86");
XCTAssertEqual(arch.cpusubtype, CPU_SUBTYPE_386, @"The cpusubtype for 'i386' should be 386");
}

- (void)test_x86_64;
{
CDArch arch = CDArchFromName(@"x86_64");
STAssertEquals(arch.cputype, CPU_TYPE_X86_64, @"The cputype for 'x86_64' should be X86_64");
STAssertEquals(arch.cpusubtype, CPU_SUBTYPE_386, @"The cpusubtype for 'x86_64' should be 386");
XCTAssertEqual(arch.cputype, CPU_TYPE_X86_64, @"The cputype for 'x86_64' should be X86_64");
XCTAssertEqual(arch.cpusubtype, CPU_SUBTYPE_386, @"The cpusubtype for 'x86_64' should be 386");
}

@end
10 changes: 0 additions & 10 deletions UnitTests/TestCDArchUses64BitABI.h

This file was deleted.

13 changes: 8 additions & 5 deletions UnitTests/TestCDArchUses64BitABI.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

#import "TestCDArchUses64BitABI.h"
#import <XCTest/XCTest.h>

#import "CDFile.h"

@interface TestCDArchUses64BitABI : XCTestCase
@end

@implementation TestCDArchUses64BitABI

- (void)setUp;
Expand All @@ -28,25 +31,25 @@ - (void)tearDown;
- (void)test_i386;
{
CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };
STAssertFalse(CDArchUses64BitABI(arch), @"i386 does not use 64 bit ABI");
XCTAssertFalse(CDArchUses64BitABI(arch), @"i386 does not use 64 bit ABI");
}

- (void)test_x86_64;
{
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
STAssertTrue(CDArchUses64BitABI(arch), @"x86_64 uses 64 bit ABI");
XCTAssertTrue(CDArchUses64BitABI(arch), @"x86_64 uses 64 bit ABI");
}

- (void)test_x86_64_lib64;
{
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 | CPU_SUBTYPE_LIB64 };
STAssertTrue(CDArchUses64BitABI(arch), @"x86_64 (with LIB64 capability bit) uses 64 bit ABI");
XCTAssertTrue(CDArchUses64BitABI(arch), @"x86_64 (with LIB64 capability bit) uses 64 bit ABI");
}

- (void)test_x86_64_plusOtherCapablity
{
CDArch arch = { CPU_TYPE_X86_64 | 0x40000000, CPU_SUBTYPE_386 };
STAssertTrue(CDArchUses64BitABI(arch), @"x86_64 (with other capability bit) uses 64 bit ABI");
XCTAssertTrue(CDArchUses64BitABI(arch), @"x86_64 (with other capability bit) uses 64 bit ABI");
}

@end
10 changes: 0 additions & 10 deletions UnitTests/TestCDNameForCPUType.h

This file was deleted.

19 changes: 11 additions & 8 deletions UnitTests/TestCDNameForCPUType.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

#import "TestCDNameForCPUType.h"
#import <XCTest/XCTest.h>

#import "CDFile.h"

@interface TestCDNameForCPUType : XCTestCase
@end

@implementation TestCDNameForCPUType

- (void)setUp;
Expand All @@ -27,39 +30,39 @@ - (void)tearDown;

- (void)test_armv6;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6), @"armv6", @"The name for ARM subtype CPU_SUBTYPE_ARM_V6 should be 'armv6'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6), @"armv6", @"The name for ARM subtype CPU_SUBTYPE_ARM_V6 should be 'armv6'");
}

- (void)test_armv7;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7), @"armv7", @"The name for ARM subtype CPU_SUBTYPE_ARM_V7 should be 'armv7'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7), @"armv7", @"The name for ARM subtype CPU_SUBTYPE_ARM_V7 should be 'armv7'");
}

- (void)test_armv7s;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, 11), @"armv7s", @"The name for ARM subtype 11 should be 'armv7s'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM, 11), @"armv7s", @"The name for ARM subtype 11 should be 'armv7s'");
}

- (void)test_arm64;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM | CPU_ARCH_ABI64, CPU_SUBTYPE_ARM_ALL), @"arm64", @"The name for ARM 64-bit subtype CPU_SUBTYPE_ARM_ALL should be 'arm64'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_ARM | CPU_ARCH_ABI64, CPU_SUBTYPE_ARM_ALL), @"arm64", @"The name for ARM 64-bit subtype CPU_SUBTYPE_ARM_ALL should be 'arm64'");
}

#pragma mark - Intel x86

- (void)test_i386;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86, CPU_SUBTYPE_386), @"i386", @"The name for X86 subtype CPU_SUBTYPE_386 should be 'i386'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86, CPU_SUBTYPE_386), @"i386", @"The name for X86 subtype CPU_SUBTYPE_386 should be 'i386'");
}

- (void)test_x86_64;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86_64, CPU_SUBTYPE_386), @"x86_64", @"The name for X86_64 subtype CPU_SUBTYPE_386 should be 'x86_64'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86_64, CPU_SUBTYPE_386), @"x86_64", @"The name for X86_64 subtype CPU_SUBTYPE_386 should be 'x86_64'");
}

- (void)test_x86_64_lib64;
{
STAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86_64, CPU_SUBTYPE_386|CPU_SUBTYPE_LIB64), @"x86_64", @"The name for X86_64 subtype CPU_SUBTYPE_386 with capability bits should be 'x86_64'");
XCTAssertEqualObjects(CDNameForCPUType(CPU_TYPE_X86_64, CPU_SUBTYPE_386|CPU_SUBTYPE_LIB64), @"x86_64", @"The name for X86_64 subtype CPU_SUBTYPE_386 with capability bits should be 'x86_64'");
}

@end
10 changes: 0 additions & 10 deletions UnitTests/TestFatFile_Intel32_64.h

This file was deleted.

25 changes: 14 additions & 11 deletions UnitTests/TestFatFile_Intel32_64.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

#import "TestFatFile_Intel32_64.h"
#import <XCTest/XCTest.h>

#import "CDFatArch.h"
#import "CDFatFile.h"
#import "CDMachOFile.h"

@interface TestFatFile_Intel32_64 : XCTestCase
@end

@implementation TestFatFile_Intel32_64
{
CDFatFile *_fatFile;
Expand Down Expand Up @@ -59,9 +62,9 @@ - (void)test_bestMatchIntel64;
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };

BOOL result = [_fatFile bestMatchForArch:&arch];
STAssertTrue(result, @"Didn't find a best match for x86_64");
STAssertTrue(arch.cputype == CPU_TYPE_X86_64, @"Best match cputype should be CPU_TYPE_X86_64");
STAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
XCTAssertTrue(result, @"Didn't find a best match for x86_64");
XCTAssertTrue(arch.cputype == CPU_TYPE_X86_64, @"Best match cputype should be CPU_TYPE_X86_64");
XCTAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
}

#if 0
Expand All @@ -71,26 +74,26 @@ - (void)test_bestMatchIntel32;
CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };

BOOL result = [_intel_32_64 bestMatchForArch:&arch];
STAssertTrue(result, @"Didn't find a best match for i386");
STAssertTrue(arch.cputype == CPU_TYPE_X86, @"Best match cputype should be CPU_TYPE_X86");
STAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
XCTAssertTrue(result, @"Didn't find a best match for i386");
XCTAssertTrue(arch.cputype == CPU_TYPE_X86, @"Best match cputype should be CPU_TYPE_X86");
XCTAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
}
#endif

- (void)test_machOFileWithArch_x86_64;
{
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
CDMachOFile *machOFile = [_fatFile machOFileWithArch:arch];
STAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil", NULL);
STAssertEquals(machOFile, _macho_x86_64, @"Didn't find correct Mach-O file");
XCTAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil", NULL);
XCTAssertEqual(machOFile, _macho_x86_64, @"Didn't find correct Mach-O file");
}

- (void)test_machOFileWithArch_i386;
{
CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };
CDMachOFile *machOFile = [_fatFile machOFileWithArch:arch];
STAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil");
STAssertEquals(machOFile, _macho_i386, @"Didn't find correct Mach-O file");
XCTAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil");
XCTAssertEqual(machOFile, _macho_i386, @"Didn't find correct Mach-O file");
}

@end
10 changes: 0 additions & 10 deletions UnitTests/TestFatFile_Intel32_64_lib64.h

This file was deleted.

Loading

0 comments on commit 5c9dae2

Please sign in to comment.