From 814102fc092091c4f1ea237921eba7099892d88b Mon Sep 17 00:00:00 2001 From: Christopher Ramey Date: Mon, 18 Jan 2021 07:40:56 -0900 Subject: [PATCH] added tokenizer test for empty quotes --- config/testdata/quotes-empty.tok | 3 +++ config/tokenizer.go | 4 +--- config/tokenizer_test.go | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 config/testdata/quotes-empty.tok diff --git a/config/testdata/quotes-empty.tok b/config/testdata/quotes-empty.tok new file mode 100644 index 0000000..26e6aa0 --- /dev/null +++ b/config/testdata/quotes-empty.tok @@ -0,0 +1,3 @@ +one "" three +"" five "" +seven diff --git a/config/tokenizer.go b/config/tokenizer.go index 44ab978..31b66ce 100644 --- a/config/tokenizer.go +++ b/config/tokenizer.go @@ -131,9 +131,7 @@ func (t *Tokenizer) Scan() bool { end: if t.err == nil || t.err == io.EOF { - if b.Len() > 0 { - t.text = b.String() - } + t.text = b.String() } return t.err == nil } diff --git a/config/tokenizer_test.go b/config/tokenizer_test.go index bf6c31b..8c8db40 100644 --- a/config/tokenizer_test.go +++ b/config/tokenizer_test.go @@ -29,6 +29,12 @@ func TestQuotesMultiline(t *testing.T) { ) } +func TestQuotesEmpty(t *testing.T) { + runTest(t, "quotes-empty", + `[["one","","three"],["","five",""],["seven"]]`, + ) +} + func TestComments(t *testing.T) { runTest(t, "comments", `[[],["one"],[],["two"],[],["three"]]`,