aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorErik Terpstra <39518+eterps@users.noreply.github.com>2020-05-19 10:19:27 +0200
committerLouis Pilfold <louis@lpil.uk>2020-05-19 14:12:11 +0100
commite5e14239bd6ca6f349b7dd76fb845b60515e3364 (patch)
tree639b29064a64811c7dec064d5881834aac916b35 /test
parentb3407607c4a58efa50239db278d730ef5b503afe (diff)
downloadgleam_stdlib-e5e14239bd6ca6f349b7dd76fb845b60515e3364.tar.gz
gleam_stdlib-e5e14239bd6ca6f349b7dd76fb845b60515e3364.zip
string.pad_left & string.pad_right
Diffstat (limited to 'test')
-rw-r--r--test/gleam/string_test.gleam36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam
index d08ea78..93de5db 100644
--- a/test/gleam/string_test.gleam
+++ b/test/gleam/string_test.gleam
@@ -185,3 +185,39 @@ pub fn slice_test() {
|> string.slice(at_index: -12, length: 2)
|> should.equal("")
}
+
+pub fn pad_left_test() {
+ "121"
+ |> string.pad_left(to: 5, with: ".")
+ |> should.equal("..121")
+
+ "121"
+ |> string.pad_left(to: 3, with: ".")
+ |> should.equal("121")
+
+ "121"
+ |> string.pad_left(to: 2, with: ".")
+ |> should.equal("121")
+
+ "121"
+ |> string.pad_left(to: 5, with: "XY")
+ |> should.equal("XYXY121")
+}
+
+pub fn pad_right_test() {
+ "121"
+ |> string.pad_right(to: 5, with: ".")
+ |> should.equal("121..")
+
+ "121"
+ |> string.pad_right(to: 3, with: ".")
+ |> should.equal("121")
+
+ "121"
+ |> string.pad_right(to: 2, with: ".")
+ |> should.equal("121")
+
+ "121"
+ |> string.pad_right(to: 5, with: "XY")
+ |> should.equal("121XYXY")
+}