FIROptionsTest.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. // Copyright 2017 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "FIRTestCase.h"
  15. #import <FirebaseCore/FIRAppInternal.h>
  16. #import <FirebaseCore/FIRBundleUtil.h>
  17. #import <FirebaseCore/FIROptionsInternal.h>
  18. extern NSString *const kFIRIsMeasurementEnabled;
  19. extern NSString *const kFIRIsAnalyticsCollectionEnabled;
  20. extern NSString *const kFIRIsAnalyticsCollectionDeactivated;
  21. extern NSString *const kFIRLibraryVersionID;
  22. @interface FIROptions (Test)
  23. @property(nonatomic, readonly) NSDictionary *analyticsOptionsDictionary;
  24. @end
  25. @interface FIROptionsTest : FIRTestCase
  26. @end
  27. @implementation FIROptionsTest
  28. - (void)setUp {
  29. [super setUp];
  30. [FIROptions resetDefaultOptions];
  31. }
  32. - (void)testInit {
  33. NSDictionary *optionsDictionary = [FIROptions defaultOptionsDictionary];
  34. FIROptions *options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  35. [self assertOptionsMatchDefaults:options andProjectID:YES];
  36. XCTAssertNil(options.deepLinkURLScheme);
  37. XCTAssertTrue(options.usingOptionsFromDefaultPlist);
  38. options.deepLinkURLScheme = kDeepLinkURLScheme;
  39. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  40. }
  41. - (void)testDefaultOptionsDictionaryWithNilFilePath {
  42. id mockBundleUtil = OCMClassMock([FIRBundleUtil class]);
  43. [OCMStub([mockBundleUtil optionsDictionaryPathWithResourceName:kServiceInfoFileName
  44. andFileType:kServiceInfoFileType
  45. inBundles:[FIRBundleUtil relevantBundles]])
  46. andReturn:nil];
  47. XCTAssertNil([FIROptions defaultOptionsDictionary]);
  48. }
  49. - (void)testDefaultOptionsDictionaryWithInvalidSourceFile {
  50. id mockBundleUtil = OCMClassMock([FIRBundleUtil class]);
  51. [OCMStub([mockBundleUtil optionsDictionaryPathWithResourceName:kServiceInfoFileName
  52. andFileType:kServiceInfoFileType
  53. inBundles:[FIRBundleUtil relevantBundles]])
  54. andReturn:@"invalid.plist"];
  55. XCTAssertNil([FIROptions defaultOptionsDictionary]);
  56. }
  57. - (void)testDefaultOptions {
  58. FIROptions *options = [FIROptions defaultOptions];
  59. [self assertOptionsMatchDefaults:options andProjectID:YES];
  60. XCTAssertNil(options.deepLinkURLScheme);
  61. XCTAssertTrue(options.usingOptionsFromDefaultPlist);
  62. options.deepLinkURLScheme = kDeepLinkURLScheme;
  63. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  64. }
  65. - (void)testInitCustomizedOptions {
  66. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  67. FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  68. bundleID:kBundleID
  69. GCMSenderID:kGCMSenderID
  70. APIKey:kAPIKey
  71. clientID:kClientID
  72. trackingID:kTrackingID
  73. androidClientID:(id _Nonnull)nil
  74. databaseURL:kDatabaseURL
  75. storageBucket:kStorageBucket
  76. deepLinkURLScheme:kDeepLinkURLScheme];
  77. #pragma clang pop
  78. [self assertOptionsMatchDefaults:options andProjectID:NO];
  79. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  80. XCTAssertFalse(options.usingOptionsFromDefaultPlist);
  81. FIROptions *options2 =
  82. [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID];
  83. options2.APIKey = kAPIKey;
  84. options2.bundleID = kBundleID;
  85. options2.clientID = kClientID;
  86. options2.databaseURL = kDatabaseURL;
  87. options2.deepLinkURLScheme = kDeepLinkURLScheme;
  88. options2.projectID = kProjectID;
  89. options2.storageBucket = kStorageBucket;
  90. options2.trackingID = kTrackingID;
  91. [self assertOptionsMatchDefaults:options2 andProjectID:YES];
  92. XCTAssertEqualObjects(options2.deepLinkURLScheme, kDeepLinkURLScheme);
  93. XCTAssertFalse(options.usingOptionsFromDefaultPlist);
  94. // nil GoogleAppID should throw an exception
  95. #pragma clang diagnostic push
  96. #pragma clang diagnostic ignored "-Wnonnull"
  97. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  98. XCTAssertThrows([[FIROptions alloc] initWithGoogleAppID:nil
  99. bundleID:kBundleID
  100. GCMSenderID:kGCMSenderID
  101. APIKey:kCustomizedAPIKey
  102. clientID:nil
  103. trackingID:nil
  104. androidClientID:nil
  105. databaseURL:nil
  106. storageBucket:nil
  107. deepLinkURLScheme:nil]);
  108. #pragma clang diagnostic pop
  109. }
  110. - (void)testinitWithContentsOfFile {
  111. NSString *filePath =
  112. [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
  113. FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
  114. [self assertOptionsMatchDefaults:options andProjectID:YES];
  115. XCTAssertNil(options.deepLinkURLScheme);
  116. XCTAssertFalse(options.usingOptionsFromDefaultPlist);
  117. #pragma clang diagnostic push
  118. #pragma clang diagnostic ignored "-Wnonnull"
  119. FIROptions *emptyOptions = [[FIROptions alloc] initWithContentsOfFile:nil];
  120. #pragma clang diagnostic pop
  121. XCTAssertNil(emptyOptions);
  122. FIROptions *invalidOptions = [[FIROptions alloc] initWithContentsOfFile:@"invalid.plist"];
  123. XCTAssertNil(invalidOptions);
  124. }
  125. - (void)assertOptionsMatchDefaults:(FIROptions *)options andProjectID:(BOOL)matchProjectID {
  126. XCTAssertEqualObjects(options.googleAppID, kGoogleAppID);
  127. XCTAssertEqualObjects(options.APIKey, kAPIKey);
  128. XCTAssertEqualObjects(options.clientID, kClientID);
  129. XCTAssertEqualObjects(options.trackingID, kTrackingID);
  130. XCTAssertEqualObjects(options.GCMSenderID, kGCMSenderID);
  131. XCTAssertNil(options.androidClientID);
  132. XCTAssertEqualObjects(options.libraryVersionID, kFIRLibraryVersionID);
  133. XCTAssertEqualObjects(options.databaseURL, kDatabaseURL);
  134. XCTAssertEqualObjects(options.storageBucket, kStorageBucket);
  135. XCTAssertEqualObjects(options.bundleID, kBundleID);
  136. // Custom `matchProjectID` parameter to be removed once the deprecated `FIROptions` constructor is
  137. // removed.
  138. if (matchProjectID) {
  139. XCTAssertEqualObjects(options.projectID, kProjectID);
  140. }
  141. }
  142. - (void)testCopyingProperties {
  143. NSMutableString *mutableString;
  144. FIROptions *options =
  145. [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID];
  146. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  147. options.APIKey = mutableString;
  148. [mutableString appendString:@"2"];
  149. XCTAssertEqualObjects(options.APIKey, @"1");
  150. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  151. options.bundleID = mutableString;
  152. [mutableString appendString:@"2"];
  153. XCTAssertEqualObjects(options.bundleID, @"1");
  154. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  155. options.clientID = mutableString;
  156. [mutableString appendString:@"2"];
  157. XCTAssertEqualObjects(options.clientID, @"1");
  158. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  159. options.trackingID = mutableString;
  160. [mutableString appendString:@"2"];
  161. XCTAssertEqualObjects(options.trackingID, @"1");
  162. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  163. options.GCMSenderID = mutableString;
  164. [mutableString appendString:@"2"];
  165. XCTAssertEqualObjects(options.GCMSenderID, @"1");
  166. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  167. options.projectID = mutableString;
  168. [mutableString appendString:@"2"];
  169. XCTAssertEqualObjects(options.projectID, @"1");
  170. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  171. options.androidClientID = mutableString;
  172. [mutableString appendString:@"2"];
  173. XCTAssertEqualObjects(options.androidClientID, @"1");
  174. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  175. options.googleAppID = mutableString;
  176. [mutableString appendString:@"2"];
  177. XCTAssertEqualObjects(options.googleAppID, @"1");
  178. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  179. options.databaseURL = mutableString;
  180. [mutableString appendString:@"2"];
  181. XCTAssertEqualObjects(options.databaseURL, @"1");
  182. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  183. options.deepLinkURLScheme = mutableString;
  184. [mutableString appendString:@"2"];
  185. XCTAssertEqualObjects(options.deepLinkURLScheme, @"1");
  186. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  187. options.storageBucket = mutableString;
  188. [mutableString appendString:@"2"];
  189. XCTAssertEqualObjects(options.storageBucket, @"1");
  190. }
  191. - (void)testCopyWithZone {
  192. // default options
  193. FIROptions *options = [FIROptions defaultOptions];
  194. options.deepLinkURLScheme = kDeepLinkURLScheme;
  195. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  196. FIROptions *newOptions = [options copy];
  197. XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  198. [options setDeepLinkURLScheme:kNewDeepLinkURLScheme];
  199. XCTAssertEqualObjects(options.deepLinkURLScheme, kNewDeepLinkURLScheme);
  200. XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  201. // customized options
  202. FIROptions *customizedOptions = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  203. bundleID:kBundleID
  204. GCMSenderID:kGCMSenderID
  205. APIKey:kAPIKey
  206. clientID:kClientID
  207. trackingID:kTrackingID
  208. androidClientID:(id _Nonnull)nil
  209. databaseURL:kDatabaseURL
  210. storageBucket:kStorageBucket
  211. deepLinkURLScheme:kDeepLinkURLScheme];
  212. FIROptions *copyCustomizedOptions = [customizedOptions copy];
  213. [copyCustomizedOptions setDeepLinkURLScheme:kNewDeepLinkURLScheme];
  214. XCTAssertEqualObjects(customizedOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  215. XCTAssertEqualObjects(copyCustomizedOptions.deepLinkURLScheme, kNewDeepLinkURLScheme);
  216. }
  217. - (void)testAnalyticsConstants {
  218. // The keys are public values and should never change.
  219. XCTAssertEqualObjects(kFIRIsMeasurementEnabled, @"IS_MEASUREMENT_ENABLED");
  220. XCTAssertEqualObjects(kFIRIsAnalyticsCollectionEnabled, @"FIREBASE_ANALYTICS_COLLECTION_ENABLED");
  221. XCTAssertEqualObjects(kFIRIsAnalyticsCollectionDeactivated,
  222. @"FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED");
  223. }
  224. - (void)testAnalyticsOptions {
  225. id mainBundleMock = OCMPartialMock([NSBundle mainBundle]);
  226. // No keys anywhere.
  227. NSDictionary *optionsDictionary = nil;
  228. FIROptions *options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  229. NSDictionary *mainDictionary = nil;
  230. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  231. NSDictionary *expectedAnalyticsOptions = @{};
  232. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  233. optionsDictionary = @{};
  234. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  235. mainDictionary = @{};
  236. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  237. expectedAnalyticsOptions = @{};
  238. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  239. // Main has no keys.
  240. optionsDictionary = @{
  241. kFIRIsAnalyticsCollectionDeactivated : @YES,
  242. kFIRIsAnalyticsCollectionEnabled : @YES,
  243. kFIRIsMeasurementEnabled : @YES
  244. };
  245. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  246. mainDictionary = @{};
  247. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  248. expectedAnalyticsOptions = optionsDictionary;
  249. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  250. // Main overrides all the keys.
  251. optionsDictionary = @{
  252. kFIRIsAnalyticsCollectionDeactivated : @YES,
  253. kFIRIsAnalyticsCollectionEnabled : @YES,
  254. kFIRIsMeasurementEnabled : @YES
  255. };
  256. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  257. mainDictionary = @{
  258. kFIRIsAnalyticsCollectionDeactivated : @NO,
  259. kFIRIsAnalyticsCollectionEnabled : @NO,
  260. kFIRIsMeasurementEnabled : @NO
  261. };
  262. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  263. expectedAnalyticsOptions = mainDictionary;
  264. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  265. // Keys exist only in main.
  266. optionsDictionary = @{};
  267. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  268. mainDictionary = @{
  269. kFIRIsAnalyticsCollectionDeactivated : @YES,
  270. kFIRIsAnalyticsCollectionEnabled : @YES,
  271. kFIRIsMeasurementEnabled : @YES
  272. };
  273. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  274. expectedAnalyticsOptions = mainDictionary;
  275. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  276. // Main overrides single keys.
  277. optionsDictionary = @{
  278. kFIRIsAnalyticsCollectionDeactivated : @YES,
  279. kFIRIsAnalyticsCollectionEnabled : @YES,
  280. kFIRIsMeasurementEnabled : @YES
  281. };
  282. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  283. mainDictionary = @{ kFIRIsAnalyticsCollectionDeactivated : @NO };
  284. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  285. expectedAnalyticsOptions = @{
  286. kFIRIsAnalyticsCollectionDeactivated : @NO, // override
  287. kFIRIsAnalyticsCollectionEnabled : @YES,
  288. kFIRIsMeasurementEnabled : @YES
  289. };
  290. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  291. optionsDictionary = @{
  292. kFIRIsAnalyticsCollectionDeactivated : @YES,
  293. kFIRIsAnalyticsCollectionEnabled : @YES,
  294. kFIRIsMeasurementEnabled : @YES
  295. };
  296. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  297. mainDictionary = @{ kFIRIsAnalyticsCollectionEnabled : @NO };
  298. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  299. expectedAnalyticsOptions = @{
  300. kFIRIsAnalyticsCollectionDeactivated : @YES,
  301. kFIRIsAnalyticsCollectionEnabled : @NO, // override
  302. kFIRIsMeasurementEnabled : @YES
  303. };
  304. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  305. optionsDictionary = @{
  306. kFIRIsAnalyticsCollectionDeactivated : @YES,
  307. kFIRIsAnalyticsCollectionEnabled : @YES,
  308. kFIRIsMeasurementEnabled : @YES
  309. };
  310. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  311. mainDictionary = @{ kFIRIsMeasurementEnabled : @NO };
  312. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  313. expectedAnalyticsOptions = @{
  314. kFIRIsAnalyticsCollectionDeactivated : @YES,
  315. kFIRIsAnalyticsCollectionEnabled : @YES,
  316. kFIRIsMeasurementEnabled : @NO // override
  317. };
  318. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  319. }
  320. - (void)testAnalyticsOptions_combinatorial {
  321. // Complete combinatorial test.
  322. id mainBundleMock = OCMPartialMock([NSBundle mainBundle]);
  323. // Possible values for the flags in the plist, where NSNull means the flag is not present.
  324. NSArray *values = @[ [NSNull null], @NO, @YES ];
  325. // Sanity checks for the combination generation.
  326. int combinationCount = 0;
  327. NSMutableArray *uniqueMainCombinations = [[NSMutableArray alloc] init];
  328. NSMutableArray *uniqueOptionsCombinations = [[NSMutableArray alloc] init];
  329. // Generate all optout flag combinations for { main plist X GoogleService-info options plist }.
  330. // Options present in the main plist should override options of the same key in the service plist.
  331. for (id mainDeactivated in values) {
  332. for (id mainAnalyticsEnabled in values) {
  333. for (id mainMeasurementEnabled in values) {
  334. for (id optionsDeactivated in values) {
  335. for (id optionsAnalyticsEnabled in values) {
  336. for (id optionsMeasurementEnabled in values) {
  337. @autoreleasepool {
  338. // Fill the GoogleService-info options plist dictionary.
  339. NSMutableDictionary *optionsDictionary = [[NSMutableDictionary alloc] init];
  340. if (![optionsDeactivated isEqual:[NSNull null]]) {
  341. optionsDictionary[kFIRIsAnalyticsCollectionDeactivated] = optionsDeactivated;
  342. }
  343. if (![optionsAnalyticsEnabled isEqual:[NSNull null]]) {
  344. optionsDictionary[kFIRIsAnalyticsCollectionEnabled] = optionsAnalyticsEnabled;
  345. }
  346. if (![optionsMeasurementEnabled isEqual:[NSNull null]]) {
  347. optionsDictionary[kFIRIsMeasurementEnabled] = optionsMeasurementEnabled;
  348. }
  349. FIROptions *options =
  350. [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  351. if (![uniqueOptionsCombinations containsObject:optionsDictionary]) {
  352. [uniqueOptionsCombinations addObject:optionsDictionary];
  353. }
  354. // Fill the main plist dictionary.
  355. NSMutableDictionary *mainDictionary = [[NSMutableDictionary alloc] init];
  356. if (![mainDeactivated isEqual:[NSNull null]]) {
  357. mainDictionary[kFIRIsAnalyticsCollectionDeactivated] = mainDeactivated;
  358. }
  359. if (![mainAnalyticsEnabled isEqual:[NSNull null]]) {
  360. mainDictionary[kFIRIsAnalyticsCollectionEnabled] = mainAnalyticsEnabled;
  361. }
  362. if (![mainMeasurementEnabled isEqual:[NSNull null]]) {
  363. mainDictionary[kFIRIsMeasurementEnabled] = mainMeasurementEnabled;
  364. }
  365. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  366. if (![uniqueMainCombinations containsObject:mainDictionary]) {
  367. [uniqueMainCombinations addObject:mainDictionary];
  368. }
  369. // Generate the expected options by adding main values on top of the service options
  370. // values. The main values will replace any existing options values with the same
  371. // key. This is a different way of combining the two sets of flags from the actual
  372. // implementation in FIROptions, with equivalent output.
  373. NSMutableDictionary *expectedAnalyticsOptions =
  374. [[NSMutableDictionary alloc] initWithDictionary:optionsDictionary];
  375. [expectedAnalyticsOptions addEntriesFromDictionary:mainDictionary];
  376. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  377. combinationCount++;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. }
  384. }
  385. // Verify the sanity checks.
  386. XCTAssertEqual(combinationCount, 729); // = 3^6.
  387. XCTAssertEqual(uniqueOptionsCombinations.count, 27);
  388. int optionsSizeCount[4] = {0};
  389. for (NSDictionary *dictionary in uniqueOptionsCombinations) {
  390. optionsSizeCount[dictionary.count]++;
  391. }
  392. XCTAssertEqual(optionsSizeCount[0], 1);
  393. XCTAssertEqual(optionsSizeCount[1], 6);
  394. XCTAssertEqual(optionsSizeCount[2], 12);
  395. XCTAssertEqual(optionsSizeCount[3], 8);
  396. XCTAssertEqual(uniqueMainCombinations.count, 27);
  397. int mainSizeCount[4] = {0};
  398. for (NSDictionary *dictionary in uniqueMainCombinations) {
  399. mainSizeCount[dictionary.count]++;
  400. }
  401. XCTAssertEqual(mainSizeCount[0], 1);
  402. XCTAssertEqual(mainSizeCount[1], 6);
  403. XCTAssertEqual(mainSizeCount[2], 12);
  404. XCTAssertEqual(mainSizeCount[3], 8);
  405. }
  406. - (void)testVersionFormat {
  407. NSRegularExpression *sLibraryVersionRegex =
  408. [NSRegularExpression regularExpressionWithPattern:@"^[0-9]{8,}$" options:0 error:NULL];
  409. NSUInteger numberOfMatches =
  410. [sLibraryVersionRegex numberOfMatchesInString:kFIRLibraryVersionID
  411. options:0
  412. range:NSMakeRange(0, kFIRLibraryVersionID.length)];
  413. XCTAssertEqual(numberOfMatches, 1, @"Incorrect library version format.");
  414. }
  415. @end