aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
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