diff options
Diffstat (limited to 'main/main_test.go')
| -rw-r--r-- | main/main_test.go | 15 | 
1 files changed, 11 insertions, 4 deletions
diff --git a/main/main_test.go b/main/main_test.go index 3d10c48..076693d 100644 --- a/main/main_test.go +++ b/main/main_test.go @@ -6,7 +6,8 @@ import (  )  const miscInput string = `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values"],"people":[{"first_name":"Charlie","last_name":"Johnson","age":22},{"first_name":"Tom","last_name":"Johnson","age":18},{"first_name":"Charlie","last_name":"Chaplin","age":122},{"first_name":"John","last_name":"Johnson","age":48}]}` -const mixedArray string = `{"array":["first",{"name":"second"},"third"]}` +const mixedArray string = `{"array":["first",null,3,{"name":"second"},"third"]}` +const mixedArray2 string = `{"array":["first",null,3,"second",{"name":"third"}]}`  func TestSpecificCases(t *testing.T) {  	type test struct { @@ -116,7 +117,7 @@ func TestSpecificCases(t *testing.T) {  		},  		{  			name: "Drop last element of array", -			program: `M/#( "people" @( . #()# )@ )#/{ Ed }`, +			program: `M/#( "people" @( . , )@ )#/{ Ed }`,  			input: miscInput,  			expected: `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values"],"people":[{"first_name":"Charlie","last_name":"Johnson","age":22},{"first_name":"Tom","last_name":"Johnson","age":18},{"first_name":"Charlie","last_name":"Chaplin","age":122}]}`,  		}, @@ -128,9 +129,15 @@ func TestSpecificCases(t *testing.T) {  		},  		{  			name: "Drop last element of mixed array", -			program: `M/#( "array" @( . (~[.]~|@()@|#()#) )@ )#/{ Ed }`, +			program: `M/#( "array" @( . , )@ )#/{ Ed }`,  			input: mixedArray, -			expected: `{"array":["first",{"name":"second"}]}`, +			expected: `{"array":["first",null,3,{"name":"second"}]}`, +		}, +		{ +			name: "Drop last element of mixed array 2", +			program: `M/#( "array" @( . , )@ )#/{ Ed }`, +			input: mixedArray2, +			expected: `{"array":["first",null,3,"second"]}`,  		},  		{  			name: "Prepend to array",  | 
