From 2dcc31fa63ba30f7c6539e77b4a4b77e63206e5f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 18 Sep 2026 18:26:41 +0200 Subject: [PATCH] Test that a quote inside a selector is a name's text, not a layout's quote --- template_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/template_test.go b/template_test.go index 12d9ae7..da8f9ff 100644 --- a/template_test.go +++ b/template_test.go @@ -2,6 +2,7 @@ package fejkdata import ( "encoding/json" + "reflect" "regexp" "strings" "testing" @@ -379,3 +380,18 @@ func TestArgErrorsNameTheSpelling(t *testing.T) { } } } + +// TestSplitArgsQuotesOutsideSelectors pins the arg grammar: a comma splits outside a +// selector and outside a quoted layout, and a quote inside a selector is a name's text. +func TestSplitArgsQuotesOutsideSelectors(t *testing.T) { + for in, want := range map[string][]string{ + "a, b": {"a", "b"}, + "1990-01-01,1990-12-31,'January 2, 2006'": {"1990-01-01", "1990-12-31", "'January 2, 2006'"}, + "/geo.US.locality[O'Fallon].name, 2": {"/geo.US.locality[O'Fallon].name", "2"}, + "'[a,b]'": {"'[a,b]'"}, + } { + if got := splitArgs(in); !reflect.DeepEqual(got, want) { + t.Errorf("splitArgs(%q) = %q, want %q", in, got, want) + } + } +}