aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
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("")
+}