-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option for encoding scalars with newlines to Emitter.Options (#…
…406)
- Loading branch information
1 parent
0d523df
commit 029b612
Showing
4 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,27 @@ class EncoderTests: XCTestCase { // swiftlint:disable:this type_body_length | |
_testRoundTrip(of: OptionalTopLevelWrapper(url), expectedYAML: expectedYAML) | ||
} | ||
|
||
func testNewlinesInString() throws { | ||
let expectedYamlLiteral = """ | ||
name: |- | ||
This name | ||
Has new lines | ||
email: [email protected] | ||
""" | ||
let expectedYamlFolded = """ | ||
name: >- | ||
This name | ||
Has new lines | ||
email: [email protected] | ||
""" | ||
let person = Person(name: "This name\nHas new lines", email: "[email protected]") | ||
_testRoundTrip(of: person, with: .init(newLineScalarStyle: .literal), expectedYAML: expectedYamlLiteral) | ||
_testRoundTrip(of: person, with: .init(newLineScalarStyle: .folded), expectedYAML: expectedYamlFolded) | ||
} | ||
|
||
func testNumberInString() throws { | ||
_testDecode(of: String.self, from: "'10'", expectedValue: "10") | ||
_testDecode(of: String.self, from: "'10.5'", expectedValue: "10.5") | ||
|