aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorErik Terpstra <39518+eterps@users.noreply.github.com>2020-05-17 20:10:39 +0200
committerLouis Pilfold <louis@lpil.uk>2020-05-17 19:50:47 +0100
commitb3407607c4a58efa50239db278d730ef5b503afe (patch)
treed9f9263cb200f1fc7681581bb6f1b89f57da4769 /test
parent157b535280ba3d579d4ec3aafb0ec45db7272ca3 (diff)
downloadgleam_stdlib-b3407607c4a58efa50239db278d730ef5b503afe.tar.gz
gleam_stdlib-b3407607c4a58efa50239db278d730ef5b503afe.zip
string.slice
Diffstat (limited to 'test')
-rw-r--r--test/gleam/string_test.gleam22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam
index 03678ea..d08ea78 100644
--- a/test/gleam/string_test.gleam
+++ b/test/gleam/string_test.gleam
@@ -163,3 +163,25 @@ pub fn ends_with_test() {
|> string.ends_with("theory2")
|> should.equal(False)
}
+
+pub fn slice_test() {
+ "gleam"
+ |> string.slice(at_index: 1, length: 2)
+ |> should.equal("le")
+
+ "gleam"
+ |> string.slice(at_index: 1, length: 10)
+ |> should.equal("leam")
+
+ "gleam"
+ |> string.slice(at_index: 10, length: 3)
+ |> should.equal("")
+
+ "gleam"
+ |> string.slice(at_index: -2, length: 2)
+ |> should.equal("am")
+
+ "gleam"
+ |> string.slice(at_index: -12, length: 2)
+ |> should.equal("")
+}