From 24d44468026a4b957a01b97f2f6d1b290f1d34d7 Mon Sep 17 00:00:00 2001 From: Riya John Date: Wed, 22 Apr 2020 08:15:49 +0530 Subject: [PATCH] Add float to test case to check leading zeroes in exponent parts (#363) * add float to test case to check leading zeroes in exponent parts * add testcase for query pkg --- example-crlf.toml | 1 + example.toml | 1 + parser_test.go | 2 ++ query/parser_test.go | 6 +++++- tomltree_write_test.go | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/example-crlf.toml b/example-crlf.toml index 12950a1..780d9c6 100644 --- a/example-crlf.toml +++ b/example-crlf.toml @@ -27,3 +27,4 @@ enabled = true [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it +score = 4e-08 # to make sure leading zeroes in exponent parts of floats are supported \ No newline at end of file diff --git a/example.toml b/example.toml index 3d902f2..f45bf88 100644 --- a/example.toml +++ b/example.toml @@ -27,3 +27,4 @@ enabled = true [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it +score = 4e-08 # to make sure leading zeroes in exponent parts of floats are supported \ No newline at end of file diff --git a/parser_test.go b/parser_test.go index a2ec3aa..65d11b0 100644 --- a/parser_test.go +++ b/parser_test.go @@ -783,6 +783,7 @@ func TestParseFile(t *testing.T) { []string{"gamma", "delta"}, []int64{1, 2}, }, + "score": 4e-08, }, }) } @@ -819,6 +820,7 @@ func TestParseFileCRLF(t *testing.T) { []string{"gamma", "delta"}, []int64{1, 2}, }, + "score": 4e-08, }, }) } diff --git a/query/parser_test.go b/query/parser_test.go index 312f51a..af93276 100644 --- a/query/parser_test.go +++ b/query/parser_test.go @@ -407,7 +407,10 @@ func TestQueryFilterFn(t *testing.T) { assertQueryPositions(t, string(buff), "$..[?(float)]", - []interface{}{ // no float values in document + []interface{}{ + queryTestNode{ + 4e-08, toml.Position{30, 1}, + }, }) tv, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z") @@ -460,6 +463,7 @@ func TestQueryFilterFn(t *testing.T) { []interface{}{"gamma", "delta"}, []interface{}{int64(1), int64(2)}, }, + "score": 4e-08, }, toml.Position{28, 1}, }, }) diff --git a/tomltree_write_test.go b/tomltree_write_test.go index 4c6540b..efbe885 100644 --- a/tomltree_write_test.go +++ b/tomltree_write_test.go @@ -236,6 +236,7 @@ func TestTreeWriteToMapExampleFile(t *testing.T) { []interface{}{"gamma", "delta"}, []interface{}{int64(1), int64(2)}, }, + "score": 4e-08, }, } testMaps(t, tree.ToMap(), expected)