From 343e4ed439ba0ccc255460df4fc69e25c4a3f91e Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 8 May 2012 14:23:31 +0000 Subject: Improve formatting of SQL keywords in view syntax prettifier and add an associated test. --- UnitTests/SPMenuAdditionsTests.h | 7 +++++++ UnitTests/SPStringAdditionsTest.h | 1 + UnitTests/SPStringAdditionsTest.m | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'UnitTests') diff --git a/UnitTests/SPMenuAdditionsTests.h b/UnitTests/SPMenuAdditionsTests.h index 1ff2ab61..f2999405 100644 --- a/UnitTests/SPMenuAdditionsTests.h +++ b/UnitTests/SPMenuAdditionsTests.h @@ -25,6 +25,13 @@ #import +/** + * @class SPMenuAdditionsTests SPMenuAdditionsTests.h + * + * @author Stuart Connolly http://stuconnolly.com/ + * + * SPMenuAdditionsTests tests class. + */ @interface SPMenuAdditionsTests : SenTestCase { NSMenu *menu; diff --git a/UnitTests/SPStringAdditionsTest.h b/UnitTests/SPStringAdditionsTest.h index 25d418f4..9599b9a6 100644 --- a/UnitTests/SPStringAdditionsTest.h +++ b/UnitTests/SPStringAdditionsTest.h @@ -29,5 +29,6 @@ - (void)testStringByRemovingCharactersInSet; - (void)testStringWithNewUUID; +- (void)testCreateViewSyntaxPrettifier; @end diff --git a/UnitTests/SPStringAdditionsTest.m b/UnitTests/SPStringAdditionsTest.m index 0571ff3c..2d0cb0fb 100644 --- a/UnitTests/SPStringAdditionsTest.m +++ b/UnitTests/SPStringAdditionsTest.m @@ -34,8 +34,8 @@ */ - (void)testStringByRemovingCharactersInSet { - static NSString *SPASCIITestString = @"this is a big, crazy test st'ring with som'e random spaces and quot'es"; - static NSString *SPUTFTestString = @"In der Kürze liegt die Würz"; + NSString *SPASCIITestString = @"this is a big, crazy test st'ring with som'e random spaces and quot'es"; + NSString *SPUTFTestString = @"In der Kürze liegt die Würz"; NSString *charsToRemove = @"abc',ü"; @@ -58,6 +58,9 @@ charsToRemove); } +/** + * stringWithNewUUID test case. + */ - (void)testStringWithNewUUID { NSString *uuid = [NSString stringWithNewUUID]; @@ -65,4 +68,17 @@ 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); } +/** + * createViewSyntaxPrettifier test case. + */ +- (void)testCreateViewSyntaxPrettifier +{ + NSString *originalSyntax = @"CREATE VIEW `test_view` AS select `test_table`.`id` AS `id` from `test_table`;"; + NSString *expectedSyntax = @"CREATE VIEW `test_view`\nAS SELECT\n `test_table`.`id` AS `id`\nFROM `test_table`;"; + + NSString *actualSyntax = [originalSyntax createViewSyntaxPrettifier]; + + STAssertEqualObjects([actualSyntax description], [expectedSyntax description], @"Actual view syntax '%@' does not equal expected syntax '%@'", actualSyntax, expectedSyntax); +} + @end -- cgit v1.2.3