FSTFieldValueTests.mm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "Firestore/Source/Model/FSTFieldValue.h"
  17. #import <FirebaseFirestore/FIRGeoPoint.h>
  18. #import <FirebaseFirestore/FIRTimestamp.h>
  19. #import <XCTest/XCTest.h>
  20. #import "Firestore/Source/API/FIRFirestore+Internal.h"
  21. #import "Firestore/Source/API/FSTUserDataConverter.h"
  22. #import "Firestore/Source/API/converters.h"
  23. #import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
  24. #import "Firestore/Example/Tests/Util/FSTHelpers.h"
  25. #include "Firestore/core/include/firebase/firestore/geo_point.h"
  26. #include "Firestore/core/src/firebase/firestore/model/database_id.h"
  27. #include "Firestore/core/src/firebase/firestore/model/field_value.h"
  28. #include "Firestore/core/src/firebase/firestore/util/string_apple.h"
  29. #include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
  30. #include "Firestore/core/test/firebase/firestore/testutil/time_testing.h"
  31. namespace testutil = firebase::firestore::testutil;
  32. namespace util = firebase::firestore::util;
  33. using firebase::firestore::GeoPoint;
  34. using firebase::firestore::api::MakeTimestamp;
  35. using firebase::firestore::model::DatabaseId;
  36. using firebase::firestore::model::FieldValue;
  37. /** Helper to wrap the values in a set of equality groups using FSTTestFieldValue(). */
  38. NSArray *FSTWrapGroups(NSArray *groups) {
  39. NSMutableArray *wrapped = [NSMutableArray array];
  40. for (NSArray<id> *group in groups) {
  41. NSMutableArray *wrappedGroup = [NSMutableArray array];
  42. for (id value in group) {
  43. FSTFieldValue *wrappedValue;
  44. // Server Timestamp values can't be parsed directly, so we have a couple predefined sentinel
  45. // strings that can be used instead.
  46. if ([value isEqual:@"server-timestamp-1"]) {
  47. wrappedValue = [FSTServerTimestampValue
  48. serverTimestampValueWithLocalWriteTime:testutil::MakeTimestamp(2016, 5, 20, 10, 20, 0)
  49. previousValue:nil];
  50. } else if ([value isEqual:@"server-timestamp-2"]) {
  51. wrappedValue = [FSTServerTimestampValue
  52. serverTimestampValueWithLocalWriteTime:testutil::MakeTimestamp(2016, 10, 21, 15, 32, 0)
  53. previousValue:nil];
  54. } else if ([value isKindOfClass:[FSTDocumentKeyReference class]]) {
  55. // We directly convert these here so that the databaseIDs can be different.
  56. FSTDocumentKeyReference *reference = (FSTDocumentKeyReference *)value;
  57. wrappedValue =
  58. [FSTReferenceValue referenceValue:[FSTDocumentKey keyWithDocumentKey:reference.key]
  59. databaseID:reference.databaseID];
  60. } else {
  61. wrappedValue = FSTTestFieldValue(value);
  62. }
  63. [wrappedGroup addObject:wrappedValue];
  64. }
  65. [wrapped addObject:wrappedGroup];
  66. }
  67. return wrapped;
  68. }
  69. @interface FSTFieldValueTests : XCTestCase
  70. @end
  71. @implementation FSTFieldValueTests {
  72. NSDate *date1;
  73. NSDate *date2;
  74. }
  75. - (void)setUp {
  76. [super setUp];
  77. // Create a couple date objects for use in tests.
  78. date1 = FSTTestDate(2016, 5, 20, 10, 20, 0);
  79. date2 = FSTTestDate(2016, 10, 21, 15, 32, 0);
  80. }
  81. union DoubleBits {
  82. double d;
  83. uint64_t bits;
  84. };
  85. - (void)testNormalizesNaNs {
  86. // NOTE: With v1 query semantics, it's no longer as important that our NaN representation matches
  87. // the backend, since all NaNs are defined to sort as equal, but we preserve the normalization and
  88. // this test regardless for now.
  89. // We use a canonical NaN bit pattern that's common for both Java and Objective-C. Specifically:
  90. // - sign: 0
  91. // - exponent: 11 bits, all 1
  92. // - significand: 52 bits, MSB=1, rest=0
  93. //
  94. // This matches the Firestore backend which uses Java's Double.doubleToLongBits which is defined
  95. // to normalize all NaNs to this value.
  96. union DoubleBits canonical = {.bits = 0x7ff8000000000000ULL};
  97. // IEEE 754 specifies that NaN isn't equal to itself.
  98. XCTAssertTrue(isnan(canonical.d));
  99. XCTAssertEqual(canonical.bits, canonical.bits);
  100. XCTAssertNotEqual(canonical.d, canonical.d);
  101. // All permutations of the 51 other non-MSB significand bits are also NaNs.
  102. union DoubleBits alternate = {.bits = 0x7fff000000000000ULL};
  103. XCTAssertTrue(isnan(alternate.d));
  104. XCTAssertNotEqual(alternate.bits, canonical.bits);
  105. XCTAssertNotEqual(alternate.d, canonical.d);
  106. // Even though at the C-level assignment preserves non-canonical NaNs, NSNumber normalizes all
  107. // NaNs to single shared instance, kCFNumberNaN. That NaN has no public definition for its value
  108. // but it happens to match what we need.
  109. union DoubleBits normalized = {.d = [[NSNumber numberWithDouble:alternate.d] doubleValue]};
  110. XCTAssertEqual(normalized.bits, canonical.bits);
  111. // Ensure we get the same normalization behavior (currently implemented explicitly by checking
  112. // for isnan() and then explicitly assigning NAN).
  113. union DoubleBits result;
  114. result.d = FieldValue::FromDouble(canonical.d).double_value();
  115. XCTAssertEqual(result.bits, canonical.bits);
  116. result.d = FieldValue::FromDouble(alternate.d).double_value();
  117. XCTAssertEqual(result.bits, canonical.bits);
  118. // A NaN that's canonical except it has the sign bit set (would be negative if signs mattered)
  119. union DoubleBits negative = {.bits = 0xfff8000000000000ULL};
  120. result.d = FieldValue::FromDouble(negative.d).double_value();
  121. XCTAssertTrue(isnan(negative.d));
  122. XCTAssertEqual(result.bits, canonical.bits);
  123. // A signaling NaN with significand where MSB is 0, and some non-MSB bit is one.
  124. union DoubleBits signaling = {.bits = 0xfff4000000000000ULL};
  125. XCTAssertTrue(isnan(signaling.d));
  126. result.d = FieldValue::FromDouble(signaling.d).double_value();
  127. XCTAssertEqual(result.bits, canonical.bits);
  128. }
  129. - (void)testZeros {
  130. // Floating point numbers have an explicit sign bit so it's possible to end up with negative
  131. // zero as a distinct value from positive zero.
  132. union DoubleBits zero = {.d = 0.0};
  133. union DoubleBits negativeZero = {.d = -0.0};
  134. // IEEE 754 requires these two zeros to compare equal.
  135. XCTAssertNotEqual(zero.bits, negativeZero.bits);
  136. XCTAssertEqual(zero.d, negativeZero.d);
  137. // NSNumber preserves the negative zero value but compares equal according to IEEE 754.
  138. union DoubleBits normalized = {.d = [[NSNumber numberWithDouble:negativeZero.d] doubleValue]};
  139. XCTAssertEqual(normalized.bits, negativeZero.bits);
  140. XCTAssertEqualObjects([NSNumber numberWithDouble:0.0], [NSNumber numberWithDouble:-0.0]);
  141. // FieldValue::FromDouble preserves positive/negative zero
  142. union DoubleBits result;
  143. result.d = FieldValue::FromDouble(zero.d).double_value();
  144. XCTAssertEqual(result.bits, zero.bits);
  145. result.d = FieldValue::FromDouble(negativeZero.d).double_value();
  146. XCTAssertEqual(result.bits, negativeZero.bits);
  147. // ... but compares positive/negative zero as unequal, compatibly with Firestore.
  148. XCTAssertNotEqual(FieldValue::FromDouble(0.0), FieldValue::FromDouble(-0.0));
  149. }
  150. - (void)testExtractsFields {
  151. FSTObjectValue *obj = FSTTestObjectValue(@{@"foo" : @{@"a" : @YES, @"b" : @"string"}});
  152. FSTAssertIsKindOfClass(obj, FSTObjectValue);
  153. FSTAssertIsKindOfClass([obj valueForPath:testutil::Field("foo")], FSTObjectValue);
  154. XCTAssertEqualObjects([obj valueForPath:testutil::Field("foo.a")], FieldValue::True().Wrap());
  155. XCTAssertEqualObjects([obj valueForPath:testutil::Field("foo.b")],
  156. FieldValue::FromString("string").Wrap());
  157. XCTAssertNil([obj valueForPath:testutil::Field("foo.a.b")]);
  158. XCTAssertNil([obj valueForPath:testutil::Field("bar")]);
  159. XCTAssertNil([obj valueForPath:testutil::Field("bar.a")]);
  160. }
  161. - (void)testOverwritesExistingFields {
  162. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @"old"});
  163. FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod")
  164. forPath:testutil::Field("a")];
  165. // Should return a new object, leaving the old one unmodified.
  166. XCTAssertNotEqual(old, mod);
  167. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @"old"}));
  168. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @"mod"}));
  169. }
  170. - (void)testAddsNewFields {
  171. FSTObjectValue *empty = [FSTObjectValue objectValue];
  172. FSTObjectValue *mod = [empty objectBySettingValue:FSTTestFieldValue(@"mod")
  173. forPath:testutil::Field("a")];
  174. XCTAssertNotEqual(empty, mod);
  175. XCTAssertEqualObjects(empty, FSTTestFieldValue(@{}));
  176. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @"mod"}));
  177. FSTObjectValue *old = mod;
  178. mod = [old objectBySettingValue:FSTTestFieldValue(@1) forPath:testutil::Field("b")];
  179. XCTAssertNotEqual(old, mod);
  180. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @"mod"}));
  181. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @"mod", @"b" : @1}));
  182. }
  183. - (void)testImplicitlyCreatesObjects {
  184. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @"old"});
  185. FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod")
  186. forPath:testutil::Field("b.c.d")];
  187. XCTAssertNotEqual(old, mod);
  188. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @"old"}));
  189. XCTAssertEqualObjects(mod,
  190. FSTTestFieldValue(@{@"a" : @"old", @"b" : @{@"c" : @{@"d" : @"mod"}}}));
  191. }
  192. - (void)testCanOverwritePrimitivesWithObjects {
  193. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @"old"}});
  194. FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@{@"b" : @"mod"})
  195. forPath:testutil::Field("a")];
  196. XCTAssertNotEqual(old, mod);
  197. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @"old"}}));
  198. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @"mod"}}));
  199. }
  200. - (void)testAddsToNestedObjects {
  201. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @"old"}});
  202. FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod")
  203. forPath:testutil::Field("a.c")];
  204. XCTAssertNotEqual(old, mod);
  205. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @"old"}}));
  206. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @"old", @"c" : @"mod"}}));
  207. }
  208. - (void)testDeletesKeys {
  209. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @1, @"b" : @2});
  210. FSTObjectValue *mod = [old objectByDeletingPath:testutil::Field("a")];
  211. XCTAssertNotEqual(old, mod);
  212. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @1, @"b" : @2}));
  213. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"b" : @2}));
  214. FSTObjectValue *empty = [mod objectByDeletingPath:testutil::Field("b")];
  215. XCTAssertNotEqual(mod, empty);
  216. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"b" : @2}));
  217. XCTAssertEqualObjects(empty, FSTTestFieldValue(@{}));
  218. }
  219. - (void)testDeletesHandleMissingKeys {
  220. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @1, @"c" : @2}});
  221. FSTObjectValue *mod = [old objectByDeletingPath:testutil::Field("b")];
  222. XCTAssertEqualObjects(old, mod);
  223. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @2}}));
  224. mod = [old objectByDeletingPath:testutil::Field("a.d")];
  225. XCTAssertEqualObjects(old, mod);
  226. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @2}}));
  227. mod = [old objectByDeletingPath:testutil::Field("a.b.c")];
  228. XCTAssertEqualObjects(old, mod);
  229. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @2}}));
  230. }
  231. - (void)testDeletesNestedKeys {
  232. FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @1, @"c" : @{@"d" : @2, @"e" : @3}}});
  233. FSTObjectValue *mod = [old objectByDeletingPath:testutil::Field("a.c.d")];
  234. XCTAssertNotEqual(old, mod);
  235. XCTAssertEqualObjects(old,
  236. FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @{@"d" : @2, @"e" : @3}}}));
  237. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @{@"e" : @3}}}));
  238. old = mod;
  239. mod = [old objectByDeletingPath:testutil::Field("a.c")];
  240. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @{@"e" : @3}}}));
  241. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1}}));
  242. old = mod;
  243. mod = [old objectByDeletingPath:testutil::Field("a")];
  244. XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @1}}));
  245. XCTAssertEqualObjects(mod, FSTTestFieldValue(@{}));
  246. }
  247. - (void)testValueEquality {
  248. DatabaseId database_id("project");
  249. NSArray *groups = @[
  250. @[ FSTTestFieldValue(@YES), FieldValue::True().Wrap() ],
  251. @[ FSTTestFieldValue(@NO), FieldValue::False().Wrap() ],
  252. @[ FSTTestFieldValue([NSNull null]), FieldValue::Null().Wrap() ],
  253. @[ FSTTestFieldValue(@(0.0 / 0.0)), FSTTestFieldValue(@(NAN)), FieldValue::Nan().Wrap() ],
  254. // -0.0 and 0.0 compare: the same (but are not isEqual:)
  255. @[ FSTTestFieldValue(@(-0.0)) ], @[ FSTTestFieldValue(@0.0) ],
  256. @[ FSTTestFieldValue(@1), FSTTestFieldValue(@1LL), FieldValue::FromInteger(1LL).Wrap() ],
  257. // double and unit64_t values can compare: the same (but won't be isEqual:)
  258. @[ FSTTestFieldValue(@1.0), FieldValue::FromDouble(1.0).Wrap() ],
  259. @[ FSTTestFieldValue(@1.1), FieldValue::FromDouble(1.1).Wrap() ],
  260. @[ FSTTestFieldValue(FSTTestData(0, 1, 2, -1)), testutil::BlobValue(0, 1, 2).Wrap() ],
  261. @[ FSTTestFieldValue(FSTTestData(0, 1, -1)) ],
  262. @[ FSTTestFieldValue(@"string"), FieldValue::FromString("string").Wrap() ],
  263. @[ FSTTestFieldValue(@"strin") ],
  264. @[ FSTTestFieldValue(@"e\u0301b") ], // latin small letter e + combining acute accent
  265. @[ FSTTestFieldValue(@"\u00e9a") ], // latin small letter e with acute accent
  266. @[ FSTTestFieldValue(date1), FieldValue::FromTimestamp(MakeTimestamp(date1)).Wrap() ],
  267. @[ FSTTestFieldValue(date2) ],
  268. @[
  269. // NOTE: ServerTimestampValues can't be parsed via FSTTestFieldValue().
  270. [FSTServerTimestampValue serverTimestampValueWithLocalWriteTime:MakeTimestamp(date1)
  271. previousValue:nil],
  272. [FSTServerTimestampValue serverTimestampValueWithLocalWriteTime:MakeTimestamp(date1)
  273. previousValue:nil]
  274. ],
  275. @[ [FSTServerTimestampValue serverTimestampValueWithLocalWriteTime:MakeTimestamp(date2)
  276. previousValue:nil] ],
  277. @[ FSTTestFieldValue(FSTTestGeoPoint(0, 1)), FieldValue::FromGeoPoint(GeoPoint(0, 1)).Wrap() ],
  278. @[ FSTTestFieldValue(FSTTestGeoPoint(1, 0)) ],
  279. @[
  280. [FSTReferenceValue
  281. referenceValue:[FSTDocumentKey keyWithDocumentKey:FSTTestDocKey(@"coll/doc1")]
  282. databaseID:database_id],
  283. FSTTestFieldValue(FSTTestRef("project", DatabaseId::kDefault, @"coll/doc1"))
  284. ],
  285. @[ FSTTestRef("project", "(default)", @"coll/doc2") ],
  286. @[ FSTTestFieldValue(@[ @"foo", @"bar" ]), FSTTestFieldValue(@[ @"foo", @"bar" ]) ],
  287. @[ FSTTestFieldValue(@[ @"foo", @"bar", @"baz" ]) ], @[ FSTTestFieldValue(@[ @"foo" ]) ],
  288. @[
  289. FSTTestFieldValue(@{@"bar" : @1, @"foo" : @2}), FSTTestFieldValue(@{@"foo" : @2, @"bar" : @1})
  290. ],
  291. @[ FSTTestFieldValue(@{@"bar" : @2, @"foo" : @1}) ],
  292. @[ FSTTestFieldValue(@{@"bar" : @1, @"foo" : @1}) ], @[ FSTTestFieldValue(@{@"foo" : @1}) ]
  293. ];
  294. FSTAssertEqualityGroups(groups);
  295. }
  296. - (void)testValueOrdering {
  297. NSArray *groups = @[
  298. // null first
  299. @[ [NSNull null] ],
  300. // booleans
  301. @[ @NO ], @[ @YES ],
  302. // numbers
  303. @[ @(0.0 / 0.0) ], @[ @(-INFINITY) ], @[ @(-DBL_MAX) ], @[ @(LLONG_MIN) ], @[ @(-1.1) ],
  304. @[ @(-1.0), @(-1LL) ], // longs and doubles compare the same
  305. @[ @(-DBL_MIN) ],
  306. @[ @(-0x1.0p-1074) ], // negative smallest subnormal
  307. @[ @(-0.0), @(0.0), @(0LL) ], // zeros all compare the same
  308. @[ @(0x1.0p-1074) ], // positive smallest subnormal
  309. @[ @(DBL_MIN) ], @[ @1.0, @1LL ], // longs and doubles compare the same
  310. @[ @1.1 ], @[ @(LLONG_MAX) ], @[ @(DBL_MAX) ], @[ @(INFINITY) ],
  311. // timestamps
  312. @[ date1 ], @[ date2 ],
  313. // server timestamps come after all concrete timestamps.
  314. // NOTE: server timestamps can't be parsed directly, so we have special sentinel strings (see
  315. // FSTWrapGroups()).
  316. @[ @"server-timestamp-1" ], @[ @"server-timestamp-2" ],
  317. // strings
  318. @[ @"" ], @[ @"\000\ud7ff\ue000\uffff" ], @[ @"(╯°□°)╯︵ ┻━┻" ], @[ @"a" ], @[ @"abc def" ],
  319. @[ @"e\u0301b" ], // latin small letter e + combining acute accent + latin small letter b
  320. @[ @"æ" ],
  321. @[ @"\u00e9a" ], // latin small letter e with acute accent + latin small letter a
  322. // blobs
  323. @[ FSTTestData(-1) ], @[ FSTTestData(0, -1) ], @[ FSTTestData(0, 1, 2, 3, 4, -1) ],
  324. @[ FSTTestData(0, 1, 2, 4, 3, -1) ], @[ FSTTestData(255, -1) ],
  325. // resource names
  326. @[ FSTTestRef("p1", "d1", @"c1/doc1") ], @[ FSTTestRef("p1", "d1", @"c1/doc2") ],
  327. @[ FSTTestRef("p1", "d1", @"c10/doc1") ], @[ FSTTestRef("p1", "d1", @"c2/doc1") ],
  328. @[ FSTTestRef("p1", "d2", @"c1/doc1") ], @[ FSTTestRef("p2", "d1", @"c1/doc1") ],
  329. // Geo points
  330. @[ FSTTestGeoPoint(-90, -180) ], @[ FSTTestGeoPoint(-90, 0) ], @[ FSTTestGeoPoint(-90, 180) ],
  331. @[ FSTTestGeoPoint(0, -180) ], @[ FSTTestGeoPoint(0, 0) ], @[ FSTTestGeoPoint(0, 180) ],
  332. @[ FSTTestGeoPoint(1, -180) ], @[ FSTTestGeoPoint(1, 0) ], @[ FSTTestGeoPoint(1, 180) ],
  333. @[ FSTTestGeoPoint(90, -180) ], @[ FSTTestGeoPoint(90, 0) ], @[ FSTTestGeoPoint(90, 180) ],
  334. // Arrays
  335. @[ @[] ], @[ @[ @"bar" ] ], @[ @[ @"foo" ] ], @[ @[ @"foo", @1 ] ], @[ @[ @"foo", @2 ] ],
  336. @[ @[ @"foo", @"0" ] ],
  337. // Objects
  338. @[ @{@"bar" : @0} ], @[ @{@"bar" : @0, @"foo" : @1} ], @[ @{@"foo" : @1} ], @[ @{@"foo" : @2} ],
  339. @[ @{@"foo" : @"0"} ]
  340. ];
  341. NSArray *wrapped = FSTWrapGroups(groups);
  342. FSTAssertComparisons(wrapped);
  343. }
  344. @end