diff options
author | Adam Scarr <adam@vektah.net> | 2017-08-15 18:57:00 +1000 |
---|---|---|
committer | Adam Scarr <adam@vektah.net> | 2017-08-15 18:57:00 +1000 |
commit | 0f854720ca2bad30246020bb01cdb903a5f9406d (patch) | |
tree | f4acedaa6928300fecd7791a68cc493c37938e5e /parser_test.go | |
parent | ddb61bdfc034a683f755dec6ddc80627d2d43522 (diff) |
Make until only work on string terminators
Diffstat (limited to 'parser_test.go')
-rw-r--r-- | parser_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/parser_test.go b/parser_test.go index ce5f3e7..aaed25f 100644 --- a/parser_test.go +++ b/parser_test.go @@ -214,6 +214,22 @@ func TestAutoWS(t *testing.T) { }) } +func TestUntil(t *testing.T) { + parser := Until("world", ".") + + t.Run("success", func(t *testing.T) { + result, ps := runParser("this is the end of the world", parser) + require.Equal(t, "this is the end of the ", result.Token) + require.Equal(t, "world", ps.Get()) + }) + + t.Run("eof", func(t *testing.T) { + result, ps := runParser("this is the end of it all", parser) + require.Equal(t, "this is the end of it all", result.Token) + require.Equal(t, "", ps.Get()) + }) +} + func runParser(input string, parser Parser) (Result, *State) { ps := NewState(input) result := Result{} |