From 7edad5cefa0f065aa83dffd2d7830aeaf9f38662 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 29 Jan 2022 23:31:16 +0100 Subject: tests: add functional tests for builtin functions Signed-off-by: Jo-Philipp Wich --- tests/custom/03_stdlib/25_ltrim | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/custom/03_stdlib/25_ltrim (limited to 'tests/custom/03_stdlib/25_ltrim') diff --git a/tests/custom/03_stdlib/25_ltrim b/tests/custom/03_stdlib/25_ltrim new file mode 100644 index 0000000..2001322 --- /dev/null +++ b/tests/custom/03_stdlib/25_ltrim @@ -0,0 +1,46 @@ +The `ltrim()` function removes specific leading characters from the given +input string. If the characters to trim are unspecified, the space, tab, +carriage return and newline characters will be used by default. + +Returns a copy of the input string with the specified leading characters +removed. + +Returns `null` if the given input argment is not a valid string value. + +-- Testcase -- +{% + printf("%.J\n", [ + // not specifying trim characters will trim whitespace + ltrim(" Hello World!"), + + // if trim characters are specified, only those are removed + ltrim("|* Foo Bar +|", "+*|"), + + // ltrim does not affect characters in the middle or the end + ltrim(" Foo Bar "), + ltrim("|Foo|Bar|", "|") + ]); +%} +-- End -- + +-- Expect stdout -- +[ + "Hello World!", + " Foo Bar +|", + "Foo Bar ", + "Foo|Bar|" +] +-- End -- + + +Supplying an invalid string will yield `null`. + +-- Testcase -- +{% + printf("%.J\n", ltrim(true)); +%} +-- End -- + +-- Expect stdout -- +null +-- End -- -- cgit v1.2.3