FIROptionsTest.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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 "FIRAppInternal.h"
  15. #import "FIRBundleUtil.h"
  16. #import "FIROptionsInternal.h"
  17. #import "FIRTestCase.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 =
  35. [[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. FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  68. bundleID:kBundleID
  69. GCMSenderID:kGCMSenderID
  70. APIKey:kAPIKey
  71. clientID:kClientID
  72. trackingID:kTrackingID
  73. androidClientID:kAndroidClientID
  74. databaseURL:kDatabaseURL
  75. storageBucket:kStorageBucket
  76. deepLinkURLScheme:kDeepLinkURLScheme];
  77. [self assertOptionsMatchDefaults:options andProjectID:NO];
  78. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  79. XCTAssertFalse(options.usingOptionsFromDefaultPlist);
  80. FIROptions *options2 = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  81. GCMSenderID:kGCMSenderID];
  82. options2.androidClientID = kAndroidClientID;
  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. XCTAssertThrows([[FIROptions alloc] initWithGoogleAppID:nil
  96. bundleID:kBundleID
  97. GCMSenderID:kGCMSenderID
  98. APIKey:kCustomizedAPIKey
  99. clientID:nil
  100. trackingID:nil
  101. androidClientID:nil
  102. databaseURL:nil
  103. storageBucket:nil
  104. deepLinkURLScheme:nil]);
  105. }
  106. - (void)testinitWithContentsOfFile {
  107. NSString *filePath =
  108. [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
  109. FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
  110. [self assertOptionsMatchDefaults:options andProjectID:YES];
  111. XCTAssertNil(options.deepLinkURLScheme);
  112. XCTAssertFalse(options.usingOptionsFromDefaultPlist);
  113. FIROptions *emptyOptions = [[FIROptions alloc] initWithContentsOfFile:nil];
  114. XCTAssertNil(emptyOptions);
  115. FIROptions *invalidOptions = [[FIROptions alloc] initWithContentsOfFile:@"invalid.plist"];
  116. XCTAssertNil(invalidOptions);
  117. }
  118. - (void)assertOptionsMatchDefaults:(FIROptions *)options andProjectID:(BOOL)matchProjectID {
  119. XCTAssertEqualObjects(options.googleAppID, kGoogleAppID);
  120. XCTAssertEqualObjects(options.APIKey, kAPIKey);
  121. XCTAssertEqualObjects(options.clientID, kClientID);
  122. XCTAssertEqualObjects(options.trackingID, kTrackingID);
  123. XCTAssertEqualObjects(options.GCMSenderID, kGCMSenderID);
  124. XCTAssertEqualObjects(options.androidClientID, kAndroidClientID);
  125. XCTAssertEqualObjects(options.libraryVersionID, kFIRLibraryVersionID);
  126. XCTAssertEqualObjects(options.databaseURL, kDatabaseURL);
  127. XCTAssertEqualObjects(options.storageBucket, kStorageBucket);
  128. XCTAssertEqualObjects(options.bundleID, kBundleID);
  129. // Custom `matchProjectID` parameter to be removed once the deprecated `FIROptions` constructor is
  130. // removed.
  131. if (matchProjectID) {
  132. XCTAssertEqualObjects(options.projectID, kProjectID);
  133. }
  134. }
  135. - (void)testCopyingProperties {
  136. NSMutableString *mutableString;
  137. FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  138. GCMSenderID:kGCMSenderID];
  139. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  140. options.APIKey = mutableString;
  141. [mutableString appendString:@"2"];
  142. XCTAssertEqualObjects(options.APIKey, @"1");
  143. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  144. options.bundleID = mutableString;
  145. [mutableString appendString:@"2"];
  146. XCTAssertEqualObjects(options.bundleID, @"1");
  147. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  148. options.clientID = mutableString;
  149. [mutableString appendString:@"2"];
  150. XCTAssertEqualObjects(options.clientID, @"1");
  151. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  152. options.trackingID = mutableString;
  153. [mutableString appendString:@"2"];
  154. XCTAssertEqualObjects(options.trackingID, @"1");
  155. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  156. options.GCMSenderID = mutableString;
  157. [mutableString appendString:@"2"];
  158. XCTAssertEqualObjects(options.GCMSenderID, @"1");
  159. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  160. options.projectID = mutableString;
  161. [mutableString appendString:@"2"];
  162. XCTAssertEqualObjects(options.projectID, @"1");
  163. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  164. options.androidClientID = mutableString;
  165. [mutableString appendString:@"2"];
  166. XCTAssertEqualObjects(options.androidClientID, @"1");
  167. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  168. options.googleAppID = mutableString;
  169. [mutableString appendString:@"2"];
  170. XCTAssertEqualObjects(options.googleAppID, @"1");
  171. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  172. options.databaseURL = mutableString;
  173. [mutableString appendString:@"2"];
  174. XCTAssertEqualObjects(options.databaseURL, @"1");
  175. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  176. options.deepLinkURLScheme = mutableString;
  177. [mutableString appendString:@"2"];
  178. XCTAssertEqualObjects(options.deepLinkURLScheme, @"1");
  179. mutableString = [[NSMutableString alloc] initWithString:@"1"];
  180. options.storageBucket = mutableString;
  181. [mutableString appendString:@"2"];
  182. XCTAssertEqualObjects(options.storageBucket, @"1");
  183. }
  184. - (void)testCopyWithZone {
  185. // default options
  186. FIROptions *options = [FIROptions defaultOptions];
  187. options.deepLinkURLScheme = kDeepLinkURLScheme;
  188. XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme);
  189. FIROptions *newOptions = [options copy];
  190. XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  191. [options setDeepLinkURLScheme:kNewDeepLinkURLScheme];
  192. XCTAssertEqualObjects(options.deepLinkURLScheme, kNewDeepLinkURLScheme);
  193. XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  194. // customized options
  195. FIROptions *customizedOptions = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
  196. bundleID:kBundleID
  197. GCMSenderID:kGCMSenderID
  198. APIKey:kAPIKey
  199. clientID:kClientID
  200. trackingID:kTrackingID
  201. androidClientID:kAndroidClientID
  202. databaseURL:kDatabaseURL
  203. storageBucket:kStorageBucket
  204. deepLinkURLScheme:kDeepLinkURLScheme];
  205. FIROptions *copyCustomizedOptions = [customizedOptions copy];
  206. [copyCustomizedOptions setDeepLinkURLScheme:kNewDeepLinkURLScheme];
  207. XCTAssertEqualObjects(customizedOptions.deepLinkURLScheme, kDeepLinkURLScheme);
  208. XCTAssertEqualObjects(copyCustomizedOptions.deepLinkURLScheme, kNewDeepLinkURLScheme);
  209. }
  210. - (void)testAnalyticsConstants {
  211. // The keys are public values and should never change.
  212. XCTAssertEqualObjects(kFIRIsMeasurementEnabled, @"IS_MEASUREMENT_ENABLED");
  213. XCTAssertEqualObjects(kFIRIsAnalyticsCollectionEnabled, @"FIREBASE_ANALYTICS_COLLECTION_ENABLED");
  214. XCTAssertEqualObjects(kFIRIsAnalyticsCollectionDeactivated,
  215. @"FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED");
  216. }
  217. - (void)testAnalyticsOptions {
  218. id mainBundleMock = OCMPartialMock([NSBundle mainBundle]);
  219. // No keys anywhere.
  220. NSDictionary *optionsDictionary = nil;
  221. FIROptions *options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  222. NSDictionary *mainDictionary = nil;
  223. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  224. NSDictionary *expectedAnalyticsOptions = @{};
  225. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  226. optionsDictionary = @{};
  227. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  228. mainDictionary = @{};
  229. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  230. expectedAnalyticsOptions = @{};
  231. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  232. // Main has no keys.
  233. optionsDictionary = @{
  234. kFIRIsAnalyticsCollectionDeactivated : @YES,
  235. kFIRIsAnalyticsCollectionEnabled : @YES,
  236. kFIRIsMeasurementEnabled : @YES
  237. };
  238. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  239. mainDictionary = @{};
  240. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  241. expectedAnalyticsOptions = optionsDictionary;
  242. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  243. // Main overrides all the keys.
  244. optionsDictionary = @{
  245. kFIRIsAnalyticsCollectionDeactivated : @YES,
  246. kFIRIsAnalyticsCollectionEnabled : @YES,
  247. kFIRIsMeasurementEnabled : @YES
  248. };
  249. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  250. mainDictionary = @{
  251. kFIRIsAnalyticsCollectionDeactivated : @NO,
  252. kFIRIsAnalyticsCollectionEnabled : @NO,
  253. kFIRIsMeasurementEnabled : @NO
  254. };
  255. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  256. expectedAnalyticsOptions = mainDictionary;
  257. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  258. // Keys exist only in main.
  259. optionsDictionary = @{};
  260. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  261. mainDictionary = @{
  262. kFIRIsAnalyticsCollectionDeactivated : @YES,
  263. kFIRIsAnalyticsCollectionEnabled : @YES,
  264. kFIRIsMeasurementEnabled : @YES
  265. };
  266. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  267. expectedAnalyticsOptions = mainDictionary;
  268. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  269. // Main overrides single keys.
  270. optionsDictionary = @{
  271. kFIRIsAnalyticsCollectionDeactivated : @YES,
  272. kFIRIsAnalyticsCollectionEnabled : @YES,
  273. kFIRIsMeasurementEnabled : @YES
  274. };
  275. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  276. mainDictionary = @{ kFIRIsAnalyticsCollectionDeactivated : @NO };
  277. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  278. expectedAnalyticsOptions = @{
  279. kFIRIsAnalyticsCollectionDeactivated : @NO, // override
  280. kFIRIsAnalyticsCollectionEnabled : @YES,
  281. kFIRIsMeasurementEnabled : @YES
  282. };
  283. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  284. optionsDictionary = @{
  285. kFIRIsAnalyticsCollectionDeactivated : @YES,
  286. kFIRIsAnalyticsCollectionEnabled : @YES,
  287. kFIRIsMeasurementEnabled : @YES
  288. };
  289. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  290. mainDictionary = @{ kFIRIsAnalyticsCollectionEnabled : @NO };
  291. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  292. expectedAnalyticsOptions = @{
  293. kFIRIsAnalyticsCollectionDeactivated : @YES,
  294. kFIRIsAnalyticsCollectionEnabled : @NO, // override
  295. kFIRIsMeasurementEnabled : @YES
  296. };
  297. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  298. optionsDictionary = @{
  299. kFIRIsAnalyticsCollectionDeactivated : @YES,
  300. kFIRIsAnalyticsCollectionEnabled : @YES,
  301. kFIRIsMeasurementEnabled : @YES
  302. };
  303. options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  304. mainDictionary = @{ kFIRIsMeasurementEnabled : @NO };
  305. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  306. expectedAnalyticsOptions = @{
  307. kFIRIsAnalyticsCollectionDeactivated : @YES,
  308. kFIRIsAnalyticsCollectionEnabled : @YES,
  309. kFIRIsMeasurementEnabled : @NO // override
  310. };
  311. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  312. }
  313. - (void)testAnalyticsOptions_combinatorial {
  314. // Complete combinatorial test.
  315. id mainBundleMock = OCMPartialMock([NSBundle mainBundle]);
  316. // Possible values for the flags in the plist, where NSNull means the flag is not present.
  317. NSArray *values = @[ [NSNull null], @NO, @YES ];
  318. // Sanity checks for the combination generation.
  319. int combinationCount = 0;
  320. NSMutableArray *uniqueMainCombinations = [[NSMutableArray alloc] init];
  321. NSMutableArray *uniqueOptionsCombinations = [[NSMutableArray alloc] init];
  322. // Generate all optout flag combinations for { main plist X GoogleService-info options plist }.
  323. // Options present in the main plist should override options of the same key in the service plist.
  324. for (id mainDeactivated in values) {
  325. for (id mainAnalyticsEnabled in values) {
  326. for (id mainMeasurementEnabled in values) {
  327. for (id optionsDeactivated in values) {
  328. for (id optionsAnalyticsEnabled in values) {
  329. for (id optionsMeasurementEnabled in values) {
  330. @autoreleasepool {
  331. // Fill the GoogleService-info options plist dictionary.
  332. NSMutableDictionary *optionsDictionary = [[NSMutableDictionary alloc] init];
  333. if (![optionsDeactivated isEqual:[NSNull null]]) {
  334. optionsDictionary[kFIRIsAnalyticsCollectionDeactivated] = optionsDeactivated;
  335. }
  336. if (![optionsAnalyticsEnabled isEqual:[NSNull null]]) {
  337. optionsDictionary[kFIRIsAnalyticsCollectionEnabled] = optionsAnalyticsEnabled;
  338. }
  339. if (![optionsMeasurementEnabled isEqual:[NSNull null]]) {
  340. optionsDictionary[kFIRIsMeasurementEnabled] = optionsMeasurementEnabled;
  341. }
  342. FIROptions *options =
  343. [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary];
  344. if (![uniqueOptionsCombinations containsObject:optionsDictionary]) {
  345. [uniqueOptionsCombinations addObject:optionsDictionary];
  346. }
  347. // Fill the main plist dictionary.
  348. NSMutableDictionary *mainDictionary = [[NSMutableDictionary alloc] init];
  349. if (![mainDeactivated isEqual:[NSNull null]]) {
  350. mainDictionary[kFIRIsAnalyticsCollectionDeactivated] = mainDeactivated;
  351. }
  352. if (![mainAnalyticsEnabled isEqual:[NSNull null]]) {
  353. mainDictionary[kFIRIsAnalyticsCollectionEnabled] = mainAnalyticsEnabled;
  354. }
  355. if (![mainMeasurementEnabled isEqual:[NSNull null]]) {
  356. mainDictionary[kFIRIsMeasurementEnabled] = mainMeasurementEnabled;
  357. }
  358. OCMExpect([mainBundleMock infoDictionary]).andReturn(mainDictionary);
  359. if (![uniqueMainCombinations containsObject:mainDictionary]) {
  360. [uniqueMainCombinations addObject:mainDictionary];
  361. }
  362. // Generate the expected options by adding main values on top of the service options
  363. // values. The main values will replace any existing options values with the same
  364. // key. This is a different way of combining the two sets of flags from the actual
  365. // implementation in FIROptions, with equivalent output.
  366. NSMutableDictionary *expectedAnalyticsOptions =
  367. [[NSMutableDictionary alloc] initWithDictionary:optionsDictionary];
  368. [expectedAnalyticsOptions addEntriesFromDictionary:mainDictionary];
  369. XCTAssertEqualObjects(options.analyticsOptionsDictionary, expectedAnalyticsOptions);
  370. combinationCount++;
  371. }
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. // Verify the sanity checks.
  379. XCTAssertEqual(combinationCount, 729); // = 3^6.
  380. XCTAssertEqual(uniqueOptionsCombinations.count, 27);
  381. int optionsSizeCount[4] = {0};
  382. for (NSDictionary *dictionary in uniqueOptionsCombinations) {
  383. optionsSizeCount[dictionary.count]++;
  384. }
  385. XCTAssertEqual(optionsSizeCount[0], 1);
  386. XCTAssertEqual(optionsSizeCount[1], 6);
  387. XCTAssertEqual(optionsSizeCount[2], 12);
  388. XCTAssertEqual(optionsSizeCount[3], 8);
  389. XCTAssertEqual(uniqueMainCombinations.count, 27);
  390. int mainSizeCount[4] = {0};
  391. for (NSDictionary *dictionary in uniqueMainCombinations) {
  392. mainSizeCount[dictionary.count]++;
  393. }
  394. XCTAssertEqual(mainSizeCount[0], 1);
  395. XCTAssertEqual(mainSizeCount[1], 6);
  396. XCTAssertEqual(mainSizeCount[2], 12);
  397. XCTAssertEqual(mainSizeCount[3], 8);
  398. }
  399. - (void)testVersionFormat {
  400. NSRegularExpression *sLibraryVersionRegex =
  401. [NSRegularExpression regularExpressionWithPattern:@"^[0-9]{8,}$" options:0 error:NULL];
  402. NSUInteger numberOfMatches =
  403. [sLibraryVersionRegex numberOfMatchesInString:kFIRLibraryVersionID
  404. options:0
  405. range:NSMakeRange(0, kFIRLibraryVersionID.length)];
  406. XCTAssertEqual(numberOfMatches, 1, @"Incorrect library version format.");
  407. }
  408. @end