diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-04-28 19:42:06 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-04-28 19:42:06 +0100 |
commit | f9a69d3121248a6fc285dbcb63b242b8425283ef (patch) | |
tree | 6a0dab37a6c9b61f39e2311de04ca8a6140c6fba /main/main_test.go | |
parent | 8ac12c99fc59b01da40c2939cb4a7b72d32d2153 (diff) | |
download | stred-go-f9a69d3121248a6fc285dbcb63b242b8425283ef.tar |
Add more tests for a and e commands
Diffstat (limited to 'main/main_test.go')
-rw-r--r-- | main/main_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/main/main_test.go b/main/main_test.go index 8512b62..94e1f04 100644 --- a/main/main_test.go +++ b/main/main_test.go @@ -107,6 +107,30 @@ func TestMain(t *testing.T) { input: miscInput, expected: `"Hello world these are values"`, }, + { + name: "Drop first element of array", + program: `s/#( "people" @( 0 . )@ )#/d`, + input: miscInput, + expected: `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values"],"people":[{"first_name":"Tom","last_name":"Johnson","age":18},{"first_name":"Charlie","last_name":"Chaplin","age":122},{"first_name":"John","last_name":"Johnson","age":48}]}`, + }, + { + name: "Drop last element of array", + 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}]}`, + }, + { + name: "Prepend to array", + program: "as/#( \"array\" :( `\"First\"` ): )#/", + input: miscInput, + expected: `{"something":{"nested":"Here is my test value"},"array":["First","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}]}`, + }, + { + name: "Append to array", + program: "es/#( \"array\" :( `\"Last\"` ): )#/", + input: miscInput, + expected: `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values","Last"],"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}]}`, + }, } for _, test := range tests { |