FIROptionsTest.m 21 KB

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