Migrate tests from XCTest to Swift Testing
- Convert XCTestCase classes to structs with @Test functions - Replace XCTAssert* with #expect, and force unwraps/XCTFail with #require - Resolve test bundle via a class token in the CLI smoke test (Swift Testing does not register the .xctest bundle in Bundle.allBundles) - Rename adaptForXCTest() to adaptForTest()
This commit is contained in:
24 files changed
+437
-374
No files matched your search
@@ -6,15 +6,16 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class AnalyticsDefinitionTests: XCTestCase {
|
||||
struct AnalyticsDefinitionTests {
|
||||
|
||||
// MARK: - Matching tags
|
||||
|
||||
func testMatchingAnalyticss() {
|
||||
@Test
|
||||
func matchingAnalyticss() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "", type: .screen)
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -26,12 +27,13 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
|
||||
|
||||
// Expect
|
||||
XCTAssertTrue(match1)
|
||||
XCTAssertTrue(match2)
|
||||
XCTAssertTrue(match3)
|
||||
#expect(match1)
|
||||
#expect(match2)
|
||||
#expect(match3)
|
||||
}
|
||||
|
||||
func testNotMatchingAnalyticss() {
|
||||
@Test
|
||||
func notMatchingAnalyticss() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "", type: .screen)
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -42,14 +44,15 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
let match3 = definition.hasOneOrMoreMatchingTags(inputTags: ["azerty"])
|
||||
|
||||
// Expect
|
||||
XCTAssertFalse(match1)
|
||||
XCTAssertFalse(match2)
|
||||
XCTAssertFalse(match3)
|
||||
#expect(match1 == false)
|
||||
#expect(match2 == false)
|
||||
#expect(match3 == false)
|
||||
}
|
||||
|
||||
// MARK: - Raw properties
|
||||
|
||||
func testGeneratedRawPropertyScreen() {
|
||||
@Test
|
||||
func generatedRawPropertyScreen() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .screen)
|
||||
definition.path = "ecran_un/"
|
||||
@@ -68,10 +71,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyScreen.adaptForXCTest(), expectScreen.adaptForXCTest())
|
||||
#expect(propertyScreen.adaptForTest() == expectScreen.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawPropertyEvent() {
|
||||
@Test
|
||||
func generatedRawPropertyEvent() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
|
||||
|
||||
@@ -90,10 +94,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyEvent.adaptForXCTest(), expectEvent.adaptForXCTest())
|
||||
#expect(propertyEvent.adaptForTest() == expectEvent.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawStaticPropertyScreen() {
|
||||
@Test
|
||||
func generatedRawStaticPropertyScreen() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .screen)
|
||||
definition.path = "ecran_un/"
|
||||
@@ -112,10 +117,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyScreen.adaptForXCTest(), expectScreen.adaptForXCTest())
|
||||
#expect(propertyScreen.adaptForTest() == expectScreen.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawStaticPropertyEvent() {
|
||||
@Test
|
||||
func generatedRawStaticPropertyEvent() {
|
||||
// Given
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
|
||||
|
||||
@@ -134,6 +140,6 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyEvent.adaptForXCTest(), expectEvent.adaptForXCTest())
|
||||
#expect(propertyEvent.adaptForTest() == expectEvent.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@
|
||||
// CPD-OFF
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class AnalyticsGeneratorTests: XCTestCase {
|
||||
struct AnalyticsGeneratorTests {
|
||||
|
||||
private func getAnalyticsDefinition(
|
||||
id: String,
|
||||
@@ -208,7 +208,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
"""
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentFirebase() {
|
||||
@Test
|
||||
func generatedExtensionContentFirebase() {
|
||||
// Given
|
||||
let sectionOne = AnalyticsCategory(id: "section_one")
|
||||
sectionOne.definitions = [
|
||||
@@ -420,10 +421,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentMatomo() {
|
||||
@Test
|
||||
func generatedExtensionContentMatomo() {
|
||||
// Given
|
||||
let sectionOne = AnalyticsCategory(id: "section_one")
|
||||
sectionOne.definitions = [
|
||||
@@ -637,10 +639,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentMatomoAndFirebase() {
|
||||
@Test
|
||||
func generatedExtensionContentMatomoAndFirebase() {
|
||||
// Given
|
||||
let sectionOne = AnalyticsCategory(id: "section_one")
|
||||
sectionOne.definitions = [
|
||||
@@ -860,7 +863,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class AnalyticsSectionTests: XCTestCase {
|
||||
struct AnalyticsSectionTests {
|
||||
|
||||
// MARK: - Matching tags
|
||||
|
||||
func testMatchingAnalytics() {
|
||||
@Test
|
||||
func matchingAnalytics() {
|
||||
// Given
|
||||
let section = AnalyticsCategory(id: "section_name")
|
||||
section.definitions = [
|
||||
@@ -37,13 +38,14 @@ final class AnalyticsSectionTests: XCTestCase {
|
||||
let match4 = section.hasOneOrMoreMatchingTags(tags: ["droidonly"])
|
||||
|
||||
// Expect
|
||||
XCTAssertTrue(match1)
|
||||
XCTAssertTrue(match2)
|
||||
XCTAssertTrue(match3)
|
||||
XCTAssertTrue(match4)
|
||||
#expect(match1)
|
||||
#expect(match2)
|
||||
#expect(match3)
|
||||
#expect(match4)
|
||||
}
|
||||
|
||||
func testNotMatchingAnalytics() {
|
||||
@Test
|
||||
func notMatchingAnalytics() {
|
||||
// Given
|
||||
let section = AnalyticsCategory(id: "section_name")
|
||||
section.definitions = [
|
||||
@@ -65,8 +67,8 @@ final class AnalyticsSectionTests: XCTestCase {
|
||||
let match3 = section.hasOneOrMoreMatchingTags(tags: ["azerty"])
|
||||
|
||||
// Expect
|
||||
XCTAssertFalse(match1)
|
||||
XCTAssertFalse(match2)
|
||||
XCTAssertFalse(match3)
|
||||
#expect(match1 == false)
|
||||
#expect(match2 == false)
|
||||
#expect(match3 == false)
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,15 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
struct ColorExtensionGeneratorTests {
|
||||
|
||||
func test_uiKit_GeneratedExtensionContent() {
|
||||
@Test
|
||||
func uiKit_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -50,10 +51,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
@Test
|
||||
func uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -90,10 +92,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContent() {
|
||||
@Test
|
||||
func swiftUI_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -130,10 +133,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
@Test
|
||||
func swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -170,6 +174,6 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ColorFileParserTests: XCTestCase {
|
||||
func testCorrectFormat_lightStyle() throws {
|
||||
struct ColorFileParserTests {
|
||||
@Test
|
||||
func correctFormat_lightStyle() throws {
|
||||
// Given
|
||||
let inputWithEqualSeparator = """
|
||||
red1 = #FF0000
|
||||
@@ -60,16 +61,17 @@ final class ColorFileParserTests: XCTestCase {
|
||||
let testValues = colorsValues.first { $0.name == parsedColor.name }
|
||||
if let testValues = testValues {
|
||||
foundColors += 1
|
||||
XCTAssertEqual(parsedColor.name, testValues.name)
|
||||
XCTAssertEqual(parsedColor.light, testValues.light)
|
||||
XCTAssertEqual(parsedColor.dark, testValues.dark)
|
||||
#expect(parsedColor.name == testValues.name)
|
||||
#expect(parsedColor.light == testValues.light)
|
||||
#expect(parsedColor.dark == testValues.dark)
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(foundColors, 12)
|
||||
#expect(foundColors == 12)
|
||||
}
|
||||
|
||||
func testCorrectFormat_allColorStyle() throws {
|
||||
@Test
|
||||
func correctFormat_allColorStyle() throws {
|
||||
// Given
|
||||
let input = """
|
||||
lightOnly #FF0000
|
||||
@@ -82,17 +84,15 @@ final class ColorFileParserTests: XCTestCase {
|
||||
colorStyle: .all)
|
||||
|
||||
// Expect
|
||||
let colorRed1 = parsedColors.first { $0.name == "lightOnly" }
|
||||
let colorRed2 = parsedColors.first { $0.name == "lightDark" }
|
||||
let colorRed1 = try #require(parsedColors.first { $0.name == "lightOnly" })
|
||||
let colorRed2 = try #require(parsedColors.first { $0.name == "lightDark" })
|
||||
|
||||
XCTAssertNotNil(colorRed1)
|
||||
XCTAssertEqual(colorRed1?.name, "lightOnly")
|
||||
XCTAssertEqual(colorRed1?.light, "#FF0000")
|
||||
XCTAssertEqual(colorRed1?.dark, "#FF0000")
|
||||
#expect(colorRed1.name == "lightOnly")
|
||||
#expect(colorRed1.light == "#FF0000")
|
||||
#expect(colorRed1.dark == "#FF0000")
|
||||
|
||||
XCTAssertNotNil(colorRed2)
|
||||
XCTAssertEqual(colorRed2?.name, "lightDark")
|
||||
XCTAssertEqual(colorRed2?.light, "#FF0000")
|
||||
XCTAssertEqual(colorRed2?.dark, "#0000FF")
|
||||
#expect(colorRed2.name == "lightDark")
|
||||
#expect(colorRed2.light == "#FF0000")
|
||||
#expect(colorRed2.dark == "#0000FF")
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,14 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ParsedColorTests: XCTestCase {
|
||||
struct ParsedColorTests {
|
||||
|
||||
func test_uiKit_GeneratedProperty() {
|
||||
@Test
|
||||
func uiKit_GeneratedProperty() {
|
||||
// Given
|
||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||
|
||||
@@ -32,10 +33,11 @@ final class ParsedColorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedStaticProperty() {
|
||||
@Test
|
||||
func uiKit_GeneratedStaticProperty() {
|
||||
// Given
|
||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||
|
||||
@@ -55,10 +57,11 @@ final class ParsedColorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedProperty() {
|
||||
@Test
|
||||
func swiftUI_GeneratedProperty() {
|
||||
// Given
|
||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||
|
||||
@@ -78,10 +81,11 @@ final class ParsedColorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedStaticProperty() {
|
||||
@Test
|
||||
func swiftUI_GeneratedStaticProperty() {
|
||||
// Given
|
||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||
|
||||
@@ -101,46 +105,40 @@ final class ParsedColorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedColorAsset() {
|
||||
@Test
|
||||
func generatedColorAsset() throws {
|
||||
// Given
|
||||
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
|
||||
|
||||
|
||||
// When
|
||||
let contentJson = color.contentsJSON()
|
||||
guard let data = contentJson.data(using: .utf8),
|
||||
let parsedJson = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
|
||||
XCTFail("Cannot convert `contentJSON` string to Data")
|
||||
return
|
||||
}
|
||||
|
||||
let colors = parsedJson["colors"] as! [Any]
|
||||
|
||||
let data = try #require(contentJson.data(using: .utf8), "Cannot convert `contentJSON` string to Data")
|
||||
let parsedJson = try #require(try JSONSerialization.jsonObject(with: data) as? [String: Any])
|
||||
|
||||
let colors = try #require(parsedJson["colors"] as? [Any])
|
||||
|
||||
for color in colors {
|
||||
guard let color = color as? [String: Any] else {
|
||||
XCTFail("Cannot convert color object to Dictonnary")
|
||||
return
|
||||
}
|
||||
let color = try #require(color as? [String: Any], "Cannot convert color object to Dictionary")
|
||||
let subColor = try #require(color["color"] as? [String: Any])
|
||||
let components = try #require(subColor["components"] as? [String: Any])
|
||||
|
||||
if let appearance = color["appearances"] as? [Any] {
|
||||
// Appearance is define only for dark appearance
|
||||
let firstAppearance = appearance.first! as! [String: Any]
|
||||
XCTAssertEqual(firstAppearance["value"] as! String, "dark")
|
||||
|
||||
let subColor = color["color"] as! [String: Any]
|
||||
let components = subColor["components"] as! [String: Any]
|
||||
XCTAssertEqual(components["alpha"] as! String, "0xFF")
|
||||
XCTAssertEqual(components["blue"] as! String, "0xFF")
|
||||
XCTAssertEqual(components["green"] as! String, "0x00")
|
||||
XCTAssertEqual(components["red"] as! String, "0x00")
|
||||
let firstAppearance = try #require(appearance.first as? [String: Any])
|
||||
#expect(firstAppearance["value"] as? String == "dark")
|
||||
|
||||
#expect(components["alpha"] as? String == "0xFF")
|
||||
#expect(components["blue"] as? String == "0xFF")
|
||||
#expect(components["green"] as? String == "0x00")
|
||||
#expect(components["red"] as? String == "0x00")
|
||||
} else {
|
||||
let subColor = color["color"] as! [String: Any]
|
||||
let components = subColor["components"] as! [String: Any]
|
||||
XCTAssertEqual(components["alpha"] as! String, "0xFF")
|
||||
XCTAssertEqual(components["blue"] as! String, "0x00")
|
||||
XCTAssertEqual(components["green"] as! String, "0x00")
|
||||
XCTAssertEqual(components["red"] as! String, "0xFF")
|
||||
#expect(components["alpha"] as? String == "0xFF")
|
||||
#expect(components["blue"] as? String == "0x00")
|
||||
#expect(components["green"] as? String == "0x00")
|
||||
#expect(components["red"] as? String == "0xFF")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
extension String {
|
||||
|
||||
/// Remove all new lines and leading/trailing whitespaces
|
||||
func adaptForXCTest() -> Self {
|
||||
func adaptForTest() -> Self {
|
||||
self
|
||||
.split(separator: "\n")
|
||||
.compactMap { String($0).removeLeadingTrailingWhitespace() }
|
||||
|
||||
@@ -6,14 +6,15 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class FontExtensionGeneratorTests: XCTestCase {
|
||||
struct FontExtensionGeneratorTests {
|
||||
|
||||
func test_uiKit_GeneratedExtensionContent() {
|
||||
@Test
|
||||
func uiKit_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let fontNames: [FontName] = [
|
||||
FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
|
||||
@@ -55,11 +56,14 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContent() {
|
||||
@Test
|
||||
|
||||
|
||||
func swiftUI_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let fontNames: [FontName] = [
|
||||
FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
|
||||
@@ -101,6 +105,6 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,14 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class FontNameTests: XCTestCase {
|
||||
struct FontNameTests {
|
||||
|
||||
func test_uiKit_GeneratedProperty_noForbiddenCharacter() {
|
||||
@Test
|
||||
func uiKit_GeneratedProperty_noForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "CircularStdBold",
|
||||
@@ -34,10 +35,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedProperty_withForbiddenCharacter() {
|
||||
@Test
|
||||
func uiKit_GeneratedProperty_withForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "[Circular_Std+Bold-Underline]",
|
||||
@@ -59,10 +61,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedMethod_noForbiddenCharacter() {
|
||||
@Test
|
||||
func uiKit_GeneratedMethod_noForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "CircularStdBold",
|
||||
@@ -84,10 +87,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedMethod_withForbiddenCharacter() {
|
||||
@Test
|
||||
func uiKit_GeneratedMethod_withForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "[Circular_Std+Bold-Underline]",
|
||||
@@ -109,10 +113,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedProperty_noForbiddenCharacter() {
|
||||
@Test
|
||||
func swiftUI_GeneratedProperty_noForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "CircularStdBold",
|
||||
@@ -134,10 +139,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedProperty_withForbiddenCharacter() {
|
||||
@Test
|
||||
func swiftUI_GeneratedProperty_withForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "[Circular_Std+Bold-Underline]",
|
||||
@@ -159,10 +165,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedMethod_noForbiddenCharacter() {
|
||||
@Test
|
||||
func swiftUI_GeneratedMethod_noForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "CircularStdBold",
|
||||
@@ -184,10 +191,11 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedMethod_withForbiddenCharacter() {
|
||||
@Test
|
||||
func swiftUI_GeneratedMethod_withForbiddenCharacter() {
|
||||
// Given
|
||||
let fontName = FontName(
|
||||
postscriptName: "[Circular_Std+Bold-Underline]",
|
||||
@@ -209,6 +217,6 @@ final class FontNameTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class FontPlistGeneratorTests: XCTestCase {
|
||||
func testGeneratedPlist() {
|
||||
struct FontPlistGeneratorTests {
|
||||
@Test
|
||||
func generatedPlist() {
|
||||
// Given
|
||||
let fontNames: [FontName] = [
|
||||
FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
|
||||
@@ -30,6 +31,6 @@ final class FontPlistGeneratorTests: XCTestCase {
|
||||
</array>
|
||||
"""
|
||||
|
||||
XCTAssertEqual(plistContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(plistContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
final class AnalyticsConfigurationTests: XCTestCase {
|
||||
struct AnalyticsConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = AnalyticsConfiguration(
|
||||
inputFile: "path/to/tags.yml",
|
||||
@@ -39,10 +40,11 @@ final class AnalyticsConfigurationTests: XCTestCase {
|
||||
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = AnalyticsConfiguration(
|
||||
inputFile: "path/to/tags.yml",
|
||||
@@ -75,6 +77,6 @@ final class AnalyticsConfigurationTests: XCTestCase {
|
||||
"mySuffix"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,16 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ColorsConfigurationTests: XCTestCase {
|
||||
struct ColorsConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = ColorsConfiguration(
|
||||
inputFile: "path/to/colors.txt",
|
||||
@@ -45,10 +46,11 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
"false"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = ColorsConfiguration(
|
||||
inputFile: "path/to/colors.txt",
|
||||
@@ -92,6 +94,6 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
"false"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,16 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class FontsConfigurationTests: XCTestCase {
|
||||
struct FontsConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = FontsConfiguration(
|
||||
inputFile: "path/to/fonts.txt",
|
||||
@@ -37,10 +38,11 @@ final class FontsConfigurationTests: XCTestCase {
|
||||
"projectDirectory/path/to/fonts.txt"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = FontsConfiguration(
|
||||
inputFile: "path/to/fonts.txt",
|
||||
@@ -78,6 +80,6 @@ final class FontsConfigurationTests: XCTestCase {
|
||||
"projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,16 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ImagesConfigurationTests: XCTestCase {
|
||||
struct ImagesConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = ImagesConfiguration(
|
||||
inputFile: "path/to/images.txt",
|
||||
@@ -41,10 +42,11 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
"projectDirectory/path/to/assets.xcassets"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = ImagesConfiguration(
|
||||
inputFile: "path/to/images.txt",
|
||||
@@ -86,7 +88,7 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
final class StringsConfigurationTests: XCTestCase {
|
||||
struct StringsConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = StringsConfiguration(
|
||||
inputFile: "path/to/strings.txt",
|
||||
@@ -46,10 +47,11 @@ final class StringsConfigurationTests: XCTestCase {
|
||||
"en"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = StringsConfiguration(
|
||||
inputFile: "path/to/strings.txt",
|
||||
@@ -97,6 +99,6 @@ final class StringsConfigurationTests: XCTestCase {
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
final class TagsConfigurationTests: XCTestCase {
|
||||
struct TagsConfigurationTests {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
@Test
|
||||
func argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = TagsConfiguration(
|
||||
inputFile: "path/to/tags.txt",
|
||||
@@ -40,10 +41,11 @@ final class TagsConfigurationTests: XCTestCase {
|
||||
"projectDirectory/Tags/Generated"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
@Test
|
||||
func argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = TagsConfiguration(
|
||||
inputFile: "path/to/tags.txt",
|
||||
@@ -79,6 +81,6 @@ final class TagsConfigurationTests: XCTestCase {
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
#expect(arguments == expectedArguments)
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,15 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
struct ImageExtensionGeneratorTests {
|
||||
|
||||
func test_uiKit_GeneratedExtensionContent() {
|
||||
@Test
|
||||
func uiKit_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -50,10 +51,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
@Test
|
||||
func uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -90,10 +92,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContent() {
|
||||
@Test
|
||||
func swiftUI_GeneratedExtensionContent() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -130,10 +133,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
@Test
|
||||
func swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -170,6 +174,6 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
class ImageFileParserTests: XCTestCase {
|
||||
func testParseImagesFile() {
|
||||
struct ImageFileParserTests {
|
||||
@Test
|
||||
func parseImagesFile() throws {
|
||||
// Given
|
||||
let input = """
|
||||
#
|
||||
@@ -29,24 +30,24 @@ class ImageFileParserTests: XCTestCase {
|
||||
platform: PlatormTag.ios)
|
||||
|
||||
// Expect
|
||||
XCTAssertEqual(parsedImages.count, 2)
|
||||
#expect(parsedImages.count == 2)
|
||||
|
||||
let firstImage = parsedImages.first {
|
||||
let firstImage = try #require(parsedImages.first {
|
||||
$0.name == "image_one"
|
||||
}
|
||||
XCTAssertEqual(firstImage!.name, "image_one")
|
||||
XCTAssertEqual(firstImage!.tags, "id")
|
||||
XCTAssertEqual(firstImage!.width, 25)
|
||||
XCTAssertEqual(firstImage!.height, -1)
|
||||
XCTAssertEqual(firstImage!.imageExtensions, [.png])
|
||||
})
|
||||
#expect(firstImage.name == "image_one")
|
||||
#expect(firstImage.tags == "id")
|
||||
#expect(firstImage.width == 25)
|
||||
#expect(firstImage.height == -1)
|
||||
#expect(firstImage.imageExtensions == [.png])
|
||||
|
||||
let secondImage = parsedImages.first {
|
||||
let secondImage = try #require(parsedImages.first {
|
||||
$0.name == "image_two"
|
||||
}
|
||||
XCTAssertEqual(secondImage!.name, "image_two")
|
||||
XCTAssertEqual(secondImage!.tags, "di")
|
||||
XCTAssertEqual(secondImage!.width, -1)
|
||||
XCTAssertEqual(secondImage!.height, 50)
|
||||
XCTAssertEqual(firstImage!.imageExtensions, [.png])
|
||||
})
|
||||
#expect(secondImage.name == "image_two")
|
||||
#expect(secondImage.tags == "di")
|
||||
#expect(secondImage.width == -1)
|
||||
#expect(secondImage.height == 50)
|
||||
#expect(firstImage.imageExtensions == [.png])
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,14 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ParsedImageTests: XCTestCase {
|
||||
struct ParsedImageTests {
|
||||
|
||||
func testConvertArguments() {
|
||||
@Test
|
||||
func convertArguments() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(name: imageName,
|
||||
@@ -24,17 +25,18 @@ final class ParsedImageTests: XCTestCase {
|
||||
let convertArguments = parsedImage.convertArguments
|
||||
|
||||
// Expect
|
||||
XCTAssertEqual(convertArguments.x1.width, "10")
|
||||
XCTAssertEqual(convertArguments.x1.height, "10")
|
||||
#expect(convertArguments.x1.width == "10")
|
||||
#expect(convertArguments.x1.height == "10")
|
||||
|
||||
XCTAssertEqual(convertArguments.x2.width, "20")
|
||||
XCTAssertEqual(convertArguments.x2.height, "20")
|
||||
#expect(convertArguments.x2.width == "20")
|
||||
#expect(convertArguments.x2.height == "20")
|
||||
|
||||
XCTAssertEqual(convertArguments.x3.width, "30")
|
||||
XCTAssertEqual(convertArguments.x3.height, "30")
|
||||
#expect(convertArguments.x3.width == "30")
|
||||
#expect(convertArguments.x3.height == "30")
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedProperty() {
|
||||
@Test
|
||||
func uiKit_GeneratedProperty() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(
|
||||
@@ -59,10 +61,11 @@ final class ParsedImageTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedStaticProperty() {
|
||||
@Test
|
||||
func uiKit_GeneratedStaticProperty() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(
|
||||
@@ -87,10 +90,11 @@ final class ParsedImageTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedProperty() {
|
||||
@Test
|
||||
func swiftUI_GeneratedProperty() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(
|
||||
@@ -115,10 +119,11 @@ final class ParsedImageTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedStaticProperty() {
|
||||
@Test
|
||||
func swiftUI_GeneratedStaticProperty() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(
|
||||
@@ -143,10 +148,11 @@ final class ParsedImageTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(property.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testAssetContentJson() {
|
||||
@Test
|
||||
func assetContentJson() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(
|
||||
@@ -184,10 +190,11 @@ final class ParsedImageTests: XCTestCase {
|
||||
)
|
||||
)
|
||||
|
||||
XCTAssertEqual(property, expect)
|
||||
#expect(property == expect)
|
||||
}
|
||||
|
||||
func testAssetPng() {
|
||||
@Test
|
||||
func assetPng() {
|
||||
// Given
|
||||
let imageName = "the_name"
|
||||
let parsedImage = ParsedImage(name: imageName,
|
||||
@@ -228,6 +235,6 @@ final class ParsedImageTests: XCTestCase {
|
||||
debugPrint(property)
|
||||
debugPrint(expect)
|
||||
|
||||
XCTAssertEqual(property, expect)
|
||||
#expect(property == expect)
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,17 @@
|
||||
import XCTest
|
||||
import class Foundation.Bundle
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class ResgenCLITests: XCTestCase {
|
||||
func testExample() throws {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||
// results.
|
||||
|
||||
// Some of the APIs that we use below are available in macOS 10.13 and above.
|
||||
guard #available(macOS 10.13, *) else {
|
||||
return
|
||||
}
|
||||
struct ResgenCLITests {
|
||||
|
||||
/// Smoke test: the built executable launches and exits.
|
||||
@Test
|
||||
func executableRuns() throws {
|
||||
// Process available on Mac only
|
||||
#if os(macOS)
|
||||
let fooBinary = productsDirectory.appendingPathComponent("ResgenSwift")
|
||||
|
||||
let process = Process()
|
||||
process.executableURL = fooBinary
|
||||
process.executableURL = try productsDirectory().appendingPathComponent("ResgenSwift")
|
||||
|
||||
let pipe = Pipe()
|
||||
process.standardOutput = pipe
|
||||
@@ -28,21 +20,22 @@ final class ResgenCLITests: XCTestCase {
|
||||
process.waitUntilExit()
|
||||
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let output = String(data: data, encoding: .utf8)
|
||||
|
||||
XCTAssertEqual(output, output)//"Hello, world!\n")
|
||||
#expect(String(data: data, encoding: .utf8) != nil)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns path to the built products directory.
|
||||
var productsDirectory: URL {
|
||||
#if os(macOS)
|
||||
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
|
||||
return bundle.bundleURL.deletingLastPathComponent()
|
||||
}
|
||||
fatalError("couldn't find the products directory")
|
||||
#else
|
||||
private func productsDirectory() throws -> URL {
|
||||
#if os(macOS)
|
||||
// Swift Testing does not register the test bundle in `Bundle.allBundles`,
|
||||
// so resolve it from a class compiled into this test target.
|
||||
let bundle = Bundle(for: BundleToken.self)
|
||||
try #require(bundle.bundlePath.hasSuffix(".xctest"))
|
||||
return bundle.bundleURL.deletingLastPathComponent()
|
||||
#else
|
||||
return Bundle.main.bundleURL
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private final class BundleToken {}
|
||||
@@ -10,25 +10,26 @@
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import ToolCore
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
final class DefinitionTests: XCTestCase {
|
||||
struct DefinitionTests {
|
||||
|
||||
// MARK: - Match line
|
||||
|
||||
func testMatchingDefinition() {
|
||||
@Test
|
||||
func matchingDefinition() throws {
|
||||
// Given
|
||||
let line = "[definition_name]"
|
||||
|
||||
// When
|
||||
let definition = Definition.match(line)
|
||||
let definition = try #require(Definition.match(line))
|
||||
|
||||
// Expect
|
||||
XCTAssertNotNil(definition)
|
||||
XCTAssertEqual(definition?.name, "definition_name")
|
||||
#expect(definition.name == "definition_name")
|
||||
}
|
||||
|
||||
func testNotMatchingDefinition() {
|
||||
@Test
|
||||
func notMatchingDefinition() {
|
||||
// Given
|
||||
let line1 = "definition_name"
|
||||
let line2 = "[definition_name"
|
||||
@@ -40,14 +41,15 @@ final class DefinitionTests: XCTestCase {
|
||||
let definition3 = Definition.match(line3)
|
||||
|
||||
// Expect
|
||||
XCTAssertNil(definition1)
|
||||
XCTAssertNil(definition2)
|
||||
XCTAssertNil(definition3)
|
||||
#expect(definition1 == nil)
|
||||
#expect(definition2 == nil)
|
||||
#expect(definition3 == nil)
|
||||
}
|
||||
|
||||
// MARK: - Matching tags
|
||||
|
||||
func testMatchingTags() {
|
||||
@Test
|
||||
func matchingTags() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -59,12 +61,13 @@ final class DefinitionTests: XCTestCase {
|
||||
|
||||
|
||||
// Expect
|
||||
XCTAssertTrue(match1)
|
||||
XCTAssertTrue(match2)
|
||||
XCTAssertTrue(match3)
|
||||
#expect(match1)
|
||||
#expect(match2)
|
||||
#expect(match3)
|
||||
}
|
||||
|
||||
func testNotMatchingTags() {
|
||||
@Test
|
||||
func notMatchingTags() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -75,14 +78,15 @@ final class DefinitionTests: XCTestCase {
|
||||
let match3 = definition.hasOneOrMoreMatchingTags(inputTags: ["azerty"])
|
||||
|
||||
// Expect
|
||||
XCTAssertFalse(match1)
|
||||
XCTAssertFalse(match2)
|
||||
XCTAssertFalse(match3)
|
||||
#expect(match1 == false)
|
||||
#expect(match2 == false)
|
||||
#expect(match3 == false)
|
||||
}
|
||||
|
||||
// MARK: - getNSLocalizedStringProperty
|
||||
|
||||
func testGeneratedNSLocalizedStringProperty() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringProperty() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -147,12 +151,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringPropertyWithEmptyComment() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringPropertyWithEmptyComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -217,12 +222,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringPropertyWithNoComment() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringPropertyWithNoComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -286,14 +292,15 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
// MARK: - getNSLocalizedStringProperty - static
|
||||
|
||||
func testGeneratedNSLocalizedStringStaticProperty() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringStaticProperty() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -358,12 +365,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringStaticPropertyWithEmptyComment() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringStaticPropertyWithEmptyComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -428,12 +436,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringStaticPropertyWithNoComment() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringStaticPropertyWithNoComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -497,12 +506,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringPropertyWithOneArgument() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringPropertyWithOneArgument() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -540,10 +550,11 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringPropertyWithMultipleArgument() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringPropertyWithMultipleArgument() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -581,10 +592,11 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedNSLocalizedStringPropertyWithNumberedArguments() {
|
||||
@Test
|
||||
func generatedNSLocalizedStringPropertyWithNumberedArguments() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -648,13 +660,14 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
}
|
||||
|
||||
// MARK: - Raw properties
|
||||
|
||||
func testGeneratedRawProperty() {
|
||||
@Test
|
||||
func generatedRawProperty() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -716,12 +729,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawPropertyWithEmptyComment() {
|
||||
@Test
|
||||
func generatedRawPropertyWithEmptyComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -783,12 +797,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawPropertyWithNoComment() {
|
||||
@Test
|
||||
func generatedRawPropertyWithNoComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -849,14 +864,15 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
// MARK: - Raw static properties
|
||||
|
||||
func testGeneratedRawStaticProperty() {
|
||||
@Test
|
||||
func generatedRawStaticProperty() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -918,12 +934,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawStaticPropertyWithEmptyComment() {
|
||||
@Test
|
||||
func generatedRawStaticPropertyWithEmptyComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -985,12 +1002,13 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedRawStaticPropertyWithNoComment() {
|
||||
@Test
|
||||
func generatedRawStaticPropertyWithNoComment() {
|
||||
// Given
|
||||
let definition = Definition(name: "definition_name")
|
||||
definition.tags = ["ios","iosonly","notranslation"]
|
||||
@@ -1051,9 +1069,9 @@ final class DefinitionTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
#expect(propertyFr.adaptForTest() == expectFr.adaptForTest())
|
||||
#expect(propertyEn.adaptForTest() == expectEn.adaptForTest())
|
||||
#expect(propertyEnUs.adaptForTest() == expectEnUs.adaptForTest())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,27 +6,28 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class SectionTests: XCTestCase {
|
||||
struct SectionTests {
|
||||
|
||||
// MARK: - Match line
|
||||
|
||||
func testMatchingDefinition() {
|
||||
@Test
|
||||
func matchingDefinition() throws {
|
||||
// Given
|
||||
let line = "[[section_name]]"
|
||||
|
||||
// When
|
||||
let section = Section.match(line)
|
||||
let section = try #require(Section.match(line))
|
||||
|
||||
// Expect
|
||||
XCTAssertNotNil(section)
|
||||
XCTAssertEqual(section?.name, "section_name")
|
||||
#expect(section.name == "section_name")
|
||||
}
|
||||
|
||||
func testNotMatchingDefinition() {
|
||||
@Test
|
||||
func notMatchingDefinition() {
|
||||
// Given
|
||||
let lines = ["section_name",
|
||||
"[section_name]",
|
||||
@@ -41,12 +42,13 @@ final class SectionTests: XCTestCase {
|
||||
let matches = lines.compactMap { Section.match($0) }
|
||||
|
||||
// Expect
|
||||
XCTAssertEqual(matches.isEmpty, true)
|
||||
#expect(matches.isEmpty == true)
|
||||
}
|
||||
|
||||
// MARK: - Matching tags
|
||||
|
||||
func testMatchingTags() {
|
||||
@Test
|
||||
func matchingTags() {
|
||||
// Given
|
||||
let section = Section(name: "section_name")
|
||||
section.definitions = [
|
||||
@@ -69,13 +71,14 @@ final class SectionTests: XCTestCase {
|
||||
let match4 = section.hasOneOrMoreMatchingTags(tags: ["droidonly"])
|
||||
|
||||
// Expect
|
||||
XCTAssertTrue(match1)
|
||||
XCTAssertTrue(match2)
|
||||
XCTAssertTrue(match3)
|
||||
XCTAssertTrue(match4)
|
||||
#expect(match1)
|
||||
#expect(match2)
|
||||
#expect(match3)
|
||||
#expect(match4)
|
||||
}
|
||||
|
||||
func testNotMatchingTags() {
|
||||
@Test
|
||||
func notMatchingTags() {
|
||||
// Given
|
||||
let section = Section(name: "section_name")
|
||||
section.definitions = [
|
||||
@@ -97,8 +100,8 @@ final class SectionTests: XCTestCase {
|
||||
let match3 = section.hasOneOrMoreMatchingTags(tags: ["azerty"])
|
||||
|
||||
// Expect
|
||||
XCTAssertFalse(match1)
|
||||
XCTAssertFalse(match2)
|
||||
XCTAssertFalse(match3)
|
||||
#expect(match1 == false)
|
||||
#expect(match2 == false)
|
||||
#expect(match3 == false)
|
||||
}
|
||||
}
|
||||
+34
-36
@@ -6,16 +6,17 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class StringsFileGeneratorTests: XCTestCase {
|
||||
struct StringsFileGeneratorTests {
|
||||
|
||||
// MARK: - Strings File Content
|
||||
|
||||
func testGenerateStringsFileContent() {
|
||||
@Test
|
||||
func generateStringsFileContent() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne()
|
||||
let sectionTwo = Section.Mock.getSectionTwo()
|
||||
@@ -36,17 +37,12 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
// CPD-ON
|
||||
|
||||
// Expect
|
||||
XCTAssertEqual(
|
||||
stringsFileContentFr.adaptForXCTest(),
|
||||
Self.appleStringsFileExpectationFr.adaptForXCTest()
|
||||
)
|
||||
XCTAssertEqual(
|
||||
stringsFileContentEn.adaptForXCTest(),
|
||||
Self.appleStringsFileExpectationEn.adaptForXCTest()
|
||||
)
|
||||
#expect(stringsFileContentFr.adaptForTest() == Self.appleStringsFileExpectationFr.adaptForTest())
|
||||
#expect(stringsFileContentEn.adaptForTest() == Self.appleStringsFileExpectationEn.adaptForTest())
|
||||
}
|
||||
|
||||
func testGenerateStringsFileContentWithComment() {
|
||||
@Test
|
||||
func generateStringsFileContentWithComment() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneComment: "This is a comment",
|
||||
@@ -73,19 +69,14 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
// CPD-ON
|
||||
|
||||
// Expect
|
||||
XCTAssertEqual(
|
||||
stringsFileContentFr.adaptForXCTest(),
|
||||
Self.appleStringsFileExpectationFr.adaptForXCTest()
|
||||
)
|
||||
XCTAssertEqual(
|
||||
stringsFileContentEn.adaptForXCTest(),
|
||||
Self.appleStringsFileExpectationEn.adaptForXCTest()
|
||||
)
|
||||
#expect(stringsFileContentFr.adaptForTest() == Self.appleStringsFileExpectationFr.adaptForTest())
|
||||
#expect(stringsFileContentEn.adaptForTest() == Self.appleStringsFileExpectationEn.adaptForTest())
|
||||
}
|
||||
|
||||
// MARK: - XcString File Content
|
||||
|
||||
func testGenerateXcStringsRootObject() {
|
||||
@Test
|
||||
func generateXcStringsRootObject() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne()
|
||||
let sectionTwo = Section.Mock.getSectionTwo(
|
||||
@@ -223,10 +214,11 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
version: "1.0"
|
||||
)
|
||||
|
||||
XCTAssertEqual(rootObject, expect)
|
||||
#expect(rootObject == expect)
|
||||
}
|
||||
|
||||
func testGenerateXcStringsRootObjectWithEmptyTranslations() {
|
||||
@Test
|
||||
func generateXcStringsRootObjectWithEmptyTranslations() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneFr: "",
|
||||
@@ -273,10 +265,11 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
version: "1.0"
|
||||
)
|
||||
|
||||
XCTAssertEqual(rootObject, expect)
|
||||
#expect(rootObject == expect)
|
||||
}
|
||||
|
||||
func testGenerateXcStringsRootObjectWithNoTranslations() {
|
||||
@Test
|
||||
func generateXcStringsRootObjectWithNoTranslations() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneFr: "",
|
||||
@@ -323,10 +316,11 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
version: "1.0"
|
||||
)
|
||||
|
||||
XCTAssertEqual(rootObject, expect)
|
||||
#expect(rootObject == expect)
|
||||
}
|
||||
|
||||
func testGenerateXcStringsRootObjectWithComments() {
|
||||
@Test
|
||||
func generateXcStringsRootObjectWithComments() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneComment: "Comment 1",
|
||||
@@ -362,12 +356,13 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
version: "1.0"
|
||||
)
|
||||
|
||||
XCTAssertEqual(rootObject, expect)
|
||||
#expect(rootObject == expect)
|
||||
}
|
||||
|
||||
// MARK: - Extension Content
|
||||
|
||||
func testGeneratedExtensionContent() {
|
||||
@Test
|
||||
func generatedExtensionContent() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne()
|
||||
let sectionTwo = Section.Mock.getSectionTwo()
|
||||
@@ -393,10 +388,11 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentWithComment() {
|
||||
@Test
|
||||
func generatedExtensionContentWithComment() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneComment: "This is a comment",
|
||||
@@ -433,11 +429,12 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
// MARK: - Extension Content Static
|
||||
func testGeneratedExtensionContentWithIsStatic() {
|
||||
@Test
|
||||
func generatedExtensionContentWithIsStatic() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne()
|
||||
let sectionTwo = Section.Mock.getSectionTwo()
|
||||
@@ -465,10 +462,11 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentWithIsStaticWithComment() {
|
||||
@Test
|
||||
func generatedExtensionContentWithIsStaticWithComment() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneComment: "This is a comment",
|
||||
@@ -506,7 +504,7 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
if extensionContent != expect {
|
||||
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||
}
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Testing
|
||||
import ToolCore
|
||||
|
||||
@testable import ResgenSwift
|
||||
|
||||
final class TagsGeneratorTests: XCTestCase {
|
||||
struct TagsGeneratorTests {
|
||||
|
||||
private func getDefinition(
|
||||
name: String,
|
||||
@@ -24,7 +24,8 @@ final class TagsGeneratorTests: XCTestCase {
|
||||
return definition
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContent() {
|
||||
@Test
|
||||
func generatedExtensionContent() {
|
||||
// Given
|
||||
let sectionOne = Section(name: "section_one")
|
||||
sectionOne.definitions = [
|
||||
@@ -94,6 +95,6 @@ final class TagsGeneratorTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user