diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-10-15 11:07:41 +0200 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-10-15 11:07:41 +0200 |
| commit | 9ce5b3b6d52368b9333a9d5f98c3cd2b1a3cb038 (patch) | |
| tree | 3a1a492fc8ef4b5a7220f8558374cdd1dbd57ccb /Tests | |
| parent | b1d16ce115571840bf69a5483f86d407623ec358 (diff) | |
| download | bar-9ce5b3b6d52368b9333a9d5f98c3cd2b1a3cb038.tar.gz bar-9ce5b3b6d52368b9333a9d5f98c3cd2b1a3cb038.zip | |
add tests
Diffstat (limited to 'Tests')
| -rw-r--r-- | Tests/barTests/phbarTests.swift | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Tests/barTests/phbarTests.swift b/Tests/barTests/phbarTests.swift index 982e728..3c44482 100644 --- a/Tests/barTests/phbarTests.swift +++ b/Tests/barTests/phbarTests.swift @@ -51,3 +51,31 @@ private func runCommand(_ command: String, env: [String: String] = [:]) throws - let result = try runCommand("printf ' %s \\n\\nlast\\n' \"$BAR_RUNNER_TEST\"; test -n \"$PATH\"", env: ["BAR_RUNNER_TEST": "value"]) #expect(result.lines == [" value ", "", "last"]) } + +@Test func parsingEmptyOutputProducesNoCells() { + #expect(Runner.parse("") == []) +} + +@Test func parsingRemovesOneFinalNewline() { + #expect(Runner.parse("cell\n") == ["cell"]) + #expect(Runner.parse("cell") == ["cell"]) +} + +@Test func parsingPreservesInternalBlankLines() { + #expect(Runner.parse("first\n\n\nlast\n") == ["first", "", "", "last"]) + #expect(Runner.parse("\nfirst") == ["", "first"]) +} + +@Test func parsingPreservesAdditionalTrailingBlankLines() { + #expect(Runner.parse("cell\n\n\n") == ["cell", "", ""]) + #expect(Runner.parse("\n") == [""]) + #expect(Runner.parse("\n\n") == ["", ""]) +} + +@Test func parsingPreservesLineOrder() { + #expect(Runner.parse("third\nfirst\nsecond\n") == ["third", "first", "second"]) +} + +@Test func parsingDoesNotTrimWhitespace() { + #expect(Runner.parse(" leading\ntrailing \n\t \t\n") == [" leading", "trailing ", "\t \t"]) +} |
