diff --git a/RealmJS.xcodeproj/project.pbxproj b/RealmJS.xcodeproj/project.pbxproj index a8c60c49..a7558118 100644 --- a/RealmJS.xcodeproj/project.pbxproj +++ b/RealmJS.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 029445981BDEDF46006D1617 /* external_commit_helper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 029445961BDEDF46006D1617 /* external_commit_helper.hpp */; }; 0294465E1BF27DE6006D1617 /* query_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0294465C1BF27DE6006D1617 /* query_builder.cpp */; }; 0294465F1BF27DE6006D1617 /* query_builder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0294465D1BF27DE6006D1617 /* query_builder.hpp */; }; + 02AAAEF01BFE72F2002DD081 /* queryTests.json in Resources */ = {isa = PBXBuildFile; fileRef = 02AAAEEF1BFE72F2002DD081 /* queryTests.json */; }; 02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; }; 02B58CCE1AE99D4D009B348C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */; }; 02C0864E1BCDB27000942F9C /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02C0864C1BCDB27000942F9C /* list.cpp */; }; @@ -206,6 +207,7 @@ 0294465D1BF27DE6006D1617 /* query_builder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = query_builder.hpp; path = "src/object-store/parser/query_builder.hpp"; sourceTree = ""; }; 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GCDWebServer.xcodeproj; path = GCDWebServer/GCDWebServer.xcodeproj; sourceTree = ""; }; 02A3C7A41BC4341500B1A7BE /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; + 02AAAEEF1BFE72F2002DD081 /* queryTests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = queryTests.json; path = tests/queryTests.json; sourceTree = SOURCE_ROOT; }; 02B29A161B7CF7C9008A7E6B /* RealmReact.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RealmReact.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 02B58CB11AE99CEC009B348C /* RealmJS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RealmJS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 02B58CBC1AE99CEC009B348C /* RealmJSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealmJSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -361,6 +363,7 @@ 02D456D91B7E59A500EE1299 /* ArrayTests.js */, 0270BC791B7D020100010E03 /* ObjectTests.js */, 02E9A9F01BFA84F100939F86 /* QueryTests.js */, + 02AAAEEF1BFE72F2002DD081 /* queryTests.json */, 0270BC7C1B7D020100010E03 /* RealmTests.js */, 0270BC7D1B7D020100010E03 /* ResultsTests.js */, 0270BC7A1B7D020100010E03 /* RealmJSTests.h */, @@ -623,6 +626,7 @@ 0270BC861B7D020100010E03 /* schemas.js in Resources */, F6F405F81BCF0C1A00A1E24F /* base-test.js in Resources */, F68A278E1BC30F0A0063D40A /* index.js in Resources */, + 02AAAEF01BFE72F2002DD081 /* queryTests.json in Resources */, 0270BC831B7D020100010E03 /* RealmTests.js in Resources */, 0270BC841B7D020100010E03 /* ResultsTests.js in Resources */, ); diff --git a/tests/QueryTests.js b/tests/QueryTests.js index 3edf4773..bb6932a4 100644 --- a/tests/QueryTests.js +++ b/tests/QueryTests.js @@ -9,6 +9,7 @@ var Realm = require('realm'); var BaseTest = require('./base-test'); var TestCase = require('./asserts'); var schemas = require('./schemas'); +var testCases = require('./queryTests.json'); var typeConverters = {}; typeConverters[Realm.Types.DATE] = function(value) { return new Date(value); }; @@ -57,218 +58,12 @@ function runQuerySuite(suite) { realm.objects.apply(realm, args); }, "Expected exception not thrown for query: " + JSON.stringify(args)); } - else { + else if (test[0] != "Disabled") { throw "Invalid query test '" + test[0] + "'"; } } } -var testCases = { - -"dateTests": { - "schema" : [{ - "name": "DateObject", - "properties": [{ "name": "date", "type": Realm.Types.DATE }], - }], - "objects": [ - { "type": "DateObject", "value": [10000] }, - { "type": "DateObject", "value": [10001] }, - { "type": "DateObject", "value": [10002] }, - ], - "tests": [ - ["QueryCount", 2, "DateObject", "date < $0", [2, 0]], - ["QueryCount", 3, "DateObject", "date <= $0", [2, 0]], - ["QueryCount", 2, "DateObject", "date > $0", [0, 0]], - ["QueryCount", 3, "DateObject", "date >= $0", [0, 0]], - ["QueryCount", 1, "DateObject", "date == $0", [0, 0]], - ["QueryCount", 2, "DateObject", "date != $0", [0, 0]], - - ["QueryThrows", "DateObject", "date == 'not a date'"], - ["QueryThrows", "DateObject", "date == 1"], - ["QueryThrows", "DateObject", "date == $0", 1], - ] -}, - -"boolTests" : { - "schema" : [{ - "name": "BoolObject", - "properties": [{ "name": "boolCol", "type": Realm.Types.BOOL }], - }], - "objects": [ - { "type": "BoolObject", "value": [false] }, - { "type": "BoolObject", "value": [true] }, - { "type": "BoolObject", "value": [true] }, - ], - "tests": [ - ["QueryCount", 2, "BoolObject", "boolCol == true"], - ["QueryCount", 1, "BoolObject", "boolCol==false"], - ["QueryCount", 1, "BoolObject", "boolCol != true"], - ["QueryCount", 2, "BoolObject", "true == boolCol"], - ["QueryCount", 2, "BoolObject", "boolCol == TRUE"], - ["QueryCount", 1, "BoolObject", "boolCol == FALSE"], - ["QueryCount", 2, "BoolObject", "boolCol == $0", true], - ["QueryCount", 1, "BoolObject", "boolCol == $0", false], - ["QueryCount", 0, "BoolObject", "boolCol == true && boolCol == false"], - ["QueryCount", 3, "BoolObject", "boolCol == true || boolCol == false"], - - ["QueryThrows", "BoolObject", "boolCol == 0"], - ["QueryThrows", "BoolObject", "boolCol == 1"], - ["QueryThrows", "BoolObject", "boolCol == 'not a bool'"], - ["QueryThrows", "BoolObject", "boolCol == $0", "not a bool"], - ["QueryThrows", "BoolObject", "boolCol > true"], - ["QueryThrows", "BoolObject", "boolCol >= true"], - ["QueryThrows", "BoolObject", "boolCol < true"], - ["QueryThrows", "BoolObject", "boolCol <= true"], - ["QueryThrows", "BoolObject", "boolCol BEGINSWITH true"], - ["QueryThrows", "BoolObject", "boolCol CONTAINS true"], - ["QueryThrows", "BoolObject", "boolCol ENDSWITH true"], - ] -}, - -"intTests" : { - "schema" : [{ - "name": "IntObject", - "properties": [{ "name": "intCol", "type": Realm.Types.INT }], - }], - "objects": [ - { "type": "IntObject", "value": [-1] }, - { "type": "IntObject", "value": [0] }, - { "type": "IntObject", "value": [100] }, - ], - "tests": [ - ["QueryCount", 1, "IntObject", "intCol == -1"], - ["QueryCount", 1, "IntObject", "intCol==0"], - ["QueryCount", 0, "IntObject", "1 == intCol"], - ["QueryCount", 2, "IntObject", "intCol != 0"], - ["QueryCount", 2, "IntObject", "intCol > -1"], - ["QueryCount", 3, "IntObject", "intCol >= -1"], - ["QueryCount", 2, "IntObject", "intCol < 100"], - ["QueryCount", 3, "IntObject", "intCol <= 100"], - ["QueryCount", 1, "IntObject", "intCol > 0x1F"], - ["QueryCount", 1, "IntObject", "intCol == $0", 100], - - ["QueryThrows", "IntObject", "intCol == 'not an int'"], - ["QueryThrows", "IntObject", "intCol == true"], - ["QueryThrows", "IntObject", "intCol == $0", "not an int"], - ["QueryThrows", "IntObject", "intCol BEGINSWITH 1"], - ["QueryThrows", "IntObject", "intCol CONTAINS 1"], - ["QueryThrows", "IntObject", "intCol ENDSWITH 1"], - ] -}, - -"floatTests" : { - "schema" : [{ - "name": "FloatObject", - "properties": [{ "name": "floatCol", "type": Realm.Types.FLOAT }], - }], - "objects": [ - { "type": "FloatObject", "value": [-1.001] }, - { "type": "FloatObject", "value": [0.0] }, - { "type": "FloatObject", "value": [100.2] }, - ], - "tests": [ - ["QueryCount", 1, "FloatObject", "floatCol == -1.001"], - ["QueryCount", 1, "FloatObject", "floatCol = 0"], - ["QueryCount", 0, "FloatObject", "1 == floatCol"], - ["QueryCount", 2, "FloatObject", "floatCol != 0"], - ["QueryCount", 2, "FloatObject", "floatCol > -1.001"], - ["QueryCount", 3, "FloatObject", "floatCol >= -1.001"], - ["QueryCount", 2, "FloatObject", "floatCol < 100.2"], - ["QueryCount", 3, "FloatObject", "floatCol <= 100.2"], - ["QueryCount", 1, "FloatObject", "floatCol > 0x1F"], - ["QueryCount", 1, "FloatObject", "floatCol == $0", 100.2], - - ["QueryThrows", "FloatObject", "floatCol == 'not a float'"], - ["QueryThrows", "FloatObject", "floatCol == true"], - ["QueryThrows", "FloatObject", "floatCol == $0", "not a float"], - ["QueryThrows", "FloatObject", "floatCol BEGINSWITH 1"], - ["QueryThrows", "FloatObject", "floatCol CONTAINS 1"], - ["QueryThrows", "FloatObject", "floatCol ENDSWITH 1"], - //XCTAssertThrows(([[realm objects:[FloatObject className] where:@"floatCol = 3.5e+38"] count]), @"Too large to be a float"); - //XCTAssertThrows(([[realm objects:[FloatObject className] where:@"floatCol = -3.5e+38"] count]), @"Too small to be a float"); - ] -}, - -"doubleTests" : { - "schema" : [{ - "name": "DoubleObject", - "properties": [{ "name": "doubleCol", "type": Realm.Types.DOUBLE }], - }], - "objects": [ - { "type": "DoubleObject", "value": [-1.001] }, - { "type": "DoubleObject", "value": [0.0] }, - { "type": "DoubleObject", "value": [100.2] }, - ], - "tests": [ - ["QueryCount", 1, "DoubleObject", "doubleCol == -1.001"], - ["QueryCount", 1, "DoubleObject", "doubleCol == 0"], - ["QueryCount", 0, "DoubleObject", "1 == doubleCol"], - ["QueryCount", 2, "DoubleObject", "doubleCol != 0"], - ["QueryCount", 2, "DoubleObject", "doubleCol > -1.001"], - ["QueryCount", 3, "DoubleObject", "doubleCol >= -1.001"], - ["QueryCount", 2, "DoubleObject", "doubleCol < 100.2"], - ["QueryCount", 3, "DoubleObject", "doubleCol <= 100.2"], - ["QueryCount", 1, "DoubleObject", "doubleCol > 0x1F"], - ["QueryCount", 1, "DoubleObject", "doubleCol == $0", 100.2], - - ["QueryThrows", "DoubleObject", "doubleCol == 'not a double'"], - ["QueryThrows", "DoubleObject", "doubleCol == true"], - ["QueryThrows", "DoubleObject", "doubleCol == $0", "not a double"], - ["QueryThrows", "DoubleObject", "doubleCol BEGINSWITH 1"], - ["QueryThrows", "DoubleObject", "doubleCol CONTAINS 1"], - ["QueryThrows", "DoubleObject", "doubleCol ENDSWITH 1"], - ] -}, - -"stringTests" : { - "schema" : [{ - "name": "StringObject", - "properties": [{ "name": "stringCol", "type": Realm.Types.STRING }], - }], - "objects": [ - { "type": "StringObject", "value": ["A"] }, - { "type": "StringObject", "value": ["a"] }, - { "type": "StringObject", "value": ["a"] }, - { "type": "StringObject", "value": ["C"] }, - { "type": "StringObject", "value": ["c"] }, - { "type": "StringObject", "value": ["abc"] }, - { "type": "StringObject", "value": ["ABC"] }, - { "type": "StringObject", "value": [""] }, - { "type": "StringObject", "value": ["\\\"\\n\\0\\r\\\\'"] }, - ], - "tests": [ - ["QueryCount", 2, "StringObject", "stringCol == 'a'"], - ["QueryCount", 1, "StringObject", "'c' == stringCol"], - ["QueryCount", 2, "StringObject", "stringCol == \"a\""], - ["QueryCount", 1, "StringObject", "stringCol=='abc'"], - ["QueryCount", 1, "StringObject", "stringCol == ''"], - ["QueryCount", 8, "StringObject", "stringCol != ''"], - ["QueryCount", 1, "StringObject", "stringCol == \"\\\"\\n\\0\\r\\\\'\""], - ["QueryCount", 3, "StringObject", "stringCol BEGINSWITH 'a'"], - ["QueryCount", 1, "StringObject", "stringCol beginswith 'ab'"], - ["QueryCount", 0, "StringObject", "stringCol BEGINSWITH 'abcd'"], - ["QueryCount", 2, "StringObject", "stringCol BEGINSWITH 'A'"], - ["QueryCount", 2, "StringObject", "stringCol ENDSWITH 'c'"], - ["QueryCount", 1, "StringObject", "stringCol endswith 'bc'"], - ["QueryCount", 9, "StringObject", "stringCol ENDSWITH ''"], - ["QueryCount", 1, "StringObject", "stringCol CONTAINS 'b'"], - ["QueryCount", 2, "StringObject", "stringCol contains 'c'"], - ["QueryCount", 9, "StringObject", "stringCol CONTAINS ''"], - ["QueryCount", 2, "StringObject", "stringCol == $0", "a"], - ["QueryCount", 2, "StringObject", "stringCol ENDSWITH $0", "c"], - - ["QueryThrows", "StringObject", "stringCol == true"], - ["QueryThrows", "StringObject", "stringCol == 123"], - ["QueryThrows", "StringObject", "stringCol CONTAINS $0", 1], - - // ["QueryCount", 3, "StringObject", "stringCol ==[c] 'a'"], - // ["QueryCount", 5, "StringObject", "stringCol BEGINSWITH[c] 'A'"], - // ["QueryCount", 4, "StringObject", "stringCol ENDSWITH[c] 'c'"], - // ["QueryCount", 2, "StringObject", "stringCol CONTAINS[c] 'B'"], - ] -}, - -}; module.exports = BaseTest.extend({ testDateQueries: function() { diff --git a/tests/RJSModuleLoader.h b/tests/RJSModuleLoader.h index 680e75d2..c438f641 100644 --- a/tests/RJSModuleLoader.h +++ b/tests/RJSModuleLoader.h @@ -12,5 +12,6 @@ - (void)addGlobalModuleObject:(id)object forName:(NSString *)name; - (JSValue *)loadModuleFromURL:(NSURL *)url error:(NSError **)error; +- (JSValue *)loadJSONFromURL:(NSURL *)url error:(NSError **)error; @end diff --git a/tests/RJSModuleLoader.m b/tests/RJSModuleLoader.m index d81fb706..a188ff5c 100644 --- a/tests/RJSModuleLoader.m +++ b/tests/RJSModuleLoader.m @@ -42,14 +42,18 @@ static NSString * const RJSModuleLoaderErrorDomain = @"RJSModuleLoaderErrorDomai NSURL *url = [[NSURL URLWithString:name relativeToURL:baseURL] absoluteURL]; BOOL isDirectory; - if ([[NSFileManager defaultManager] fileExistsAtPath:url.path isDirectory:&isDirectory]) { - if (!isDirectory) { - return nil; - } - + if ([[NSFileManager defaultManager] fileExistsAtPath:url.path isDirectory:&isDirectory] && isDirectory) { url = [url URLByAppendingPathComponent:@"index.js"]; } else { - url = [url URLByAppendingPathExtension:@"js"]; + if ([[url pathExtension] isEqualToString:@"json"]) { + return [self loadJSONFromURL:url error:error]; + } + else if ([[url pathExtension] length] == 0) { + url = [url URLByAppendingPathExtension:@"js"]; + } + else { + return nil; + } } return [self loadModuleFromURL:url error:error]; @@ -136,6 +140,34 @@ static NSString * const RJSModuleLoaderErrorDomain = @"RJSModuleLoaderErrorDomai return exports; } +- (JSValue *)loadJSONFromURL:(NSURL *)url error:(NSError **)error { + url = url.absoluteURL; + url = url.standardizedURL ?: url; + + NSString *path = url.path; + JSValue *exports = self.modules[path]; + if (exports) { + return exports; + } + + NSString *source = [NSString stringWithContentsOfURL:url usedEncoding:NULL error:error]; + if (!source) { + return nil; + } + + JSContext *context = self.context; + JSValueRef json = JSValueMakeFromJSONString(context.JSGlobalContextRef, JSStringCreateWithUTF8CString(source.UTF8String)); + if (!json) { + *error = [NSError errorWithDomain:RJSModuleLoaderErrorDomain code:1 userInfo:@{ + NSLocalizedDescriptionKey: @"Invalid JSON" + }]; + return nil; + } + + self.modules[path] = [JSValue valueWithJSValueRef:json inContext:context]; + return self.modules[path]; +} + - (JSValue *)loadGlobalModule:(NSString *)name relativeToURL:(NSURL *)baseURL error:(NSError **)error { JSValue *exports = self.globalModules[name]; if (exports || !baseURL) { diff --git a/tests/queryTests.json b/tests/queryTests.json new file mode 100644 index 00000000..e1272cc3 --- /dev/null +++ b/tests/queryTests.json @@ -0,0 +1,207 @@ +{ + +"dateTests" : { + "schema" : [{ + "name": "DateObject", + "properties": [{ "name": "date", "type": "date" }] + }], + "objects": [ + { "type": "DateObject", "value": [10000] }, + { "type": "DateObject", "value": [10001] }, + { "type": "DateObject", "value": [10002] } + ], + "tests": [ + ["QueryCount", 2, "DateObject", "date < $0", [2, 0]], + ["QueryCount", 3, "DateObject", "date <= $0", [2, 0]], + ["QueryCount", 2, "DateObject", "date > $0", [0, 0]], + ["QueryCount", 3, "DateObject", "date >= $0", [0, 0]], + ["QueryCount", 1, "DateObject", "date == $0", [0, 0]], + ["QueryCount", 2, "DateObject", "date != $0", [0, 0]], + + ["QueryThrows", "DateObject", "date == 'not a date'"], + ["QueryThrows", "DateObject", "date == 1"], + ["QueryThrows", "DateObject", "date == $0", 1] + ] +}, + +"boolTests" : { + "schema" : [{ + "name": "BoolObject", + "properties": [{ "name": "boolCol", "type": "bool" }] + }], + "objects": [ + { "type": "BoolObject", "value": [false] }, + { "type": "BoolObject", "value": [true] }, + { "type": "BoolObject", "value": [true] } + ], + "tests": [ + ["QueryCount", 2, "BoolObject", "boolCol == true"], + ["QueryCount", 1, "BoolObject", "boolCol==false"], + ["QueryCount", 1, "BoolObject", "boolCol != true"], + ["QueryCount", 2, "BoolObject", "true == boolCol"], + ["QueryCount", 2, "BoolObject", "boolCol == TRUE"], + ["QueryCount", 1, "BoolObject", "boolCol == FALSE"], + ["QueryCount", 2, "BoolObject", "boolCol == $0", true], + ["QueryCount", 1, "BoolObject", "boolCol == $0", false], + ["QueryCount", 0, "BoolObject", "boolCol == true && boolCol == false"], + ["QueryCount", 3, "BoolObject", "boolCol == true || boolCol == false"], + + ["QueryThrows", "BoolObject", "boolCol == 0"], + ["QueryThrows", "BoolObject", "boolCol == 1"], + ["QueryThrows", "BoolObject", "boolCol == 'not a bool'"], + ["QueryThrows", "BoolObject", "boolCol == $0", "not a bool"], + ["QueryThrows", "BoolObject", "boolCol > true"], + ["QueryThrows", "BoolObject", "boolCol >= true"], + ["QueryThrows", "BoolObject", "boolCol < true"], + ["QueryThrows", "BoolObject", "boolCol <= true"], + ["QueryThrows", "BoolObject", "boolCol BEGINSWITH true"], + ["QueryThrows", "BoolObject", "boolCol CONTAINS true"], + ["QueryThrows", "BoolObject", "boolCol ENDSWITH true"] + ] +}, + +"intTests" : { + "schema" : [{ + "name": "IntObject", + "properties": [{ "name": "intCol", "type": "int" }] + }], + "objects": [ + { "type": "IntObject", "value": [-1] }, + { "type": "IntObject", "value": [0] }, + { "type": "IntObject", "value": [100] } + ], + "tests": [ + ["QueryCount", 1, "IntObject", "intCol == -1"], + ["QueryCount", 1, "IntObject", "intCol==0"], + ["QueryCount", 0, "IntObject", "1 == intCol"], + ["QueryCount", 2, "IntObject", "intCol != 0"], + ["QueryCount", 2, "IntObject", "intCol > -1"], + ["QueryCount", 3, "IntObject", "intCol >= -1"], + ["QueryCount", 2, "IntObject", "intCol < 100"], + ["QueryCount", 3, "IntObject", "intCol <= 100"], + ["QueryCount", 1, "IntObject", "intCol > 0x1F"], + ["QueryCount", 1, "IntObject", "intCol == $0", 100], + + ["QueryThrows", "IntObject", "intCol == 'not an int'"], + ["QueryThrows", "IntObject", "intCol == true"], + ["QueryThrows", "IntObject", "intCol == $0", "not an int"], + ["QueryThrows", "IntObject", "intCol BEGINSWITH 1"], + ["QueryThrows", "IntObject", "intCol CONTAINS 1"], + ["QueryThrows", "IntObject", "intCol ENDSWITH 1"] + ] +}, + +"floatTests" : { + "schema" : [{ + "name": "FloatObject", + "properties": [{ "name": "floatCol", "type": "float" }] + }], + "objects": [ + { "type": "FloatObject", "value": [-1.001] }, + { "type": "FloatObject", "value": [0.0] }, + { "type": "FloatObject", "value": [100.2] } + ], + "tests": [ + ["QueryCount", 1, "FloatObject", "floatCol == -1.001"], + ["QueryCount", 1, "FloatObject", "floatCol = 0"], + ["QueryCount", 0, "FloatObject", "1 == floatCol"], + ["QueryCount", 2, "FloatObject", "floatCol != 0"], + ["QueryCount", 2, "FloatObject", "floatCol > -1.001"], + ["QueryCount", 3, "FloatObject", "floatCol >= -1.001"], + ["QueryCount", 2, "FloatObject", "floatCol < 100.2"], + ["QueryCount", 3, "FloatObject", "floatCol <= 100.2"], + ["QueryCount", 1, "FloatObject", "floatCol > 0x1F"], + ["QueryCount", 1, "FloatObject", "floatCol == $0", 100.2], + + ["QueryThrows", "FloatObject", "floatCol == 'not a float'"], + ["QueryThrows", "FloatObject", "floatCol == true"], + ["QueryThrows", "FloatObject", "floatCol == $0", "not a float"], + ["QueryThrows", "FloatObject", "floatCol BEGINSWITH 1"], + ["QueryThrows", "FloatObject", "floatCol CONTAINS 1"], + ["QueryThrows", "FloatObject", "floatCol ENDSWITH 1"], + + ["Disabled", "QueryThrows", "FloatObject", "floatCol = 3.5e+38"], + ["Disabled", "QueryThrows", "FloatObject", "floatCol = -3.5e+38"] + ] +}, + +"doubleTests" : { + "schema" : [{ + "name": "DoubleObject", + "properties": [{ "name": "doubleCol", "type": "double" }] + }], + "objects": [ + { "type": "DoubleObject", "value": [-1.001] }, + { "type": "DoubleObject", "value": [0.0] }, + { "type": "DoubleObject", "value": [100.2] } + ], + "tests": [ + ["QueryCount", 1, "DoubleObject", "doubleCol == -1.001"], + ["QueryCount", 1, "DoubleObject", "doubleCol == 0"], + ["QueryCount", 0, "DoubleObject", "1 == doubleCol"], + ["QueryCount", 2, "DoubleObject", "doubleCol != 0"], + ["QueryCount", 2, "DoubleObject", "doubleCol > -1.001"], + ["QueryCount", 3, "DoubleObject", "doubleCol >= -1.001"], + ["QueryCount", 2, "DoubleObject", "doubleCol < 100.2"], + ["QueryCount", 3, "DoubleObject", "doubleCol <= 100.2"], + ["QueryCount", 1, "DoubleObject", "doubleCol > 0x1F"], + ["QueryCount", 1, "DoubleObject", "doubleCol == $0", 100.2], + + ["QueryThrows", "DoubleObject", "doubleCol == 'not a double'"], + ["QueryThrows", "DoubleObject", "doubleCol == true"], + ["QueryThrows", "DoubleObject", "doubleCol == $0", "not a double"], + ["QueryThrows", "DoubleObject", "doubleCol BEGINSWITH 1"], + ["QueryThrows", "DoubleObject", "doubleCol CONTAINS 1"], + ["QueryThrows", "DoubleObject", "doubleCol ENDSWITH 1"] + ] +}, + +"stringTests" : { + "schema" : [{ + "name": "StringObject", + "properties": [{ "name": "stringCol", "type": "string" }] + }], + "objects": [ + { "type": "StringObject", "value": ["A"] }, + { "type": "StringObject", "value": ["a"] }, + { "type": "StringObject", "value": ["a"] }, + { "type": "StringObject", "value": ["C"] }, + { "type": "StringObject", "value": ["c"] }, + { "type": "StringObject", "value": ["abc"] }, + { "type": "StringObject", "value": ["ABC"] }, + { "type": "StringObject", "value": [""] }, + { "type": "StringObject", "value": ["\\\"\\n\\0\\r\\\\'"] } + ], + "tests": [ + ["QueryCount", 2, "StringObject", "stringCol == 'a'"], + ["QueryCount", 1, "StringObject", "'c' == stringCol"], + ["QueryCount", 2, "StringObject", "stringCol == \"a\""], + ["QueryCount", 1, "StringObject", "stringCol=='abc'"], + ["QueryCount", 1, "StringObject", "stringCol == ''"], + ["QueryCount", 8, "StringObject", "stringCol != ''"], + ["QueryCount", 1, "StringObject", "stringCol == \"\\\"\\n\\0\\r\\\\'\""], + ["QueryCount", 3, "StringObject", "stringCol BEGINSWITH 'a'"], + ["QueryCount", 1, "StringObject", "stringCol beginswith 'ab'"], + ["QueryCount", 0, "StringObject", "stringCol BEGINSWITH 'abcd'"], + ["QueryCount", 2, "StringObject", "stringCol BEGINSWITH 'A'"], + ["QueryCount", 2, "StringObject", "stringCol ENDSWITH 'c'"], + ["QueryCount", 1, "StringObject", "stringCol endswith 'bc'"], + ["QueryCount", 9, "StringObject", "stringCol ENDSWITH ''"], + ["QueryCount", 1, "StringObject", "stringCol CONTAINS 'b'"], + ["QueryCount", 2, "StringObject", "stringCol contains 'c'"], + ["QueryCount", 9, "StringObject", "stringCol CONTAINS ''"], + ["QueryCount", 2, "StringObject", "stringCol == $0", "a"], + ["QueryCount", 2, "StringObject", "stringCol ENDSWITH $0", "c"], + + ["QueryThrows", "StringObject", "stringCol == true"], + ["QueryThrows", "StringObject", "stringCol == 123"], + ["QueryThrows", "StringObject", "stringCol CONTAINS $0", 1], + + ["Disabled", "QueryCount", 3, "StringObject", "stringCol ==[c] 'a'"], + ["Disabled", "QueryCount", 5, "StringObject", "stringCol BEGINSWITH[c] 'A'"], + ["Disabled", "QueryCount", 4, "StringObject", "stringCol ENDSWITH[c] 'c'"], + ["Disabled", "QueryCount", 2, "StringObject", "stringCol CONTAINS[c] 'B'"] + ] +} + +} \ No newline at end of file