From bfdde0ee0b60482f5d41e7e6cbae2b11f9daf08f Mon Sep 17 00:00:00 2001 From: greggreg Date: Thu, 16 Apr 2020 08:50:24 -0600 Subject: Implementing String.contains and String.repeat --- test/gleam/string_test.gleam | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam index ae8a0e9..133bdf5 100644 --- a/test/gleam/string_test.gleam +++ b/test/gleam/string_test.gleam @@ -67,6 +67,19 @@ pub fn compare_test() { |> should.equal(_, order.Gt) } +pub fn contains_test() { + "gleam" + |> string.contains(_, "ea") + |> should.equal(_, True) + + "gleam" + |> string.contains(_, "x") + |> should.equal(_, False) + + string.contains(does: "bellwether", contain: "bell") + |> should.equal(_, True) +} + pub fn concat_test() { [ "Hello", ", ", "world!", @@ -75,6 +88,20 @@ pub fn concat_test() { |> should.equal(_, "Hello, world!") } +pub fn repeat_test() { + "hi" + |> string.repeat(_, times: 3) + |> should.equal(_, "hihihi") + + "hi" + |> string.repeat(_, 0) + |> should.equal(_, "") + + "hi" + |> string.repeat(_, -1) + |> should.equal(_, "") +} + pub fn join_test() { [ "Hello", "world!", -- cgit v1.2.3