aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/SPDataAdditionsTests.m70
-rw-r--r--UnitTests/SPDatabaseActionTest.m10
-rw-r--r--UnitTests/SPMenuAdditionsTests.m6
-rw-r--r--UnitTests/SPMutableArrayAdditionsTests.m6
-rw-r--r--UnitTests/SPParserUtilsTest.m22
-rw-r--r--UnitTests/SPStringAdditionsTests.m64
-rw-r--r--UnitTests/SPTableCopyTest.m7
-rw-r--r--UnitTests/SPTableFilterParserTest.m10
8 files changed, 98 insertions, 97 deletions
diff --git a/UnitTests/SPDataAdditionsTests.m b/UnitTests/SPDataAdditionsTests.m
index 988267d2..4769e499 100644
--- a/UnitTests/SPDataAdditionsTests.m
+++ b/UnitTests/SPDataAdditionsTests.m
@@ -29,11 +29,11 @@
// More info at <https://github.com/sequelpro/sequelpro>
#import <Cocoa/Cocoa.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#import "SPDataAdditions.h"
#import <errno.h>
-@interface SPDataAdditionsTests : SenTestCase
+@interface SPDataAdditionsTests : XCTestCase
- (void)testSha1Hash;
- (void)testDataEncryptedWithPassword;
@@ -53,7 +53,7 @@
NSString *input = @"Hello World!";
unsigned char bytes[] = {0x2e,0xf7,0xbd,0xe6,0x08,0xce,0x54,0x04,0xe9,0x7d,0x5f,0x04,0x2f,0x95,0xf8,0x9f,0x1c,0x23,0x28,0x71};
- STAssertTrue(memcmp([[[input dataUsingEncoding:NSUTF8StringEncoding] sha1Hash] bytes], bytes, 20) == 0, @"SHA1 simple hash from ASCII text");
+ XCTAssertTrue(memcmp([[[input dataUsingEncoding:NSUTF8StringEncoding] sha1Hash] bytes], bytes, 20) == 0, @"SHA1 simple hash from ASCII text");
}
// 16MB of all 8bit values
{
@@ -65,14 +65,14 @@
NSData *input = [NSData dataWithBytesNoCopy:buf length:bufSz];
NSString *result = @"25E05EB8E9E2B06036DF4026630FE01A19BF0F16";
- STAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash from full ASCII range");
+ XCTAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash from full ASCII range");
}
// empty hash
{
NSData *input = [NSData data];
NSString *result = @"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709";
- STAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash from empty data");
+ XCTAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash from empty data");
}
// test with > 4GB data (other code path)
// HFS+ does not support sparse files, so enable this one only if you have enough disk space.
@@ -109,7 +109,7 @@
NSData *input = [@"føöbärbãz" dataUsingEncoding:NSUTF8StringEncoding];
NSString *result = @"8A8B6142281950CBB9B01C9DF0DADB0BDAE2D0E1";
- STAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash of UTF-8 string");
+ XCTAssertEqualObjects([[input sha1Hash] dataToHexString], result, @"SHA1 hash of UTF-8 string");
}
}
@@ -123,11 +123,11 @@
NSData *encrypted = [raw dataEncryptedWithPassword:password];
//check that our encrypted data is not the plaintext data
NSData *encCore = [encrypted subdataWithRange:NSMakeRange(16, [raw length])];
- STAssertFalse([encCore isEqualToData:raw], @"encrypted equal to plain text!");
+ XCTAssertFalse([encCore isEqualToData:raw], @"encrypted equal to plain text!");
//decrypt again and verify
NSData *decrypted = [encrypted dataDecryptedWithPassword:password];
- STAssertEqualObjects(decrypted, raw, @"decrypted data not equal to plaintext data!");
+ XCTAssertEqualObjects(decrypted, raw, @"decrypted data not equal to plaintext data!");
}
- (void)testDataEncryptedWithKeyIV
@@ -144,7 +144,7 @@
{
@try {
[raw dataEncryptedWithKey:[@"password" dataUsingEncoding:NSASCIIStringEncoding] IV:iv];
- STFail(@"Password should not be a valid key!");
+ XCTFail(@"Password should not be a valid key!");
}
@catch (NSException *exception) {
//expected
@@ -154,7 +154,7 @@
{
@try {
[raw dataEncryptedWithKey:key IV:[NSData data]];
- STFail(@"Empty IV should throw exception!");
+ XCTFail(@"Empty IV should throw exception!");
}
@catch (NSException *exception) {
// expected
@@ -171,7 +171,7 @@
0x1d, 0x9f, 0x0c, 0x7a
}; // reference data generated with OpenSSL
NSData *expData = [NSData dataWithBytesNoCopy:expect length:sizeof(expect) freeWhenDone:NO];
- STAssertEqualObjects(enc, expData, @"Encryption of empty data");
+ XCTAssertEqualObjects(enc, expData, @"Encryption of empty data");
}
//simple encryption test
{
@@ -185,7 +185,7 @@
0x44, 0x32, 0xb3, 0xda, 0x42, 0x58, 0x29, 0x78, 0xc3
}; // reference data generated with OpenSSL
NSData *expData = [NSData dataWithBytesNoCopy:expect length:sizeof(expect) freeWhenDone:NO];
- STAssertEqualObjects(enc, expData, @"Simple encryption test");
+ XCTAssertEqualObjects(enc, expData, @"Simple encryption test");
}
}
@@ -205,7 +205,7 @@
NSData *decrypted = [encData dataDecryptedWithPassword:@""];
- STAssertEqualObjects(decrypted, raw, @"Decrypt simple data encrypted with empty password");
+ XCTAssertEqualObjects(decrypted, raw, @"Decrypt simple data encrypted with empty password");
}
- (void)testDataDecryptedWithKey
@@ -229,7 +229,7 @@
{
@try {
[encData dataDecryptedWithKey:[NSData data]];
- STFail(@"Invalid key length!");
+ XCTFail(@"Invalid key length!");
}
@catch (NSException *exception) {
//expected
@@ -239,7 +239,7 @@
{
@try {
[[@"Hello World!" dataUsingEncoding:NSASCIIStringEncoding] dataDecryptedWithKey:key];
- STFail(@"Invalid data length!");
+ XCTFail(@"Invalid data length!");
}
@catch (NSException *exception) {
//expected
@@ -248,17 +248,17 @@
// wrong data with valid length
{
NSData *inp = [@"12345678901234567890123456789012" dataUsingEncoding:NSASCIIStringEncoding];
- STAssertNil([inp dataDecryptedWithKey:key], @"Trying to decrypt invalid data.");
+ XCTAssertNil([inp dataDecryptedWithKey:key], @"Trying to decrypt invalid data.");
}
// wrong data with invalid length
{
NSData *inp = [@"12345678901234567890123456789012345678901234567" dataUsingEncoding:NSASCIIStringEncoding];
- STAssertNil([inp dataDecryptedWithKey:key], @"Trying to decrypt data with invalid length.");
+ XCTAssertNil([inp dataDecryptedWithKey:key], @"Trying to decrypt data with invalid length.");
}
// simple decryption test
{
NSData *decrypted = [encData dataDecryptedWithKey:key];
- STAssertEqualObjects(decrypted, raw, @"Simple Decryption test");
+ XCTAssertEqualObjects(decrypted, raw, @"Simple Decryption test");
}
// malicious message test
{
@@ -274,7 +274,7 @@
@try {
[_encData dataDecryptedWithKey:key];
- STFail(@"Malicious message with invalid data length");
+ XCTFail(@"Malicious message with invalid data length");
}
@catch (NSException *exception) {
//expected
@@ -291,7 +291,7 @@
[data enumerateLinesBreakingAt:SPLineTerminatorAny withBlock:^(NSRange line, BOOL *stop) {
invocations++;
}];
- STAssertTrue(invocations==0, @"Empty data never invokes block");
+ XCTAssertTrue(invocations==0, @"Empty data never invokes block");
}
//simple unix file
{
@@ -301,15 +301,15 @@
[data enumerateLinesBreakingAt:SPLineTerminatorAny withBlock:^(NSRange line, BOOL *stop) {
switch (invocations) {
case 0:
- STAssertEquals(line, NSMakeRange(0, 3), @"range of first line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(0, 3)), @"range of first line");
break;
case 1:
- STAssertEquals(line, NSMakeRange(4, 5), @"range of second line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(4, 5)), @"range of second line");
break;
}
invocations++;
}];
- STAssertTrue(invocations==2, @"File with two lines, terminated with empty line");
+ XCTAssertTrue(invocations==2, @"File with two lines, terminated with empty line");
}
//simple windows file without ending empty line
{
@@ -319,18 +319,18 @@
[data enumerateLinesBreakingAt:SPLineTerminatorAny withBlock:^(NSRange line, BOOL *stop) {
switch (invocations) {
case 0:
- STAssertEquals(line, NSMakeRange(0, 1), @"range of first line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(0, 1)), @"range of first line");
break;
case 1:
- STAssertEquals(line, NSMakeRange(3, 7), @"range of second line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(3, 7)), @"range of second line");
break;
case 2:
- STAssertEquals(line, NSMakeRange(12, 4), @"range of third line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(12, 4)), @"range of third line");
break;
}
invocations++;
}];
- STAssertTrue(invocations==3, @"File with three lines, CRLF, terminated with empty line");
+ XCTAssertTrue(invocations==3, @"File with three lines, CRLF, terminated with empty line");
}
//empty lines with all 3 endings
{
@@ -340,18 +340,18 @@
[data enumerateLinesBreakingAt:SPLineTerminatorAny withBlock:^(NSRange line, BOOL *stop) {
switch (invocations) {
case 0:
- STAssertEquals(line, NSMakeRange(0, 0), @"range of first line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(0, 0)), @"range of first line");
break;
case 1:
- STAssertEquals(line, NSMakeRange(1, 0), @"range of second line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(1, 0)), @"range of second line");
break;
case 2:
- STAssertEquals(line, NSMakeRange(3, 0), @"range of third line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(3, 0)), @"range of third line");
break;
}
invocations++;
}];
- STAssertTrue(invocations==3, @"LF, CRLF and CR mixed");
+ XCTAssertTrue(invocations==3, @"LF, CRLF and CR mixed");
}
//looking for specific line breaks only
{
@@ -361,15 +361,15 @@
[data enumerateLinesBreakingAt:SPLineTerminatorCRLF withBlock:^(NSRange line, BOOL *stop) {
switch (invocations) {
case 0:
- STAssertEquals(line, NSMakeRange(0, 7), @"range of first line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(0, 7)), @"range of first line");
break;
case 1:
- STAssertEquals(line, NSMakeRange(9, 4), @"range of second line");
+ XCTAssertTrue(NSEqualRanges(line, NSMakeRange(9, 4)), @"range of second line");
break;
}
invocations++;
}];
- STAssertTrue(invocations==2, @"other line breaks when only CRLF is expected");
+ XCTAssertTrue(invocations==2, @"other line breaks when only CRLF is expected");
}
//stopping early
{
@@ -380,7 +380,7 @@
invocations++;
*stop = YES;
}];
- STAssertTrue(invocations==1, @"File with two lines, stopped after first");
+ XCTAssertTrue(invocations==1, @"File with two lines, stopped after first");
}
}
diff --git a/UnitTests/SPDatabaseActionTest.m b/UnitTests/SPDatabaseActionTest.m
index f7704df5..a74dc0f0 100644
--- a/UnitTests/SPDatabaseActionTest.m
+++ b/UnitTests/SPDatabaseActionTest.m
@@ -29,14 +29,14 @@
// More info at <https://github.com/sequelpro/sequelpro>
#import <OCMock/OCMock.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#import "SPDatabaseAction.h"
#import <SPMySQL/SPMySQL.h>
-@interface SPDatabaseActionTest : SenTestCase
+@interface SPDatabaseActionTest : XCTestCase
- (void)testCreateDatabase_01_emptyName;
- (void)testCreateDatabase_02_allParams;
@@ -53,7 +53,7 @@
SPDatabaseAction *createDb = [[[SPDatabaseAction alloc] init] autorelease];
[createDb setConnection:mockConnection];
- STAssertFalse([createDb createDatabase:@"" withEncoding:nil collation:nil],@"create database = NO with empty db name");
+ XCTAssertFalse([createDb createDatabase:@"" withEncoding:nil collation:nil],@"create database = NO with empty db name");
OCMVerifyAll(mockConnection);
}
@@ -69,7 +69,7 @@
SPDatabaseAction *createDb = [[[SPDatabaseAction alloc] init] autorelease];
[createDb setConnection:mockConnection];
- STAssertTrue([createDb createDatabase:@"target_name" withEncoding:@"utf8" collation:@"utf8_bin_ci"], @"create database return");
+ XCTAssertTrue([createDb createDatabase:@"target_name" withEncoding:@"utf8" collation:@"utf8_bin_ci"], @"create database return");
OCMVerifyAll(mockConnection);
}
@@ -84,7 +84,7 @@
SPDatabaseAction *createDb = [[[SPDatabaseAction alloc] init] autorelease];
[createDb setConnection:mockConnection];
- STAssertTrue([createDb createDatabase:@"target_name" withEncoding:@"" collation:nil], @"create database return");
+ XCTAssertTrue([createDb createDatabase:@"target_name" withEncoding:@"" collation:nil], @"create database return");
OCMVerifyAll(mockConnection);
}
diff --git a/UnitTests/SPMenuAdditionsTests.m b/UnitTests/SPMenuAdditionsTests.m
index 83647e6f..7e8b5ecc 100644
--- a/UnitTests/SPMenuAdditionsTests.m
+++ b/UnitTests/SPMenuAdditionsTests.m
@@ -30,7 +30,7 @@
#import "SPMenuAdditions.h"
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
/**
* @class SPMenuAdditionsTests SPMenuAdditionsTests.h
@@ -39,7 +39,7 @@
*
* SPMenuAdditionsTests tests class.
*/
-@interface SPMenuAdditionsTests : SenTestCase
+@interface SPMenuAdditionsTests : XCTestCase
{
NSMenu *menu;
}
@@ -71,7 +71,7 @@ static NSString *SPTestMenuItemTitle = @"Menu Item";
{
[menu compatibleRemoveAllItems];
- STAssertFalse([menu numberOfItems], @"The menu should have no menu items.");
+ XCTAssertFalse([menu numberOfItems], @"The menu should have no menu items.");
}
@end
diff --git a/UnitTests/SPMutableArrayAdditionsTests.m b/UnitTests/SPMutableArrayAdditionsTests.m
index e09f00a4..82fec400 100644
--- a/UnitTests/SPMutableArrayAdditionsTests.m
+++ b/UnitTests/SPMutableArrayAdditionsTests.m
@@ -30,7 +30,7 @@
#import "SPMutableArrayAdditions.h"
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
/**
* @class SPMutableArrayAdditionsTest SPMutableArrayAdditionsTest.h
@@ -39,7 +39,7 @@
*
* SPMutableArrayAdditions tests class.
*/
-@interface SPMutableArrayAdditionsTests : SenTestCase
+@interface SPMutableArrayAdditionsTests : XCTestCase
@end
@@ -55,7 +55,7 @@
[testArray reverse];
- STAssertEqualObjects(testArray, expectedArray, @"The reversed array should look like: %@, but actually looks like: %@", expectedArray, testArray);
+ XCTAssertEqualObjects(testArray, expectedArray, @"The reversed array should look like: %@, but actually looks like: %@", expectedArray, testArray);
}
@end
diff --git a/UnitTests/SPParserUtilsTest.m b/UnitTests/SPParserUtilsTest.m
index 994b166a..6796a250 100644
--- a/UnitTests/SPParserUtilsTest.m
+++ b/UnitTests/SPParserUtilsTest.m
@@ -31,11 +31,11 @@
#define USE_APPLICATION_UNIT_TEST 1
#import <Cocoa/Cocoa.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#include "SPParserUtils.h"
-@interface SPParserUtilsTest : SenTestCase
+@interface SPParserUtilsTest : XCTestCase
- (void)testUtf8strlen;
@@ -49,39 +49,39 @@
const char *empty = "";
NSString *emptyString = [NSString stringWithCString:empty encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(empty),[emptyString length], @"empty string");
+ XCTAssertEqual(utf8strlen(empty),[emptyString length], @"empty string");
// This is just a little safeguard.
// If any of those conditions fail, all of the following assumptions are moot.
const char *charSeq = "\xF0\x9F\x8D\x8F"; //🍏
NSString *charString = [NSString stringWithCString:charSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(strlen(charSeq), (size_t)4, @"assumption about storage for binary C string");
- STAssertEquals([charString length], (NSUInteger)2, @"assumption about NSString internal storage of string");
+ XCTAssertEqual(strlen(charSeq), (size_t)4, @"assumption about storage for binary C string");
+ XCTAssertEqual([charString length], (NSUInteger)2, @"assumption about NSString internal storage of string");
const char *singleByteSeq = "Hello World!";
NSString *singleByteString = [NSString stringWithCString:singleByteSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(singleByteSeq), [singleByteString length], @"ASCII UTF-8 subset");
+ XCTAssertEqual(utf8strlen(singleByteSeq), [singleByteString length], @"ASCII UTF-8 subset");
const char *twoByteSeq = "H\xC3\xA4ll\xC3\xB6 W\xC3\x9Crld\xC3\x9F!"; // Hällö WÜrldß!
NSString *twoByteString = [NSString stringWithCString:twoByteSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(twoByteSeq), [twoByteString length], @"String containing two-byte utf8 characters");
+ XCTAssertEqual(utf8strlen(twoByteSeq), [twoByteString length], @"String containing two-byte utf8 characters");
const char *threeByteSeq = "\xE3\x81\x93.\xE3\x82\x93.\xE3\x81\xAB.\xE3\x81\xA1.\xE3\x81\xAF"; // こ.ん.に.ち.は
NSString *threeByteString = [NSString stringWithCString:threeByteSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(threeByteSeq), [threeByteString length], @"String containing three-byte utf8 characters");
+ XCTAssertEqual(utf8strlen(threeByteSeq), [threeByteString length], @"String containing three-byte utf8 characters");
const char *fourByteSeq = "\xF0\x9F\x8D\x8F\xF0\x9F\x8D\x8B\xF0\x9F\x8D\x92"; //🍏🍋🍒
NSString *fourByteString = [NSString stringWithCString:fourByteSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(fourByteSeq), [fourByteString length], @"String containing only 4-byte utf8 characters (outside BMP)");
+ XCTAssertEqual(utf8strlen(fourByteSeq), [fourByteString length], @"String containing only 4-byte utf8 characters (outside BMP)");
const char *mixedSeq = "\xE3\x81\x82\xE3\x82\x81\xE3\x80\x90\xE9\xA3\xB4\xE3\x80\x91\xF0\x9F\x8D\xAD \xE2\x89\x88 S\xC3\xBC\xC3\x9Figkeit"; // あめ【飴】🍭 ≈ Süßigkeit
NSString *mixedString = [NSString stringWithCString:mixedSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(mixedSeq), [mixedString length], @"utf8 characters with all 4 lengths mixed together.");
+ XCTAssertEqual(utf8strlen(mixedSeq), [mixedString length], @"utf8 characters with all 4 lengths mixed together.");
//composed vs. decomposed chars
const char *decompSeq = "\xC3\xA4 - a\xCC\x88"; // ä - ä
NSString *decompString = [NSString stringWithCString:decompSeq encoding:NSUTF8StringEncoding];
- STAssertEquals(utf8strlen(decompSeq), [decompString length], @"\"LATIN SMALL LETTER A WITH DIAERESIS\" vs. \"LATIN SMALL LETTER A\" + \"COMBINING DIAERESIS\"");
+ XCTAssertEqual(utf8strlen(decompSeq), [decompString length], @"\"LATIN SMALL LETTER A WITH DIAERESIS\" vs. \"LATIN SMALL LETTER A\" + \"COMBINING DIAERESIS\"");
}
@end
diff --git a/UnitTests/SPStringAdditionsTests.m b/UnitTests/SPStringAdditionsTests.m
index 00cbdc14..eca9f7ab 100644
--- a/UnitTests/SPStringAdditionsTests.m
+++ b/UnitTests/SPStringAdditionsTests.m
@@ -31,9 +31,9 @@
#import "SPStringAdditions.h"
#import "RegexKitLite.h"
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
-@interface SPStringAdditionsTests : SenTestCase
+@interface SPStringAdditionsTests : XCTestCase
- (void)testStringByRemovingCharactersInSet;
- (void)testStringWithNewUUID;
@@ -65,12 +65,12 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
NSString *expectedUTFString = @"In der Krze liegt die Wrz";
NSString *expectedASCIIString = @"this is ig rzy test string with some rndom spes nd quotes";
- STAssertEqualObjects([actualASCIIString stringByRemovingCharactersInSet:junk],
+ XCTAssertEqualObjects([actualASCIIString stringByRemovingCharactersInSet:junk],
expectedASCIIString,
@"The following characters should have been removed %@",
charsToRemove);
- STAssertEqualObjects([actualUTFString stringByRemovingCharactersInSet:junk],
+ XCTAssertEqualObjects([actualUTFString stringByRemovingCharactersInSet:junk],
expectedUTFString,
@"The following characters should have been removed %@",
charsToRemove);
@@ -83,7 +83,7 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
{
NSString *uuid = [NSString stringWithNewUUID];
- STAssertTrue([uuid isMatchedByRegex:@"[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}"], @"UUID %@ doesn't match regex", uuid);
+ XCTAssertTrue([uuid isMatchedByRegex:@"[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}"], @"UUID %@ doesn't match regex", uuid);
}
/**
@@ -96,7 +96,7 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
NSString *actualSyntax = [originalSyntax createViewSyntaxPrettifier];
- STAssertEqualObjects([actualSyntax description], [expectedSyntax description], @"Actual view syntax '%@' does not equal expected syntax '%@'", actualSyntax, expectedSyntax);
+ XCTAssertEqualObjects([actualSyntax description], [expectedSyntax description], @"Actual view syntax '%@' does not equal expected syntax '%@'", actualSyntax, expectedSyntax);
}
- (void)testNonConsecutivelySearchStringMatchingRanges
@@ -104,48 +104,48 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
//basic tests
{
NSArray *matches = nil;
- STAssertTrue([@"" nonConsecutivelySearchString:@"" matchingRanges:&matches], @"Equality of empty strings");
- STAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(0, 0), RangeFromArray(matches, 0)), @"Returned matches in empty string");
+ XCTAssertTrue([@"" nonConsecutivelySearchString:@"" matchingRanges:&matches], @"Equality of empty strings");
+ XCTAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(0, 0), RangeFromArray(matches, 0)), @"Returned matches in empty string");
}
{
NSArray *matches = (void *)0xdeadbeef;
- STAssertFalse([@"" nonConsecutivelySearchString:@"R" matchingRanges:&matches], @"Inequality with empty left side");
- STAssertTrue((matches == (void *)0xdeadbeef), @"out variable not touched by mismatch");
+ XCTAssertFalse([@"" nonConsecutivelySearchString:@"R" matchingRanges:&matches], @"Inequality with empty left side");
+ XCTAssertTrue((matches == (void *)0xdeadbeef), @"out variable not touched by mismatch");
}
- STAssertFalse([@"L" nonConsecutivelySearchString:@"" matchingRanges:NULL], @"Inequality with empty right side");
+ XCTAssertFalse([@"L" nonConsecutivelySearchString:@"" matchingRanges:NULL], @"Inequality with empty right side");
{
NSArray *matches = nil;
- STAssertTrue([@"left" nonConsecutivelySearchString:@"le" matchingRanges:&matches], @"Anchored match left");
- STAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(0, 2), RangeFromArray(matches, 0)), @"Returned matches in anchored left match");
+ XCTAssertTrue([@"left" nonConsecutivelySearchString:@"le" matchingRanges:&matches], @"Anchored match left");
+ XCTAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(0, 2), RangeFromArray(matches, 0)), @"Returned matches in anchored left match");
}
{
NSArray *matches = nil;
- STAssertTrue([@"right" nonConsecutivelySearchString:@"ht" matchingRanges:&matches], @"Anchored match right");
- STAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(3, 2), RangeFromArray(matches, 0)), @"Returned matches in anchroed right match");
+ XCTAssertTrue([@"right" nonConsecutivelySearchString:@"ht" matchingRanges:&matches], @"Anchored match right");
+ XCTAssertTrue(([matches count] == 1) && NSEqualRanges(NSMakeRange(3, 2), RangeFromArray(matches, 0)), @"Returned matches in anchroed right match");
}
- STAssertFalse([@"ht" nonConsecutivelySearchString:@"right" matchingRanges:NULL], @"Left and Right are not commutative");
+ XCTAssertFalse([@"ht" nonConsecutivelySearchString:@"right" matchingRanges:NULL], @"Left and Right are not commutative");
//real tests
{
NSArray *matches = nil;
- STAssertTrue([@"... is not secure anymore!" nonConsecutivelySearchString:@"NSA" matchingRanges:&matches], @"Non-consecutive match, ignoring case");
- STAssertTrue(([matches count] == 3) &&
+ XCTAssertTrue([@"... is not secure anymore!" nonConsecutivelySearchString:@"NSA" matchingRanges:&matches], @"Non-consecutive match, ignoring case");
+ XCTAssertTrue(([matches count] == 3) &&
NSEqualRanges(NSMakeRange( 7, 1), RangeFromArray(matches, 0)) &&
NSEqualRanges(NSMakeRange(11, 1), RangeFromArray(matches, 1)) &&
NSEqualRanges(NSMakeRange(18, 1), RangeFromArray(matches, 2)), @"Returned matches in non-consecutive string");
}
- STAssertFalse([@"Deoxyribonucleic Acid" nonConsecutivelySearchString:@"DNS" matchingRanges:NULL], @"Non-consecutive mismatch");
+ XCTAssertFalse([@"Deoxyribonucleic Acid" nonConsecutivelySearchString:@"DNS" matchingRanges:NULL], @"Non-consecutive mismatch");
{
NSArray *matches = nil;
- STAssertTrue([@"Turn left, then right at the corner" nonConsecutivelySearchString:@"left right" matchingRanges:&matches], @"Partly consecutive match");
- STAssertTrue(([matches count] == 2) &&
+ XCTAssertTrue([@"Turn left, then right at the corner" nonConsecutivelySearchString:@"left right" matchingRanges:&matches], @"Partly consecutive match");
+ XCTAssertTrue(([matches count] == 2) &&
(NSEqualRanges(NSMakeRange( 5, 4), RangeFromArray(matches, 0))) &&
(NSEqualRanges(NSMakeRange(15, 6), RangeFromArray(matches, 1))), @"Returned matches in partly-consecutive string");
}
@@ -159,8 +159,8 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
// ^^^^^^^ ^ ^ ^ ^ = 5 (after optimizing consecutive atomic matches)
// Desired: "central_private_rabbit_park"
// ^^^^^^^ ^^^^ = 2
- STAssertTrue([@"central_private_rabbit_park" nonConsecutivelySearchString:@"centralpark" matchingRanges:&matches], @"Optimization partly consecutive match");
- STAssertTrue((([matches count] == 2) &&
+ XCTAssertTrue([@"central_private_rabbit_park" nonConsecutivelySearchString:@"centralpark" matchingRanges:&matches], @"Optimization partly consecutive match");
+ XCTAssertTrue((([matches count] == 2) &&
(NSEqualRanges(NSMakeRange( 0, 7), RangeFromArray(matches, 0))) &&
(NSEqualRanges(NSMakeRange(23, 4), RangeFromArray(matches, 1)))), @"Returned matches set is minimal");
}
@@ -172,8 +172,8 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
// Unoptimized: ^ ^ ^ ^ ^ ^ ^ = 7
// Desired: ^ ^^^ ^^^ = 3
NSArray *matches = nil;
- STAssertTrue([@"a.?a?ab?abc?1?12?123?" nonConsecutivelySearchString:@".abc123" matchingRanges:&matches], @"Optimization non-consecutive match");
- STAssertTrue((([matches count] == 3) &&
+ XCTAssertTrue([@"a.?a?ab?abc?1?12?123?" nonConsecutivelySearchString:@".abc123" matchingRanges:&matches], @"Optimization non-consecutive match");
+ XCTAssertTrue((([matches count] == 3) &&
(NSEqualRanges(NSMakeRange( 1, 1), RangeFromArray(matches, 0))) &&
(NSEqualRanges(NSMakeRange( 8, 3), RangeFromArray(matches, 1))) &&
(NSEqualRanges(NSMakeRange(17, 3), RangeFromArray(matches, 2)))), @"Returned matches set is minimal (2)");
@@ -184,15 +184,15 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
// LATIN CAPITAL LETTER A == LATIN SMALL LETTER A
// LATIN SMALL LETTER O WITH DIAERESIS == LATIN SMALL LETTER O
// FULLWIDTH LATIN SMALL LETTER b == LATIN SMALL LETTER B
- STAssertTrue([@"A:\xC3\xB6:\xEF\xBD\x82" nonConsecutivelySearchString:@"aob" matchingRanges:NULL], @"Fuzzy matching of defined characters");
+ XCTAssertTrue([@"A:\xC3\xB6:\xEF\xBD\x82" nonConsecutivelySearchString:@"aob" matchingRanges:NULL], @"Fuzzy matching of defined characters");
//all bytes on the right are contained on the left, but on a character level "ä" is not contained in "Hütte Ф"
- STAssertFalse([@"H\xC3\xBCtte \xD0\xA4" nonConsecutivelySearchString:@"\xC3\xA4" matchingRanges:NULL], @"Mismatch of composed characters with same prefix");
+ XCTAssertFalse([@"H\xC3\xBCtte \xD0\xA4" nonConsecutivelySearchString:@"\xC3\xA4" matchingRanges:NULL], @"Mismatch of composed characters with same prefix");
// ":😥:𠘄:" vs "😄" (according to wikipedia "𠘄" is the arachic variant of "印")
// TECHNICALLY THIS SHOULD NOT MATCH!
// However Apple doesn't correctly handle characters in the 4-Byte UTF range, so let's use this test to check for changes in Apples behaviour :)
- STAssertTrue([@":\xF0\x9F\x98\x84:\xF0\xA0\x98\x84:" nonConsecutivelySearchString:@"\xF0\x9F\x98\x84" matchingRanges:NULL], @"Mismatch of composed characters (4-byte) with same prefix");
+ XCTAssertTrue([@":\xF0\x9F\x98\x84:\xF0\xA0\x98\x84:" nonConsecutivelySearchString:@"\xF0\x9F\x98\x84" matchingRanges:NULL], @"Mismatch of composed characters (4-byte) with same prefix");
}
@@ -200,19 +200,19 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
{
{
//test against empty string
- STAssertEqualObjects([@"" stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"x"], @"", @"replacement on empty string must result in empty string");
+ XCTAssertEqualObjects([@"" stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"x"], @"", @"replacement on empty string must result in empty string");
}
{
//test match at begin, middle, end / consecutive matches
- STAssertEqualObjects([@" ab c " stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"_"], @"_ab__c_", @"Testing matches at both end, replacement of consecutive matches");
+ XCTAssertEqualObjects([@" ab c " stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"_"], @"_ab__c_", @"Testing matches at both end, replacement of consecutive matches");
}
{
//test replacement of different characters
- STAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:@"*"], @"ab**cd", @"Testing replacement of different characters in set");
+ XCTAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:@"*"], @"ab**cd", @"Testing replacement of different characters in set");
}
{
// nil for replacement char
- STAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:nil], @"abcd", @"testing replacement with nil");
+ XCTAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:nil], @"abcd", @"testing replacement with nil");
}
}
diff --git a/UnitTests/SPTableCopyTest.m b/UnitTests/SPTableCopyTest.m
index 05ab4a76..563322df 100644
--- a/UnitTests/SPTableCopyTest.m
+++ b/UnitTests/SPTableCopyTest.m
@@ -31,12 +31,12 @@
#import "SPTableCopy.h"
#import <SPMySQL/SPMySQL.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#define USE_APPLICATION_UNIT_TEST 1
-@interface SPTableCopyTest : SenTestCase
+@interface SPTableCopyTest : XCTestCase
- (void)testCopyTableFromToWithData;
- (void)testCopyTableFromTo_NoPermissions;
@@ -88,8 +88,9 @@
{
SPTableCopy *tableCopy = [[SPTableCopy alloc] init];
+ [tableCopy setConnection:mockConnection];
- STAssertFalse([tableCopy copyTable:@"table_name" from:@"source_db" to:@"target_db"],@"copy operation must fail.");
+ XCTAssertFalse([tableCopy copyTable:@"table_name" from:@"source_db" to:@"target_db"], @"copy operation must fail.");
[tableCopy release];
}
diff --git a/UnitTests/SPTableFilterParserTest.m b/UnitTests/SPTableFilterParserTest.m
index d5f46969..1ff69e7f 100644
--- a/UnitTests/SPTableFilterParserTest.m
+++ b/UnitTests/SPTableFilterParserTest.m
@@ -12,9 +12,9 @@
#define USE_APPLICATION_UNIT_TEST 1
#import <Cocoa/Cocoa.h>
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
-@interface SPTableFilterParserTest : SenTestCase
+@interface SPTableFilterParserTest : XCTestCase
- (void)testFilterString;
@@ -29,7 +29,7 @@
[p setCurrentField:@"FLD"];
// binary matches as "$BINARY ", eating the one additional whitespace
- STAssertEqualObjects([p filterString],@"`FLD` constant string", @"Constant replacement");
+ XCTAssertEqualObjects([p filterString],@"`FLD` constant string", @"Constant replacement");
}
//simple one argument case with binary
{
@@ -38,7 +38,7 @@
[p setCaseSensitive:YES];
[p setArgument:@"arg1"];
- STAssertEqualObjects([p filterString], @"`FLD2` = FOO(BINARY arg1)", @"One Argument, $BINARY variable");
+ XCTAssertEqualObjects([p filterString], @"`FLD2` = FOO(BINARY arg1)", @"One Argument, $BINARY variable");
}
//simple two argument case with explicit current field
{
@@ -48,7 +48,7 @@
[p setFirstBetweenArgument:@"LA"];
[p setSecondBetweenArgument:@"RA"];
- STAssertEqualObjects([p filterString], @"MIN(`FLD3`,LA) = RA", @"Two Arguments, $CURRENT_FIELD variable");
+ XCTAssertEqualObjects([p filterString], @"MIN(`FLD3`,LA) = RA", @"Two Arguments, $CURRENT_FIELD variable");
}
}