UIColor+FIRIAMHexStringTests.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <XCTest/XCTest.h>
  17. #import "FirebaseInAppMessaging/Sources/Util/UIColor+FIRIAMHexString.h"
  18. @interface UIColor_FIRIAMHexStringTests : XCTestCase
  19. @end
  20. @implementation UIColor_FIRIAMHexStringTests
  21. - (void)setUp {
  22. [super setUp];
  23. // Put setup code here. This method is called before the invocation of each test method in the
  24. // class.
  25. }
  26. - (void)tearDown {
  27. // Put teardown code here. This method is called after the invocation of each test method in the
  28. // class.
  29. [super tearDown];
  30. }
  31. - (void)testNilHexString {
  32. UIColor *color = [UIColor firiam_colorWithHexString:nil];
  33. XCTAssertNil(color);
  34. }
  35. - (void)testEmptyHexString {
  36. UIColor *color = [UIColor firiam_colorWithHexString:@""];
  37. XCTAssertNil(color);
  38. }
  39. - (void)testInvalidHexString {
  40. UIColor *color = [UIColor firiam_colorWithHexString:@"#sssfsss"];
  41. XCTAssertNil(color);
  42. }
  43. - (void)testValidHexString {
  44. UIColor *color = [UIColor firiam_colorWithHexString:@"#00FFEE"];
  45. XCTAssertNotNil(color);
  46. }
  47. @end