Files
purchases-ios/Tests/UnitTests/FoundationExtensions/StringExtensionsTests.swift
T
NachoSoto 7ca28477f4 Fixed ROT13.string thread-safety (#1686)
Fixes #1685.

### Description

Swift's `lazy` and `static` property initialization is always thread-safe. However, `key` was only created as an empty dictionary, and the evaluation of `ROT13.string`, which was the one initializing that data, wasn't isolated.
By creating `ROT13.key` inline, this ensures that the initialization is only done once in a thread-safe way.
2022-06-10 11:31:04 -07:00

31 lines
788 B
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// StringExtensionsTests.swift
//
// Created by Nacho Soto on 6/10/22.
import Foundation
import Nimble
import XCTest
@testable import RevenueCat
class StringExtensionsTests: TestCase {
func testROT13() {
let mangledTrackingClassName = "NGGenpxvatZnantre"
let mangledAuthStatusPropertyName = "genpxvatNhgubevmngvbaFgnghf"
expect(mangledTrackingClassName.rot13()) == "ATTrackingManager"
expect(mangledAuthStatusPropertyName.rot13()) == "trackingAuthorizationStatus"
}
}