@testable import PureYAML import Testing @Suite("Double-quoted scalar folding") struct DoubleQuotedFoldingTests { @Test("A multi-line double-quoted scalar folds breaks, blank lines, and adjacent whitespace") func test_doubleQuotedLineFolding() throws { // First-line leading and last-line trailing whitespace are kept (next to a quote, not a // break); a single break folds to a space; a blank line folds to one newline; leading // whitespace on continuation lines and trailing whitespace before a break are stripped. let parsed = try PureYAML.parse("\" 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty \"") #expect(parsed == .string(" 1st non-empty\n2nd non-empty 3rd non-empty ")) } @Test("An escaped newline stays literal while real breaks fold to a space") func test_doubleQuotedEscapeVersusBreak() throws { // A real line break between the two lines folds to a space; the trailing `\n` escape // decodes to a literal newline. let parsed = try PureYAML.parse("\"So does this\n quoted scalar.\\n\"") #expect(parsed == .string("So does this quoted scalar.\n")) } @Test("A single-line double-quoted scalar is unchanged") func test_doubleQuotedSingleLine() throws { #expect(try PureYAML.parse("\"hello world\"") == .string("hello world")) } }