FBXMLSafeStringTests.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <XCTest/XCTest.h>
  10. #import "NSString+FBXMLSafeString.h"
  11. @interface FBXMLSafeStringTests : XCTestCase
  12. @end
  13. @implementation FBXMLSafeStringTests
  14. - (void)testSafeXmlStringTransformationWithEmptyReplacement {
  15. NSString *withInvalidChar = [NSString stringWithFormat:@"bla%@", @"\uFFFF"];
  16. NSString *withoutInvalidChar = @"bla";
  17. XCTAssertNotEqualObjects(withInvalidChar, withoutInvalidChar);
  18. XCTAssertEqualObjects([withInvalidChar fb_xmlSafeStringWithReplacement:@""], withoutInvalidChar);
  19. }
  20. - (void)testSafeXmlStringTransformationWithNonEmptyReplacement {
  21. NSString *withInvalidChar = [NSString stringWithFormat:@"bla%@", @"\uFFFF"];
  22. XCTAssertEqualObjects([withInvalidChar fb_xmlSafeStringWithReplacement:@"1"], @"bla1");
  23. }
  24. - (void)testSafeXmlStringTransformationWithSmileys {
  25. NSString *validString = @"Yo👿";
  26. XCTAssertEqualObjects([validString fb_xmlSafeStringWithReplacement:@""], validString);
  27. }
  28. @end