FABURLBuilderTests.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 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 "Crashlytics/Shared/FIRCLSNetworking/FIRCLSURLBuilder.h"
  15. #import <Foundation/Foundation.h>
  16. #import <XCTest/XCTest.h>
  17. @interface FIRCLSURLBuilder (Testing)
  18. - (NSString *)escapeString:(NSString *)string;
  19. @end
  20. @interface FABURLBuilderTests : XCTestCase
  21. @end
  22. @implementation FABURLBuilderTests
  23. - (void)setUp {
  24. [super setUp];
  25. }
  26. - (void)tearDown {
  27. [super tearDown];
  28. }
  29. - (void)testTheRightUrlEncodingIsUsed {
  30. NSString *actual =
  31. @"https://settings.crashlytics.com/spi/v2/platforms/ios/apps/"
  32. @"com.dogs.testingappforfunandprofit/"
  33. @"settings?icon_hash=277530e7595e8ff02a163905942a24dd14747fcb&display_version=1.0 "
  34. @"#1234&source=1&instance=d8b2e102647d9cbdc67a650d23bcefd445874a2c&build_version=1";
  35. NSString *expected =
  36. @"https://settings.crashlytics.com/spi/v2/platforms/ios/apps/"
  37. @"com.dogs.testingappforfunandprofit/"
  38. @"settings?icon_hash=277530e7595e8ff02a163905942a24dd14747fcb&display_version=1.0%20%231234&"
  39. @"source=1&instance=d8b2e102647d9cbdc67a650d23bcefd445874a2c&build_version=1";
  40. FIRCLSURLBuilder *urlBuilder = [FIRCLSURLBuilder new];
  41. NSString *encoded = [urlBuilder escapeString:actual];
  42. XCTAssertEqualObjects(encoded, expected);
  43. }
  44. @end