From b3407607c4a58efa50239db278d730ef5b503afe Mon Sep 17 00:00:00 2001 From: Erik Terpstra <39518+eterps@users.noreply.github.com> Date: Sun, 17 May 2020 20:10:39 +0200 Subject: string.slice --- test/gleam/string_test.gleam | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') 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("") +} -- cgit v1.2.3