Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update OCUnit to XCTest

  • Loading branch information...
commit 1dce80baa4739e6ee53d8938b3c85d670b81f87e 1 parent 71d88f5
@wjk wjk authored
View
23 framework/CocoaOniguruma.xcodeproj/project.pbxproj
@@ -83,7 +83,7 @@
7807AC340E2FBB8600A5AB6A /* regversion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regversion.c; sourceTree = "<group>"; };
7807AC350E2FBB8600A5AB6A /* st.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = st.c; sourceTree = "<group>"; };
7807AC360E2FBB8600A5AB6A /* st.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = st.h; sourceTree = "<group>"; };
- 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.octest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 78C5E1B10E39CDCE00F62F5D /* UnitTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
78C5E1B60E39CDEE00F62F5D /* OnigRegexpTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OnigRegexpTest.h; path = tests/OnigRegexpTest.h; sourceTree = "<group>"; };
78C5E1B70E39CDEE00F62F5D /* OnigRegexpTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OnigRegexpTest.m; path = tests/OnigRegexpTest.m; sourceTree = "<group>"; };
78C5E1E70E39CEBD00F62F5D /* UnitTest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "UnitTest-Info.plist"; sourceTree = "<group>"; };
@@ -129,7 +129,7 @@
isa = PBXGroup;
children = (
8DC2EF5B0486A6940098B216 /* CocoaOniguruma.framework */,
- 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */,
+ 78C5E1B10E39CDCE00F62F5D /* UnitTest.xctest */,
78C5E3A90E39E37F00F62F5D /* TestCommand */,
);
name = Products;
@@ -284,8 +284,8 @@
);
name = UnitTest;
productName = UnitTest;
- productReference = 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */;
- productType = "com.apple.product-type.bundle";
+ productReference = 78C5E1B10E39CDCE00F62F5D /* UnitTest.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
};
78C5E3A80E39E37F00F62F5D /* TestCommand */ = {
isa = PBXNativeTarget;
@@ -329,7 +329,8 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0440;
+ LastTestingUpgradeCheck = 0510;
+ LastUpgradeCheck = 0510;
};
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "CocoaOniguruma" */;
compatibilityVersion = "Xcode 3.2";
@@ -489,7 +490,6 @@
1DEB91B208733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -501,7 +501,6 @@
1DEB91B308733DA50010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
DEPLOYMENT_LOCATION = NO;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -517,7 +516,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
- FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
+ FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -528,11 +527,8 @@
OTHER_LDFLAGS = (
"-framework",
Cocoa,
- "-framework",
- SenTestingKit,
);
PRODUCT_NAME = UnitTest;
- WRAPPER_EXTENSION = octest;
};
name = Debug;
};
@@ -543,7 +539,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
+ FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
@@ -552,11 +548,8 @@
OTHER_LDFLAGS = (
"-framework",
Cocoa,
- "-framework",
- SenTestingKit,
);
PRODUCT_NAME = UnitTest;
- WRAPPER_EXTENSION = octest;
};
name = Release;
};
View
4 framework/tests/OnigRegexpTest.h
@@ -1,8 +1,8 @@
// CocoaOniguruma is copyrighted free software by Satoshi Nakagawa <psychs AT limechat DOT net>.
// You can redistribute it and/or modify it under the new BSD license.
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
-@interface OnigRegexpTest : SenTestCase
+@interface OnigRegexpTest : XCTestCase
@end
View
124 framework/tests/OnigRegexpTest.m
@@ -12,11 +12,11 @@ - (void)testSurrogatePairs
OnigRegexp* e = [OnigRegexp compile:@"[^a-z0-9_\\s]"];
OnigResult* r = [e search:[NSString stringWithUTF8String:"012_\xf0\xa3\x8f\x90 abc"]];
- STAssertNotNil(r, nil);
- STAssertEquals([r bodyRange], NSMakeRange(4,2), nil);
- STAssertEqualObjects([r body], [NSString stringWithUTF8String:"\xf0\xa3\x8f\x90"], nil);
- STAssertEqualObjects([r preMatch], @"012_", nil);
- STAssertEqualObjects([r postMatch], @" abc", nil);
+ XCTAssertNotNil(r);
+ XCTAssertEqual([r bodyRange], NSMakeRange(4,2));
+ XCTAssertEqualObjects([r body], [NSString stringWithUTF8String:"\xf0\xa3\x8f\x90"]);
+ XCTAssertEqualObjects([r preMatch], @"012_");
+ XCTAssertEqualObjects([r postMatch], @" abc");
}
- (void)testNamedCaptures
@@ -24,18 +24,18 @@ - (void)testNamedCaptures
OnigRegexp* e = [OnigRegexp compile:@"(?<digits>\\d+)[^\\d]+(?<digits>\\d+)[^a-zA-Z\\d]*(?<letters>[a-zA-Z]+)"];
OnigResult* r = [e search:@" 012/345 \\t abc##"];
- STAssertNotNil(r, nil);
- STAssertEquals(NSMakeRange(2,11), [r bodyRange], nil);
- STAssertEquals([r count], (NSUInteger)4, nil);
- STAssertEquals([r indexForName:@"digits"], (NSInteger)1, nil);
- STAssertEqualObjects([r indexesForName:@"digits"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,2)], nil);
- STAssertEquals([r indexForName:@"letters"], (NSInteger)3, nil);
- STAssertEqualObjects([r indexesForName:@"letters"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(3,1)], nil);
- STAssertEqualObjects([r stringForName:@"digits"], @"012", nil);
+ XCTAssertNotNil(r);
+ XCTAssertEqual(NSMakeRange(2,11), [r bodyRange]);
+ XCTAssertEqual([r count], (NSUInteger)4);
+ XCTAssertEqual([r indexForName:@"digits"], (NSInteger)1);
+ XCTAssertEqualObjects([r indexesForName:@"digits"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,2)]);
+ XCTAssertEqual([r indexForName:@"letters"], (NSInteger)3);
+ XCTAssertEqualObjects([r indexesForName:@"letters"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(3,1)]);
+ XCTAssertEqualObjects([r stringForName:@"digits"], @"012");
NSArray* ary = [r stringsForName:@"digits"];
NSArray* expected = [NSArray arrayWithObjects:@"012", @"345", nil];
- STAssertEqualObjects(ary, expected, nil);
+ XCTAssertEqualObjects(ary, expected);
}
- (void)testSearch
@@ -43,8 +43,8 @@ - (void)testSearch
OnigRegexp* e = [OnigRegexp compile:@"[a-z]+"];
OnigResult* r = [e search:@" 012xyz abc789"];
- STAssertEquals([r bodyRange], NSMakeRange(4,3), nil);
- STAssertEqualObjects([r body], @"xyz", nil);
+ XCTAssertEqual([r bodyRange], NSMakeRange(4,3));
+ XCTAssertEqualObjects([r body], @"xyz");
}
- (void)testMatch
@@ -52,18 +52,18 @@ - (void)testMatch
OnigRegexp* e = [OnigRegexp compile:@"[a-z]+"];
OnigResult* r = [e match:@"abcABC"];
- STAssertEquals(NSMakeRange(0,3), [r bodyRange], nil);
- STAssertEqualObjects(@"abc", [r body], nil);
+ XCTAssertEqual(NSMakeRange(0,3), [r bodyRange]);
+ XCTAssertEqualObjects(@"abc", [r body]);
}
- (void)testRangeOfRegexp
{
- STAssertEquals([@"" rangeOfRegexp:@"^"], NSMakeRange(0,0), nil);
- STAssertEquals([@"" rangeOfRegexp:[OnigRegexp compile:@"^"]], NSMakeRange(0,0), nil);
- STAssertEquals([@" 0 abc xyz" rangeOfRegexp:@"[a-z]+"], NSMakeRange(3,3), nil);
- STAssertEquals([@" 0 abc xyz" rangeOfRegexp:[OnigRegexp compile:@"[a-z]+"]], NSMakeRange(3,3), nil);
- STAssertEquals([@"abc" rangeOfRegexp:@"[^a-z]+"], NSMakeRange(NSNotFound,0), nil);
- STAssertEquals([@"abc" rangeOfRegexp:[OnigRegexp compile:@"[^a-z]+"]], NSMakeRange(NSNotFound,0), nil);
+ XCTAssertEqual([@"" rangeOfRegexp:@"^"], NSMakeRange(0,0));
+ XCTAssertEqual([@"" rangeOfRegexp:[OnigRegexp compile:@"^"]], NSMakeRange(0,0));
+ XCTAssertEqual([@" 0 abc xyz" rangeOfRegexp:@"[a-z]+"], NSMakeRange(3,3));
+ XCTAssertEqual([@" 0 abc xyz" rangeOfRegexp:[OnigRegexp compile:@"[a-z]+"]], NSMakeRange(3,3));
+ XCTAssertEqual([@"abc" rangeOfRegexp:@"[^a-z]+"], NSMakeRange(NSNotFound,0));
+ XCTAssertEqual([@"abc" rangeOfRegexp:[OnigRegexp compile:@"[^a-z]+"]], NSMakeRange(NSNotFound,0));
}
// These tests are based on ruby 1.8's source code.
@@ -73,34 +73,34 @@ - (void)testSplit
NSArray* expected;
expected = [NSArray arrayWithObjects:@"now's", @"the", @"time", nil];
- STAssertEqualObjects([@" now's the time" split], expected, nil);
- STAssertEqualObjects([@" now's the time" splitByRegexp:@" "], expected, nil);
+ XCTAssertEqualObjects([@" now's the time" split], expected);
+ XCTAssertEqualObjects([@" now's the time" splitByRegexp:@" "], expected);
expected = [NSArray arrayWithObjects:@"", @"now's", @"", @"the", @"time", nil];
- STAssertEqualObjects([@" now's the time" splitByRegexp:[OnigRegexp compile:@" "]], expected, nil);
+ XCTAssertEqualObjects([@" now's the time" splitByRegexp:[OnigRegexp compile:@" "]], expected);
expected = [NSArray arrayWithObjects:@"1", @"2.34", @"56", @"7", nil];
- STAssertEqualObjects([@"1, 2.34,56, 7" splitByRegexp:@",\\s*"], expected, nil);
+ XCTAssertEqualObjects([@"1, 2.34,56, 7" splitByRegexp:@",\\s*"], expected);
expected = [NSArray arrayWithObjects:@"h", @"e", @"l", @"l", @"o", nil];
- STAssertEqualObjects([@"hello" splitByRegexp:@""], expected, nil);
+ XCTAssertEqualObjects([@"hello" splitByRegexp:@""], expected);
expected = [NSArray arrayWithObjects:@"h", @"e", @"llo", nil];
- STAssertEqualObjects([@"hello" splitByRegexp:@"" limit:3], expected, nil);
+ XCTAssertEqualObjects([@"hello" splitByRegexp:@"" limit:3], expected);
expected = [NSArray arrayWithObjects:@"h", @"i", @"m", @"o", @"m", nil];
- STAssertEqualObjects([@"hi mom" splitByRegexp:@"\\s*"], expected, nil);
+ XCTAssertEqualObjects([@"hi mom" splitByRegexp:@"\\s*"], expected);
expected = [NSArray arrayWithObjects:@"m", @"w y", @"w", nil];
- STAssertEqualObjects([@"mellow yellow" splitByRegexp:@"ello"], expected, nil);
+ XCTAssertEqualObjects([@"mellow yellow" splitByRegexp:@"ello"], expected);
expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3", @"4", nil];
- STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@","], expected, nil);
+ XCTAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@","], expected);
expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3,4,,", nil];
- STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:4], expected, nil);
+ XCTAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:4], expected);
expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3", @"4", @"", @"", nil];
- STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:-4], expected, nil);
+ XCTAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:-4], expected);
}
- (NSString *)succReplace:(OnigResult *)res
@@ -124,69 +124,69 @@ - (NSString *)xReplace:(OnigResult *)res
- (void)testReplace
{
- STAssertEqualObjects([@"" replaceByRegexp:@"" with:@""], @"", nil);
- STAssertEqualObjects([@"" replaceByRegexp:@"" with:@"_"], @"_", nil);
- STAssertEqualObjects([@"" replaceByRegexp:@"0" with:@"_"], @"", nil);
- STAssertEqualObjects([@"abc" replaceByRegexp:@"" with:@"_"], @"_abc", nil);
- STAssertEqualObjects([@"abc" replaceByRegexp:@"$" with:@"_"], @"abc_", nil);
- STAssertEqualObjects([@"aa 00 aa 11" replaceByRegexp:@"\\d+" with:@"digits"], @"aa digits aa 11", nil);
- STAssertEqualObjects([@"hello" replaceByRegexp:@"." withBlock:^(OnigResult* res) {
+ XCTAssertEqualObjects([@"" replaceByRegexp:@"" with:@""], @"");
+ XCTAssertEqualObjects([@"" replaceByRegexp:@"" with:@"_"], @"_");
+ XCTAssertEqualObjects([@"" replaceByRegexp:@"0" with:@"_"], @"");
+ XCTAssertEqualObjects([@"abc" replaceByRegexp:@"" with:@"_"], @"_abc");
+ XCTAssertEqualObjects([@"abc" replaceByRegexp:@"$" with:@"_"], @"abc_");
+ XCTAssertEqualObjects([@"aa 00 aa 11" replaceByRegexp:@"\\d+" with:@"digits"], @"aa digits aa 11");
+ XCTAssertEqualObjects([@"hello" replaceByRegexp:@"." withBlock:^(OnigResult* res) {
unichar ch[2];
ch[0] = [[res body] characterAtIndex:0] + 1;
ch[1] = ' ';
return (NSString *)[NSString stringWithCharacters:ch length:2];
- }], @"i ello", nil);
+ }], @"i ello");
NSString* actual = [@"hello!" replaceByRegexp:@"(.)(.)" withBlock:^(OnigResult* res) {
NSString* body = [res body];
return [NSString stringWithFormat:@"[%@]", body];
}];
- STAssertEqualObjects(actual, @"[he]llo!", nil);
+ XCTAssertEqualObjects(actual, @"[he]llo!");
- STAssertEqualObjects([@"hello" replaceByRegexp:@"l" withBlock:^(OnigResult* res) {
+ XCTAssertEqualObjects([@"hello" replaceByRegexp:@"l" withBlock:^(OnigResult* res) {
return @"x";
- }], @"hexlo", nil);
+ }], @"hexlo");
}
- (void)testReplaceAll
{
- STAssertEqualObjects([@"abc" replaceAllByRegexp:@"" with:@"_"], @"_a_b_c_", nil);
- STAssertEqualObjects([@"abc" replaceAllByRegexp:@"^" with:@"_"], @"_abc", nil);
- STAssertEqualObjects([@"abc" replaceAllByRegexp:@"$" with:@"_"], @"abc_", nil);
- STAssertEqualObjects([@"abc" replaceAllByRegexp:@"." with:@"_"], @"___", nil);
- STAssertEqualObjects([@"aa 00 aa 11" replaceAllByRegexp:@"\\d+" with:@"digits"], @"aa digits aa digits", nil);
+ XCTAssertEqualObjects([@"abc" replaceAllByRegexp:@"" with:@"_"], @"_a_b_c_");
+ XCTAssertEqualObjects([@"abc" replaceAllByRegexp:@"^" with:@"_"], @"_abc");
+ XCTAssertEqualObjects([@"abc" replaceAllByRegexp:@"$" with:@"_"], @"abc_");
+ XCTAssertEqualObjects([@"abc" replaceAllByRegexp:@"." with:@"_"], @"___");
+ XCTAssertEqualObjects([@"aa 00 aa 11" replaceAllByRegexp:@"\\d+" with:@"digits"], @"aa digits aa digits");
- STAssertEqualObjects([@"hello" replaceAllByRegexp:@"." withBlock:^(OnigResult* res) {
+ XCTAssertEqualObjects([@"hello" replaceAllByRegexp:@"." withBlock:^(OnigResult* res) {
unichar ch[2];
ch[0] = [[res body] characterAtIndex:0] + 1;
ch[1] = ' ';
return (NSString *)[NSString stringWithCharacters:ch length:2];
- }], @"i f m m p ", nil);
+ }], @"i f m m p ");
NSString* actual = [@"hello!" replaceAllByRegexp:@"(.)(.)" withBlock:^(OnigResult* res) {
NSString* body = [res body];
return (NSString *)[NSString stringWithFormat:@"[%@]", body];
}];
- STAssertEqualObjects(actual, @"[he][ll][o!]", nil);
+ XCTAssertEqualObjects(actual, @"[he][ll][o!]");
- STAssertEqualObjects([@"hello" replaceAllByRegexp:@"l" withBlock:^(OnigResult* res) {
+ XCTAssertEqualObjects([@"hello" replaceAllByRegexp:@"l" withBlock:^(OnigResult* res) {
return @"x";
- }], @"hexxo", nil);
+ }], @"hexxo");
}
- (void)testError
{
NSError *error = NULL;
id ret = [OnigRegexp compileIgnorecase:nil error:&error];
- STAssertNil(ret, @"Parsed expression");
- STAssertEquals([error code], (NSInteger)ONIG_NORMAL, @"Wrong error code");
- STAssertEqualObjects([error localizedDescription], @"Invalid expression argument", nil);
+ XCTAssertNil(ret, @"Parsed expression");
+ XCTAssertEqual([error code], (NSInteger)ONIG_NORMAL, @"Wrong error code");
+ XCTAssertEqualObjects([error localizedDescription], @"Invalid expression argument");
error = NULL;
ret = [OnigRegexp compileIgnorecase:@"(?<openb>\\[)?year(?(<openb>)\\])" error:&error];
- STAssertNil(ret, @"Parsed expression");
- STAssertEquals([error code], (NSInteger)ONIGERR_UNDEFINED_GROUP_OPTION, @"Wrong error code");
- STAssertEqualObjects([error localizedDescription], @"undefined group option", nil);
+ XCTAssertNil(ret, @"Parsed expression");
+ XCTAssertEqual([error code], (NSInteger)ONIGERR_UNDEFINED_GROUP_OPTION, @"Wrong error code");
+ XCTAssertEqualObjects([error localizedDescription], @"undefined group option");
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.