From ddb61bdfc034a683f755dec6ddc80627d2d43522 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sun, 13 Aug 2017 22:11:27 +1000 Subject: Add an Until function --- combinator_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'combinator_test.go') diff --git a/combinator_test.go b/combinator_test.go index c1eedb3..e792c47 100644 --- a/combinator_test.go +++ b/combinator_test.go @@ -181,6 +181,20 @@ func TestMap(t *testing.T) { }) } +func TestUntil(t *testing.T) { + parser := Until("world", ".") + + t.Run("success", func(t *testing.T) { + result, _ := runParser("this is the end of the world", parser) + require.Equal(t, "this is the end of the ", result.Token) + }) + + t.Run("eof", func(t *testing.T) { + result, _ := runParser("this is the end of it all", parser) + require.Equal(t, "this is the end of it all", result.Token) + }) +} + func TestBind(t *testing.T) { parser := Bind("true", true) -- cgit v1.2.3