Skip to content

Commit

Permalink
Clean up helpers_test code
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephTLyons committed Nov 12, 2024
1 parent a32c9b1 commit 7afdce3
Showing 1 changed file with 28 additions and 37 deletions.
65 changes: 28 additions & 37 deletions test/helpers_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,32 @@ import startest.{describe, it}
import startest/expect

pub fn to_printable_text_tests() {
describe(
"should_be_printable_text",
[
#("\t", "\\t"),
#("\n", "\\n"),
#("\r", "\\r"),
#("\f", "\\f"),
#("\r\n", "\\r\\n"),
#("\t\nabc123\r", "\\t\\nabc123\\r"),
#("abc123\r\n", "abc123\\r\\n"),
]
|> list.map(fn(tuple) {
let #(input, output) = tuple
use <- it("\"" <> output <> "\"")
input |> to_printable_text(False) |> expect.to_equal(output)
}),
)
}

pub fn to_printable_text_python_tests() {
describe(
"should_be_printable_python_text",
[
#("\t", "\\t"),
#("\n", "\\n"),
#("\r", "\\r"),
#("\f", "\\x0c"),
#("\r\n", "\\r\\n"),
#("\t\nabc123\r", "\\t\\nabc123\\r"),
#("abc123\r\n", "abc123\\r\\n"),
]
|> list.map(fn(tuple) {
let #(input, output) = tuple
use <- it("\"" <> output <> "\"")
input |> to_printable_text(True) |> expect.to_equal(output)
}),
)
describe("should_be_printable_text", [
describe(
"normal_printable",
[
#("\t", "\\t"),
#("\n", "\\n"),
#("\r", "\\r"),
#("\f", "\\f"),
#("\r\n", "\\r\\n"),
#("\t\nabc123\r", "\\t\\nabc123\\r"),
#("abc123\r\n", "abc123\\r\\n"),
]
|> list.map(fn(tuple) {
let #(input, output) = tuple
use <- it("\"" <> output <> "\"")
input |> to_printable_text(False) |> expect.to_equal(output)
}),
),
describe(
"python_printable",
[#("\f", "\\x0c"), #("\n\f\t", "\\n\\x0c\\t")]
|> list.map(fn(tuple) {
let #(input, output) = tuple
use <- it("\"" <> output <> "\"")
input |> to_printable_text(True) |> expect.to_equal(output)
}),
),
])
}

0 comments on commit 7afdce3

Please sign in to comment.