Skip to content

Commit

Permalink
fix test for multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
miyashi committed Mar 21, 2020
1 parent 3e64bc5 commit fe4f34d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,26 @@ class MultilineFormatterTests: XCTestCase {
let fields: [(String, String)] = [
("name", #""pochi""#),
("owner", """
Owner(name: "Nanachi",
age: 4)
Owner(
name: "Nanachi",
age: 4
)
"""),
]

let expected =
"""
Dog(
name: "pochi",
owner: Owner(
name: "Nanachi",
age: 4
)
)
"""

formatter = MultilineFormatter(option: option(indent: 2))
assertEqualLines(formatter.objectString(typeName: "Dog", fields: fields),
"""
Dog(name: "pochi",
owner: Owner(name: "Nanachi",
age: 4))
""")
assertEqualLines(formatter.objectString(typeName: "Dog", fields: fields), expected)
}

// MARK: - Helper
Expand Down
120 changes: 70 additions & 50 deletions Tests/SwiftPrettyPrintTests/Public/DebugTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,47 @@ class DebugTests: XCTestCase {
Debug.prettyPrint(dog, to: &result)
assertEqualLines(result,
"""
Dog(id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/)
Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
)
""" + "\n")

result = ""
Debug.debugPrettyPrint(dog, to: &result)
assertEqualLines(result,
"""
Dog(id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/))
Dog(
id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)
)
""" + "\n")

result = ""
Debug.prettyPrint([dog, dog], to: &result)
assertEqualLines(result,
"""
[
Dog(id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/),
Dog(id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/)
Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
),
Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
)
]
""" + "\n")

Expand All @@ -137,16 +145,20 @@ class DebugTests: XCTestCase {
assertEqualLines(result,
"""
[
Dog(id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)),
Dog(id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/))
Dog(
id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)
),
Dog(
id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)
)
]
""" + "\n")

Expand All @@ -160,16 +172,20 @@ class DebugTests: XCTestCase {
assertEqualLines(result,
"""
[
"dog-1": Dog(id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/),
"dog-2": Dog(id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/)
"dog-1": Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
),
"dog-2": Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
)
]
""" + "\n")

Expand All @@ -178,16 +194,20 @@ class DebugTests: XCTestCase {
assertEqualLines(result,
"""
[
"dog-1": Dog(id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)),
"dog-2": Dog(id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/))
"dog-1": Dog(
id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)
),
"dog-2": Dog(
id: DogId(rawValue: "pochi"),
name: Optional("ポチ"),
nickname: nil,
age: 3,
homepage: Optional(https://www.google.com/)
)
]
""" + "\n")
}
Expand Down

0 comments on commit fe4f34d

Please sign in to comment.