aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-04-23 21:34:15 +0200
committerMax <post@wickenrode.com>2015-04-23 21:34:15 +0200
commitd828290bdc4229db1beb7e8e2f9df0b8f0a35a72 (patch)
tree1551157fada5f09905379a1c08a6b57bc71ee816 /UnitTests
parent5ef3f0df72d89ad85680a02048c27e2460e2c685 (diff)
downloadsequelpro-d828290bdc4229db1beb7e8e2f9df0b8f0a35a72.tar.gz
sequelpro-d828290bdc4229db1beb7e8e2f9df0b8f0a35a72.tar.bz2
sequelpro-d828290bdc4229db1beb7e8e2f9df0b8f0a35a72.zip
Added some basic unit tests for SPTableFilterParser
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/SPTableFilterParserTest.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/UnitTests/SPTableFilterParserTest.m b/UnitTests/SPTableFilterParserTest.m
new file mode 100644
index 00000000..d5f46969
--- /dev/null
+++ b/UnitTests/SPTableFilterParserTest.m
@@ -0,0 +1,57 @@
+//
+// SPTableFilterParserTest.m
+// sequel-pro
+//
+// Created by Max Lohrmann on 23.04.15.
+//
+//
+
+#import <Foundation/Foundation.h>
+#import "SPTableFilterParser.h"
+
+#define USE_APPLICATION_UNIT_TEST 1
+
+#import <Cocoa/Cocoa.h>
+#import <SenTestingKit/SenTestingKit.h>
+
+@interface SPTableFilterParserTest : SenTestCase
+
+- (void)testFilterString;
+
+@end
+
+@implementation SPTableFilterParserTest
+
+- (void)testFilterString {
+ //simple zero argument case
+ {
+ SPTableFilterParser *p = [[[SPTableFilterParser alloc] initWithFilterClause:@" constant $BINARY string" numberOfArguments:0] autorelease];
+ [p setCurrentField:@"FLD"];
+
+ // binary matches as "$BINARY ", eating the one additional whitespace
+ STAssertEqualObjects([p filterString],@"`FLD` constant string", @"Constant replacement");
+ }
+ //simple one argument case with binary
+ {
+ SPTableFilterParser *p = [[[SPTableFilterParser alloc] initWithFilterClause:@"= FOO($BINARY ${})" numberOfArguments:1] autorelease];
+ [p setCurrentField:@"FLD2"];
+ [p setCaseSensitive:YES];
+ [p setArgument:@"arg1"];
+
+ STAssertEqualObjects([p filterString], @"`FLD2` = FOO(BINARY arg1)", @"One Argument, $BINARY variable");
+ }
+ //simple two argument case with explicit current field
+ {
+ SPTableFilterParser *p = [[[SPTableFilterParser alloc] initWithFilterClause:@"MIN($CURRENT_FIELD,${}) = ${}" numberOfArguments:2] autorelease];
+ [p setCurrentField:@"FLD3"];
+ [p setSuppressLeadingTablePlaceholder:YES];
+ [p setFirstBetweenArgument:@"LA"];
+ [p setSecondBetweenArgument:@"RA"];
+
+ STAssertEqualObjects([p filterString], @"MIN(`FLD3`,LA) = RA", @"Two Arguments, $CURRENT_FIELD variable");
+ }
+
+}
+
+
+@end