From 9ce5b3b6d52368b9333a9d5f98c3cd2b1a3cb038 Mon Sep 17 00:00:00 2001 From: Tommaso Negri Date: Thu, 15 Oct 2026 11:07:41 +0200 Subject: add tests --- Tests/barTests/phbarTests.swift | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Tests/barTests') 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"]) +} -- cgit v1.2.3