aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests/SPStringAdditionsTests.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-05-08 14:40:57 +0000
committerstuconnolly <stuart02@gmail.com>2012-05-08 14:40:57 +0000
commit7bead0b2fc2dc203157988460c4c0a2abd5857a2 (patch)
tree10bb64793faebcc649f74bd9cc21bef6838c4b3b /UnitTests/SPStringAdditionsTests.m
parent343e4ed439ba0ccc255460df4fc69e25c4a3f91e (diff)
downloadsequelpro-7bead0b2fc2dc203157988460c4c0a2abd5857a2.tar.gz
sequelpro-7bead0b2fc2dc203157988460c4c0a2abd5857a2.tar.bz2
sequelpro-7bead0b2fc2dc203157988460c4c0a2abd5857a2.zip
Rename test files.
Diffstat (limited to 'UnitTests/SPStringAdditionsTests.m')
-rw-r--r--UnitTests/SPStringAdditionsTests.m84
1 files changed, 84 insertions, 0 deletions
diff --git a/UnitTests/SPStringAdditionsTests.m b/UnitTests/SPStringAdditionsTests.m
new file mode 100644
index 00000000..2c2b2f25
--- /dev/null
+++ b/UnitTests/SPStringAdditionsTests.m
@@ -0,0 +1,84 @@
+//
+// $Id$
+//
+// SPStringAdditionsTests.m
+// sequel-pro
+//
+// Created by J Knight on 17/05/09.
+// Copyright 2009 J Knight. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <http://code.google.com/p/sequel-pro/>
+
+#import "SPStringAdditionsTests.h"
+#import "SPStringAdditions.h"
+#import "RegexKitLite.h"
+
+@implementation SPStringAdditionsTests
+
+/**
+ * stringByRemovingCharactersInSet test case.
+ */
+- (void)testStringByRemovingCharactersInSet
+{
+ 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',ü";
+
+ NSCharacterSet *junk = [NSCharacterSet characterSetWithCharactersInString:charsToRemove];
+
+ NSString *actualUTFString = SPUTFTestString;
+ NSString *actualASCIIString = SPASCIITestString;
+
+ 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],
+ expectedASCIIString,
+ @"The following characters should have been removed %@",
+ charsToRemove);
+
+ STAssertEqualObjects([actualUTFString stringByRemovingCharactersInSet:junk],
+ expectedUTFString,
+ @"The following characters should have been removed %@",
+ charsToRemove);
+}
+
+/**
+ * stringWithNewUUID test case.
+ */
+- (void)testStringWithNewUUID
+{
+ 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);
+}
+
+/**
+ * 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