| 1 | package jsonparserscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/" |
| 5 | "errorsscip-go gomod github.com/golang/go/src go1.13 errors/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 7 | _ "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 8 | "reflectscip-go gomod github.com/golang/go/src go1.13 reflect/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 10 | ) |
| 11 | |
| 12 | // Set it to non-empty value if want to run only specific test |
| 13 | var activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. = "" |
| 14 | |
| 15 | // Test helper for SYS-REQ-006. |
| 16 | func toArrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/toArray().(data []byte) (result [][]byte) { |
| 17 | ArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ArrayEach().(data, func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, offset int, err error) { |
| 18 | result = append(result, value) |
| 19 | }) |
| 20 | |
| 21 | return |
| 22 | } |
| 23 | |
| 24 | // Test helper for SYS-REQ-006 and SYS-REQ-008. |
| 25 | func toStringArrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/toStringArray().(data []byte) (result []string) { |
| 26 | ArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ArrayEach().(data, func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, offset int, err error) { |
| 27 | result = append(result, string(value)) |
| 28 | }) |
| 29 | |
| 30 | return |
| 31 | } |
| 32 | |
| 33 | type GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest# struct { |
| 34 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc. string |
| 35 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json. string |
| 36 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path. []string |
| 37 | |
| 38 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr. bool |
| 39 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound. bool |
| 40 | |
| 41 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data. interface{} |
| 42 | } |
| 43 | |
| 44 | type SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest# struct { |
| 45 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc. string |
| 46 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json. string |
| 47 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData. string |
| 48 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path. []string |
| 49 | |
| 50 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isErr. bool |
| 51 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound. bool |
| 52 | |
| 53 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data. interface{} |
| 54 | } |
| 55 | |
| 56 | type DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest# struct { |
| 57 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc. string |
| 58 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json. string |
| 59 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path. []string |
| 60 | |
| 61 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data. interface{} |
| 62 | } |
| 63 | |
| 64 | var deleteTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/deleteTests. = []DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#{ |
| 65 | { |
| 66 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete test key", |
| 67 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":"input"}`, |
| 68 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test"}, |
| 69 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{}`, |
| 70 | }, |
| 71 | { |
| 72 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object", |
| 73 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":"input"}`, |
| 74 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{}, |
| 75 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: ``, |
| 76 | }, |
| 77 | { |
| 78 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete a nested object", |
| 79 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":"input","new.field":{"key": "new object"}}`, |
| 80 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"new.field", "key"}, |
| 81 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":"input","new.field":{}}`, |
| 82 | }, |
| 83 | { |
| 84 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Deleting a key that doesn't exist should return the same object", |
| 85 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":"input"}`, |
| 86 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test2"}, |
| 87 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":"input"}`, |
| 88 | }, |
| 89 | { |
| 90 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object in an array", |
| 91 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":[{"key":"val-obj1"}]}`, |
| 92 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test", "[0]"}, |
| 93 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":[]}`, |
| 94 | }, |
| 95 | { |
| 96 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Deleting a object in an array that doesn't exists should return the same object", |
| 97 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":[{"key":"val-obj1"}]}`, |
| 98 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test", "[1]"}, |
| 99 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":[{"key":"val-obj1"}]}`, |
| 100 | }, |
| 101 | { |
| 102 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete a complex object in a nested array", |
| 103 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":[{"key":[{"innerKey":"innerKeyValue"}]}]}`, |
| 104 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test", "[0]", "key", "[0]"}, |
| 105 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":[{"key":[]}]}`, |
| 106 | }, |
| 107 | { |
| 108 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete known key (simple type within nested array)", |
| 109 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":[{"key":["innerKey"]}]}`, |
| 110 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test", "[0]", "key", "[0]"}, |
| 111 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test":[{"key":[]}]}`, |
| 112 | }, |
| 113 | { |
| 114 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete in empty json", |
| 115 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{}`, |
| 116 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{}, |
| 117 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: ``, |
| 118 | }, |
| 119 | { |
| 120 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete empty array", |
| 121 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `[]`, |
| 122 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{}, |
| 123 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: ``, |
| 124 | }, |
| 125 | { |
| 126 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Deleting non json should return the same value", |
| 127 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `1.323`, |
| 128 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"foo"}, |
| 129 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `1.323`, |
| 130 | }, |
| 131 | { |
| 132 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete known key (top level array)", |
| 133 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `[{"key":"val-obj1"}]`, |
| 134 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"[0]"}, |
| 135 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `[]`, |
| 136 | }, |
| 137 | { // This test deletes the key instead of returning a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 138 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: `malformed with trailing whitespace`, |
| 139 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a":1 `, |
| 140 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a"}, |
| 141 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{ `, |
| 142 | }, |
| 143 | { // This test dels the key instead of returning a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 144 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "malformed 'colon chain', delete b", |
| 145 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a":"b":"c"}`, |
| 146 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"b"}, |
| 147 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a":}`, |
| 148 | }, |
| 149 | { |
| 150 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object without inner array", |
| 151 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": {"b": 1}, "b": 2}`, |
| 152 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"b"}, |
| 153 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": {"b": 1}}`, |
| 154 | }, |
| 155 | { |
| 156 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object without inner array", |
| 157 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": [{"b": 1}], "b": 2}`, |
| 158 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"b"}, |
| 159 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": [{"b": 1}]}`, |
| 160 | }, |
| 161 | { |
| 162 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object without inner array", |
| 163 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": {"c": {"b": 3}, "b": 1}, "b": 2}`, |
| 164 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a", "b"}, |
| 165 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": {"c": {"b": 3}}, "b": 2}`, |
| 166 | }, |
| 167 | { |
| 168 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete object without inner array", |
| 169 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": [{"c": {"b": 3}, "b": 1}], "b": 2}`, |
| 170 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a", "[0]", "b"}, |
| 171 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": [{"c": {"b": 3}}], "b": 2}`, |
| 172 | }, |
| 173 | { |
| 174 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Remove trailing comma if last object is deleted", |
| 175 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": "1", "b": "2"}`, |
| 176 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"b"}, |
| 177 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": "1"}`, |
| 178 | }, |
| 179 | { |
| 180 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Correctly delete first element with space-comma", |
| 181 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": "1" ,"b": "2" }`, |
| 182 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a"}, |
| 183 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"b": "2" }`, |
| 184 | }, |
| 185 | { |
| 186 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Correctly delete middle element with space-comma", |
| 187 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": "1" ,"b": "2" , "c": 3}`, |
| 188 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"b"}, |
| 189 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": "1" , "c": 3}`, |
| 190 | }, |
| 191 | { |
| 192 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete non-last key", |
| 193 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test":"input","test1":"input1"}`, |
| 194 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test"}, |
| 195 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test1":"input1"}`, |
| 196 | }, |
| 197 | { |
| 198 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete non-exist key", |
| 199 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"test:":"input"}`, |
| 200 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test", "test1"}, |
| 201 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"test:":"input"}`, |
| 202 | }, |
| 203 | { |
| 204 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete non-last object in an array", |
| 205 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `[{"key":"val-obj1"},{"key2":"val-obj2"}]`, |
| 206 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"[0]"}, |
| 207 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `[{"key2":"val-obj2"}]`, |
| 208 | }, |
| 209 | { |
| 210 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Delete non-first object in an array", |
| 211 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `[{"key":"val-obj1"},{"key2":"val-obj2"}]`, |
| 212 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"[1]"}, |
| 213 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `[{"key":"val-obj1"}]`, |
| 214 | }, |
| 215 | { |
| 216 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Issue #188: infinite loop in Delete", |
| 217 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `^_�^C^A^@[`, |
| 218 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{""}, |
| 219 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `^_�^C^A^@[`, |
| 220 | }, |
| 221 | { |
| 222 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Issue #188: infinite loop in Delete", |
| 223 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `^_�^C^A^@{`, |
| 224 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{""}, |
| 225 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `^_�^C^A^@{`, |
| 226 | }, |
| 227 | { |
| 228 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "Issue #150: leading space", |
| 229 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: ` {"test":"input"}`, |
| 230 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"test"}, |
| 231 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: ` {}`, |
| 232 | }, |
| 233 | { |
| 234 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "GO-2026-4514: malformed JSON without enclosing braces should not panic", |
| 235 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `"0":"0":`, |
| 236 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"0"}, |
| 237 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `"0":"0":`, |
| 238 | }, |
| 239 | { |
| 240 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "GO-2026-4514: malformed JSON with key but truncated value should not panic", |
| 241 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a": `, |
| 242 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a"}, |
| 243 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a": `, |
| 244 | }, |
| 245 | { |
| 246 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.: "GO-2026-4514: malformed nested JSON with truncated value should not panic", |
| 247 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.: `{"a":{"b": `, |
| 248 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path.: []string{"a", "b"}, |
| 249 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data.: `{"a":{"b": `, |
| 250 | }, |
| 251 | } |
| 252 | |
| 253 | var setTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/setTests. = []SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#{ |
| 254 | { |
| 255 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (string)", |
| 256 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 257 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 258 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"new.field"}, |
| 259 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new value"`, |
| 260 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":"input","new.field":"new value"}`, |
| 261 | }, |
| 262 | { |
| 263 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set known key (string)", |
| 264 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 265 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 266 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test"}, |
| 267 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new value"`, |
| 268 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":"new value"}`, |
| 269 | }, |
| 270 | { |
| 271 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (object)", |
| 272 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 273 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 274 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"new.field"}, |
| 275 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key": "new object"}`, |
| 276 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":"input","new.field":{"key": "new object"}}`, |
| 277 | }, |
| 278 | { |
| 279 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set known key (object)", |
| 280 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 281 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 282 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test"}, |
| 283 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key": "new object"}`, |
| 284 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":{"key": "new object"}}`, |
| 285 | }, |
| 286 | { |
| 287 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set known key (object within array)", |
| 288 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":[{"key":"val-obj1"}]}`, |
| 289 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 290 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "[0]"}, |
| 291 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key":"new object"}`, |
| 292 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":[{"key":"new object"}]}`, |
| 293 | }, |
| 294 | { |
| 295 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (replace object)", |
| 296 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":[{"key":"val-obj1"}]}`, |
| 297 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 298 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "newKey"}, |
| 299 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new object"`, |
| 300 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":{"newKey":"new object"}}`, |
| 301 | }, |
| 302 | { |
| 303 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (complex object within nested array)", |
| 304 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":[{"key":[{"innerKey":"innerKeyValue"}]}]}`, |
| 305 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 306 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "[0]", "key", "[0]", "newInnerKey"}, |
| 307 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key":"new object"}`, |
| 308 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":[{"key":[{"innerKey":"innerKeyValue","newInnerKey":{"key":"new object"}}]}]}`, |
| 309 | }, |
| 310 | { |
| 311 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set known key (complex object within nested array)", |
| 312 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":[{"key":[{"innerKey":"innerKeyValue"}]}]}`, |
| 313 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 314 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "[0]", "key", "[0]", "innerKey"}, |
| 315 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key":"new object"}`, |
| 316 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":[{"key":[{"innerKey":{"key":"new object"}}]}]}`, |
| 317 | }, |
| 318 | { |
| 319 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (object, partial subtree exists)", |
| 320 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":{"input":"output"}}`, |
| 321 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 322 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "new.field"}, |
| 323 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key":"new object"}`, |
| 324 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":{"input":"output","new.field":{"key":"new object"}}}`, |
| 325 | }, |
| 326 | { |
| 327 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (object, empty partial subtree exists)", |
| 328 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":{}}`, |
| 329 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 330 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "new.field"}, |
| 331 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key":"new object"}`, |
| 332 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":{"new.field":{"key":"new object"}}}`, |
| 333 | }, |
| 334 | { |
| 335 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (object, no subtree exists)", |
| 336 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 337 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 338 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"new.field", "nested", "value"}, |
| 339 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `{"key": "new object"}`, |
| 340 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":"input","new.field":{"nested":{"value":{"key": "new object"}}}}`, |
| 341 | }, |
| 342 | { |
| 343 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set in empty json", |
| 344 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{}`, |
| 345 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 346 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"foo"}, |
| 347 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"null"`, |
| 348 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"foo":"null"}`, |
| 349 | }, |
| 350 | { |
| 351 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set subtree in empty json", |
| 352 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{}`, |
| 353 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 354 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"foo", "bar"}, |
| 355 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"null"`, |
| 356 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"foo":{"bar":"null"}}`, |
| 357 | }, |
| 358 | { |
| 359 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set in empty string - not found", |
| 360 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: ``, |
| 361 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: false, |
| 362 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"foo"}, |
| 363 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"null"`, |
| 364 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: ``, |
| 365 | }, |
| 366 | { |
| 367 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set in Number - not found", |
| 368 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `1.323`, |
| 369 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: false, |
| 370 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"foo"}, |
| 371 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"null"`, |
| 372 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `1.323`, |
| 373 | }, |
| 374 | { |
| 375 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set known key (top level array)", |
| 376 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `[{"key":"val-obj1"}]`, |
| 377 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 378 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"[0]", "key"}, |
| 379 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new object"`, |
| 380 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `[{"key":"new object"}]`, |
| 381 | }, |
| 382 | { |
| 383 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (trailing whitespace)", |
| 384 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"key":"val-obj1"} `, |
| 385 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 386 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"alt-key"}, |
| 387 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new object"`, |
| 388 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"key":"val-obj1","alt-key":"new object"} `, |
| 389 | }, |
| 390 | { // This test sets the key instead of returning a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 391 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: `malformed with trailing whitespace`, |
| 392 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"a":1 `, |
| 393 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"a"}, |
| 394 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `2`, |
| 395 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 396 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"a":2 `, |
| 397 | }, |
| 398 | { // This test sets the key instead of returning a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 399 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "malformed 'colon chain', set second string", |
| 400 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"a":"b":"c"}`, |
| 401 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"b"}, |
| 402 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"d"`, |
| 403 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 404 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"a":"b":"d"}`, |
| 405 | }, |
| 406 | { |
| 407 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set indexed path to object on empty JSON", |
| 408 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{}`, |
| 409 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"top", "[0]", "middle", "[0]", "bottom"}, |
| 410 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"value"`, |
| 411 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 412 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"top":[{"middle":[{"bottom":"value"}]}]}`, |
| 413 | }, |
| 414 | { |
| 415 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set indexed path on existing object with object", |
| 416 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"top":[{"middle":[]}]}`, |
| 417 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"top", "[0]", "middle", "[0]", "bottom"}, |
| 418 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"value"`, |
| 419 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 420 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"top":[{"middle":[{"bottom":"value"}]}]}`, |
| 421 | }, |
| 422 | { |
| 423 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set indexed path on existing object with value", |
| 424 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"top":[{"middle":[]}]}`, |
| 425 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"top", "[0]", "middle", "[0]"}, |
| 426 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"value"`, |
| 427 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 428 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"top":[{"middle":["value"]}]}`, |
| 429 | }, |
| 430 | { |
| 431 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set indexed path on empty object with value", |
| 432 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{}`, |
| 433 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"top", "[0]", "middle", "[0]"}, |
| 434 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"value"`, |
| 435 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 436 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"top":[{"middle":["value"]}]}`, |
| 437 | }, |
| 438 | { |
| 439 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set indexed path on object with existing array", |
| 440 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"top":["one", "two", "three"]}`, |
| 441 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"top", "[2]"}, |
| 442 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"value"`, |
| 443 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 444 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"top":["one", "two", "value"]}`, |
| 445 | }, |
| 446 | { |
| 447 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set non-exist key", |
| 448 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":"input"}`, |
| 449 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new value"`, |
| 450 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: false, |
| 451 | }, |
| 452 | { |
| 453 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set key in invalid json", |
| 454 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test"::"input"}`, |
| 455 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test"}, |
| 456 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: "new value", |
| 457 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isErr.: true, |
| 458 | }, |
| 459 | { |
| 460 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.: "set unknown key (simple object within nested array)", |
| 461 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.: `{"test":{"key":[{"innerKey":"innerKeyValue", "innerKey2":"innerKeyValue2"}]}}`, |
| 462 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound.: true, |
| 463 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path.: []string{"test", "key", "[1]", "newInnerKey"}, |
| 464 | setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.: `"new object"`, |
| 465 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.: `{"test":{"key":[{"innerKey":"innerKeyValue", "innerKey2":"innerKeyValue2"},{"newInnerKey":"new object"}]}}`, |
| 466 | }, |
| 467 | } |
| 468 | |
| 469 | var getTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 470 | // Trivial tests |
| 471 | { |
| 472 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read string", |
| 473 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `""`, |
| 474 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 475 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: ``, |
| 476 | }, |
| 477 | { |
| 478 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read number", |
| 479 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `0`, |
| 480 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 481 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `0`, |
| 482 | }, |
| 483 | { |
| 484 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read object", |
| 485 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{}`, |
| 486 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 487 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `{}`, |
| 488 | }, |
| 489 | { |
| 490 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read array", |
| 491 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `[]`, |
| 492 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 493 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `[]`, |
| 494 | }, |
| 495 | { |
| 496 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read boolean", |
| 497 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `true`, |
| 498 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 499 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `true`, |
| 500 | }, |
| 501 | |
| 502 | // Found key tests |
| 503 | { |
| 504 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "handling multiple nested keys with same name", |
| 505 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[{"b":1},{"b":2},3],"c":{"c":[1,2]}} }`, |
| 506 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c", "c"}, |
| 507 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 508 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `[1,2]`, |
| 509 | }, |
| 510 | { |
| 511 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read basic key", |
| 512 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b"}`, |
| 513 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 514 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 515 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `b`, |
| 516 | }, |
| 517 | { |
| 518 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read basic key with space", |
| 519 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b"}`, |
| 520 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 521 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 522 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `b`, |
| 523 | }, |
| 524 | { |
| 525 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "read composite key", |
| 526 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b":{"c":"d" }}}`, |
| 527 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b", "c"}, |
| 528 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 529 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `d`, |
| 530 | }, |
| 531 | { |
| 532 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read numberic value as string`, |
| 533 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": 1}`, |
| 534 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 535 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 536 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 537 | }, |
| 538 | { |
| 539 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `handle multiple nested keys with same name`, |
| 540 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[{"b":1},{"b":2},3],"c":{"c":[1,2]}} }`, |
| 541 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c", "c"}, |
| 542 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 543 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `[1,2]`, |
| 544 | }, |
| 545 | { |
| 546 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read string values with quotes`, |
| 547 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "string\"with\"quotes"}`, |
| 548 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 549 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 550 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `string\"with\"quotes`, |
| 551 | }, |
| 552 | { |
| 553 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read object`, |
| 554 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b":{"c":"d" }}}`, |
| 555 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b"}, |
| 556 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 557 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `{"c":"d" }`, |
| 558 | }, |
| 559 | { |
| 560 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `empty path`, |
| 561 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c":"d" }`, |
| 562 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{}, |
| 563 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 564 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `{"c":"d" }`, |
| 565 | }, |
| 566 | { |
| 567 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `formatted JSON value`, |
| 568 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\n \"a\": \"b\"\n}", |
| 569 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 570 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 571 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `b`, |
| 572 | }, |
| 573 | { |
| 574 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `formatted JSON value 2`, |
| 575 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\n \"a\":\n {\n\"b\":\n {\"c\":\"d\",\n\"e\": \"f\"}\n}\n}", |
| 576 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b"}, |
| 577 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 578 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "{\"c\":\"d\",\n\"e\": \"f\"}", |
| 579 | }, |
| 580 | { |
| 581 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `whitespace`, |
| 582 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: " \n\r\t{ \n\r\t\"whitespace\" \n\r\t: \n\r\t333 \n\r\t} \n\r\t", |
| 583 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"whitespace"}, |
| 584 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 585 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "333", |
| 586 | }, |
| 587 | { |
| 588 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `escaped backslash quote`, |
| 589 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "\\\""}`, |
| 590 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 591 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 592 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `\\\"`, |
| 593 | }, |
| 594 | { |
| 595 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `unescaped backslash quote`, |
| 596 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "\\"}`, |
| 597 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 598 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 599 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `\\`, |
| 600 | }, |
| 601 | { |
| 602 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `unicode in JSON`, |
| 603 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "15°C"}`, |
| 604 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 605 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 606 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `15°C`, |
| 607 | }, |
| 608 | { |
| 609 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `no padding + nested`, |
| 610 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":{"a":"1"},"b":2}`, |
| 611 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 612 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 613 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `2`, |
| 614 | }, |
| 615 | { |
| 616 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `no padding + nested + array`, |
| 617 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":{"b":[1,2]},"c":3}`, |
| 618 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 619 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 620 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `3`, |
| 621 | }, |
| 622 | { |
| 623 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `empty key`, |
| 624 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"":{"":{"":true}}}`, |
| 625 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"", "", ""}, |
| 626 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 627 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `true`, |
| 628 | }, |
| 629 | |
| 630 | // Escaped key tests |
| 631 | { |
| 632 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `key with simple escape`, |
| 633 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a\\b":1}`, |
| 634 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a\\b"}, |
| 635 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 636 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 637 | }, |
| 638 | { |
| 639 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `key and value with whitespace escapes`, |
| 640 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"key\b\f\n\r\tkey":"value\b\f\n\r\tvalue"}`, |
| 641 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"key\b\f\n\r\tkey"}, |
| 642 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 643 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `value\b\f\n\r\tvalue`, // value is not unescaped since this is Get(), but the key should work correctly |
| 644 | }, |
| 645 | { |
| 646 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `key with Unicode escape`, |
| 647 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a\u00B0b":1}`, |
| 648 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a\u00B0b"}, |
| 649 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 650 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 651 | }, |
| 652 | { |
| 653 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `key with complex escape`, |
| 654 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a\uD83D\uDE03b":1}`, |
| 655 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a\U0001F603b"}, |
| 656 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 657 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 658 | }, |
| 659 | |
| 660 | { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance |
| 661 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed with trailing whitespace`, |
| 662 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":1 `, |
| 663 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 664 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 665 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 666 | }, |
| 667 | { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance |
| 668 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed with wrong closing bracket`, |
| 669 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":1]`, |
| 670 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 671 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 672 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 673 | }, |
| 674 | |
| 675 | // Not found key tests |
| 676 | { |
| 677 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `empty input`, |
| 678 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: ``, |
| 679 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 680 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 681 | }, |
| 682 | { |
| 683 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "non-existent key 1", |
| 684 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b"}`, |
| 685 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 686 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 687 | }, |
| 688 | { |
| 689 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "non-existent key 2", |
| 690 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b"}`, |
| 691 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 692 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 693 | }, |
| 694 | { |
| 695 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "non-existent key 3", |
| 696 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"aa":"b"}`, |
| 697 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 698 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 699 | }, |
| 700 | { |
| 701 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "apply scope of parent when search for nested key", |
| 702 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b": 1}, "c": 2 }`, |
| 703 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b", "c"}, |
| 704 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 705 | }, |
| 706 | { |
| 707 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `apply scope to key level`, |
| 708 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b": 1}, "c": 2 }`, |
| 709 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 710 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 711 | }, |
| 712 | { |
| 713 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `handle escaped quote in key name in JSON`, |
| 714 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"key\"key": 1}`, |
| 715 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"key"}, |
| 716 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 717 | }, |
| 718 | { |
| 719 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "handling multiple keys with different name", |
| 720 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":{"a":1},"b":{"a":3,"c":[1,2]}}`, |
| 721 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "c"}, |
| 722 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 723 | }, |
| 724 | { |
| 725 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "handling nested json", |
| 726 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":{"b":{"c":1},"d":4}}`, |
| 727 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "d"}, |
| 728 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 729 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `4`, |
| 730 | }, |
| 731 | { // Issue #148 |
| 732 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing key in different key same level`, |
| 733 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"s":"s","ic":2,"r":{"o":"invalid"}}`, |
| 734 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"ic", "o"}, |
| 735 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 736 | }, |
| 737 | |
| 738 | // Error/invalid tests |
| 739 | { |
| 740 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `handle escaped quote in key name in JSON`, |
| 741 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"key\"key": 1}`, |
| 742 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"key"}, |
| 743 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 744 | }, |
| 745 | { |
| 746 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing closing brace, but can still find key`, |
| 747 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b"`, |
| 748 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 749 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 750 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `b`, |
| 751 | }, |
| 752 | { |
| 753 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value closing quote`, |
| 754 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b`, |
| 755 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 756 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 757 | }, |
| 758 | { |
| 759 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value closing curly brace`, |
| 760 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b": "c"`, |
| 761 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 762 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 763 | }, |
| 764 | { |
| 765 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value closing square bracket`, |
| 766 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": [1, 2, 3 }`, |
| 767 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 768 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 769 | }, |
| 770 | { |
| 771 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value 1`, |
| 772 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":`, |
| 773 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 774 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 775 | }, |
| 776 | { |
| 777 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value 2`, |
| 778 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": `, |
| 779 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 780 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 781 | }, |
| 782 | { |
| 783 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing value 3`, |
| 784 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":}`, |
| 785 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 786 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 787 | }, |
| 788 | { |
| 789 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed array (no closing brace)`, |
| 790 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[, "b":123}`, |
| 791 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 792 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 793 | }, |
| 794 | { // Issue #81 |
| 795 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing key in object in array`, |
| 796 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"p":{"a":[{"u":"abc","t":"th"}]}}`, |
| 797 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"p", "a", "[0]", "x"}, |
| 798 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 799 | }, |
| 800 | { // Issue #81 counter test |
| 801 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `existing key in object in array`, |
| 802 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"p":{"a":[{"u":"abc","t":"th"}]}}`, |
| 803 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"p", "a", "[0]", "u"}, |
| 804 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 805 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "abc", |
| 806 | }, |
| 807 | { // This test returns not found instead of a parse error, as checking for the malformed JSON would reduce performance |
| 808 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "malformed key (followed by comma followed by colon)", |
| 809 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a",:1}`, |
| 810 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 811 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 812 | }, |
| 813 | { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 814 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "malformed 'colon chain', lookup first string", |
| 815 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b":"c"}`, |
| 816 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 817 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 818 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "b", |
| 819 | }, |
| 820 | { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance (this is not ideal) |
| 821 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "malformed 'colon chain', lookup second string", |
| 822 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":"b":"c"}`, |
| 823 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 824 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 825 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "c", |
| 826 | }, |
| 827 | // Array index paths |
| 828 | { |
| 829 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "last key in path is index", |
| 830 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[{"b":1},{"b":"2"}, 3],"c":{"c":[1,2]}}`, |
| 831 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "[1]"}, |
| 832 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 833 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `{"b":"2"}`, |
| 834 | }, |
| 835 | { |
| 836 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "get string from array", |
| 837 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[{"b":1},"foo", 3],"c":{"c":[1,2]}}`, |
| 838 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "[1]"}, |
| 839 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 840 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "foo", |
| 841 | }, |
| 842 | { |
| 843 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "key in path is index", |
| 844 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":[{"b":"1"},{"b":"2"},3],"c":{"c":[1,2]}}`, |
| 845 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "[0]", "b"}, |
| 846 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 847 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 848 | }, |
| 849 | { |
| 850 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "last key in path is an index to value in array (formatted json)", |
| 851 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{ |
| 852 | "a": [ |
| 853 | { |
| 854 | "b": 1 |
| 855 | }, |
| 856 | {"b":"2"}, |
| 857 | 3 |
| 858 | ], |
| 859 | "c": { |
| 860 | "c": [ |
| 861 | 1, |
| 862 | 2 |
| 863 | ] |
| 864 | } |
| 865 | }`, |
| 866 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "[1]"}, |
| 867 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 868 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `{"b":"2"}`, |
| 869 | }, |
| 870 | { |
| 871 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: "key in path is index (formatted json)", |
| 872 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{ |
| 873 | "a": [ |
| 874 | {"b": 1}, |
| 875 | {"b": "2"}, |
| 876 | 3 |
| 877 | ], |
| 878 | "c": { |
| 879 | "c": [ |
| 880 | 1, |
| 881 | 2 |
| 882 | ] |
| 883 | } |
| 884 | }`, |
| 885 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "[0]", "b"}, |
| 886 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 887 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `1`, |
| 888 | }, |
| 889 | { |
| 890 | // Issue #178: Crash in searchKeys |
| 891 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `invalid json`, |
| 892 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{{{"":`, |
| 893 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b"}, |
| 894 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 895 | }, |
| 896 | { |
| 897 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `opening brace instead of closing and without key`, |
| 898 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a":1{`, |
| 899 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"b"}, |
| 900 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 901 | }, |
| 902 | } |
| 903 | |
| 904 | var getIntTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getIntTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 905 | { |
| 906 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read numeric value as number`, |
| 907 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": 1}`, |
| 908 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 909 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 910 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: int64(1), |
| 911 | }, |
| 912 | { |
| 913 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read numeric value as number in formatted JSON`, |
| 914 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\"a\": \"b\", \"c\": 1 \n}", |
| 915 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 916 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 917 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: int64(1), |
| 918 | }, |
| 919 | { // Issue #138: overflow detection |
| 920 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Fails because of overflow`, |
| 921 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"p":9223372036854775808}`, |
| 922 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"p"}, |
| 923 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 924 | }, |
| 925 | { // Issue #138: overflow detection |
| 926 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Fails because of underflow`, |
| 927 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"p":-9223372036854775809}`, |
| 928 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"p"}, |
| 929 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 930 | }, |
| 931 | { |
| 932 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read non-numeric value as integer`, |
| 933 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": "d"}`, |
| 934 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 935 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 936 | }, |
| 937 | { |
| 938 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `null test`, |
| 939 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": null}`, |
| 940 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 941 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 942 | }, |
| 943 | } |
| 944 | |
| 945 | var getFloatTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getFloatTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 946 | { |
| 947 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read numeric value as number`, |
| 948 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": 1.123}`, |
| 949 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 950 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 951 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: float64(1.123), |
| 952 | }, |
| 953 | { |
| 954 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read numeric value as number in formatted JSON`, |
| 955 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\"a\": \"b\", \"c\": 23.41323 \n}", |
| 956 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 957 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 958 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: float64(23.41323), |
| 959 | }, |
| 960 | { |
| 961 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read non-numeric value as float`, |
| 962 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": "d"}`, |
| 963 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 964 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 965 | }, |
| 966 | { |
| 967 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `null test`, |
| 968 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": null}`, |
| 969 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 970 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 971 | }, |
| 972 | } |
| 973 | |
| 974 | var getStringTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getStringTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 975 | { |
| 976 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Translate Unicode symbols`, |
| 977 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "test"}`, |
| 978 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 979 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 980 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `test`, |
| 981 | }, |
| 982 | { |
| 983 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Translate Unicode symbols`, |
| 984 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "15\u00b0C"}`, |
| 985 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 986 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 987 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `15°C`, |
| 988 | }, |
| 989 | { |
| 990 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Translate supplementary Unicode symbols`, |
| 991 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "\uD83D\uDE03"}`, // Smiley face (UTF16 surrogate pair) |
| 992 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 993 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 994 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "\U0001F603", // Smiley face |
| 995 | }, |
| 996 | { |
| 997 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Translate escape symbols`, |
| 998 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "\\\""}`, |
| 999 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1000 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1001 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `\"`, |
| 1002 | }, |
| 1003 | { |
| 1004 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `key and value with whitespace escapes`, |
| 1005 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"key\b\f\n\r\tkey":"value\b\f\n\r\tvalue"}`, |
| 1006 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"key\b\f\n\r\tkey"}, |
| 1007 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1008 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: "value\b\f\n\r\tvalue", // value is unescaped since this is GetString() |
| 1009 | }, |
| 1010 | { // This test checks we avoid an infinite loop for certain malformed JSON. We don't check for all malformed JSON as it would reduce performance. |
| 1011 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed with double quotes`, |
| 1012 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a"":1}`, |
| 1013 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 1014 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1015 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: ``, |
| 1016 | }, |
| 1017 | { // More malformed JSON testing, to be sure we avoid an infinite loop. |
| 1018 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed with double quotes, and path does not exist`, |
| 1019 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"z":123,"y":{"x":7,"w":0},"v":{"u":"t","s":"r","q":0,"p":1558051800},"a":"b","c":"2016-11-02T20:10:11Z","d":"e","f":"g","h":{"i":"j""},"k":{"l":"m"}}`, |
| 1020 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"o"}, |
| 1021 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1022 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: ``, |
| 1023 | }, |
| 1024 | { |
| 1025 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read non-string as string`, |
| 1026 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": true}`, |
| 1027 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1028 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 1029 | }, |
| 1030 | { |
| 1031 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `empty array index`, |
| 1032 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `[""]`, |
| 1033 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"[]"}, |
| 1034 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1035 | }, |
| 1036 | { |
| 1037 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `malformed array index`, |
| 1038 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `[""]`, |
| 1039 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"["}, |
| 1040 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1041 | }, |
| 1042 | { |
| 1043 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `null test`, |
| 1044 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": null}`, |
| 1045 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1046 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 1047 | }, |
| 1048 | } |
| 1049 | |
| 1050 | var getUnsafeStringTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getUnsafeStringTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 1051 | { |
| 1052 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read empty string as unsafe string`, |
| 1053 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": ""}`, |
| 1054 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1055 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1056 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: ``, |
| 1057 | }, |
| 1058 | { |
| 1059 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Do not translate Unicode symbols`, |
| 1060 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "test"}`, |
| 1061 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1062 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1063 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `test`, |
| 1064 | }, |
| 1065 | { |
| 1066 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Do not translate Unicode symbols`, |
| 1067 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "15\u00b0C"}`, |
| 1068 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1069 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1070 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `15\u00b0C`, |
| 1071 | }, |
| 1072 | { |
| 1073 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Do not translate supplementary Unicode symbols`, |
| 1074 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "\uD83D\uDE03"}`, // Smiley face (UTF16 surrogate pair) |
| 1075 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1076 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1077 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `\uD83D\uDE03`, // Smiley face |
| 1078 | }, |
| 1079 | { |
| 1080 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `Do not translate escape symbols`, |
| 1081 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "\\\""}`, |
| 1082 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1083 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1084 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `\\\"`, |
| 1085 | }, |
| 1086 | { |
| 1087 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read boolean token as unsafe string`, |
| 1088 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": true}`, |
| 1089 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1090 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1091 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: `true`, |
| 1092 | }, |
| 1093 | { |
| 1094 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `missing key returns not found for unsafe string`, |
| 1095 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"c": "test"}`, |
| 1096 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"missing"}, |
| 1097 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1098 | }, |
| 1099 | } |
| 1100 | |
| 1101 | var getBoolTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getBoolTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 1102 | { |
| 1103 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read boolean true as boolean`, |
| 1104 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": true}`, |
| 1105 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1106 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1107 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: true, |
| 1108 | }, |
| 1109 | { |
| 1110 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `boolean true in formatted JSON`, |
| 1111 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\"a\": \"b\", \"c\": true \n}", |
| 1112 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1113 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1114 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: true, |
| 1115 | }, |
| 1116 | { |
| 1117 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read boolean false as boolean`, |
| 1118 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": false}`, |
| 1119 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1120 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1121 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: false, |
| 1122 | }, |
| 1123 | { |
| 1124 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `boolean true in formatted JSON`, |
| 1125 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\"a\": \"b\", \"c\": false \n}", |
| 1126 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1127 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1128 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: false, |
| 1129 | }, |
| 1130 | { |
| 1131 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read fake boolean true`, |
| 1132 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": txyz}`, |
| 1133 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 1134 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 1135 | }, |
| 1136 | { |
| 1137 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read fake boolean false`, |
| 1138 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": fwxyz}`, |
| 1139 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 1140 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 1141 | }, |
| 1142 | { |
| 1143 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read boolean true with whitespace and another key`, |
| 1144 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: "{\r\t\n \"a\"\r\t\n :\r\t\n true\r\t\n ,\r\t\n \"b\": 1}", |
| 1145 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 1146 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1147 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: true, |
| 1148 | }, |
| 1149 | { |
| 1150 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `null test`, |
| 1151 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": "b", "c": null}`, |
| 1152 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"c"}, |
| 1153 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: false, |
| 1154 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr.: true, |
| 1155 | }, |
| 1156 | } |
| 1157 | |
| 1158 | var getArrayTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getArrayTests. = []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#{ |
| 1159 | { |
| 1160 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read array of simple values`, |
| 1161 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b":[1,2,3,4]}}`, |
| 1162 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b"}, |
| 1163 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1164 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: []string{`1`, `2`, `3`, `4`}, |
| 1165 | }, |
| 1166 | { |
| 1167 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read array via empty path`, |
| 1168 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `[1,2,3,4]`, |
| 1169 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{}, |
| 1170 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1171 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: []string{`1`, `2`, `3`, `4`}, |
| 1172 | }, |
| 1173 | { |
| 1174 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read array of objects`, |
| 1175 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": { "b":[{"x":1},{"x":2},{"x":3},{"x":4}]}}`, |
| 1176 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a", "b"}, |
| 1177 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1178 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: []string{`{"x":1}`, `{"x":2}`, `{"x":3}`, `{"x":4}`}, |
| 1179 | }, |
| 1180 | { |
| 1181 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.: `read nested array`, |
| 1182 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.: `{"a": [[[1]],[[2]]]}`, |
| 1183 | pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path.: []string{"a"}, |
| 1184 | isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound.: true, |
| 1185 | datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data.: []string{`[[1]]`, `[[2]]`}, |
| 1186 | }, |
| 1187 | } |
| 1188 | |
| 1189 | // checkFoundAndNoError checks the dataType and error return from Get*() against the test case expectations. |
| 1190 | // Returns true the test should proceed to checking the actual data returned from Get*(), or false if the test is finished. |
| 1191 | // Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011. |
| 1192 | func getTestCheckFoundAndNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getTestCheckFoundAndNoError().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, jtype ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, value interface{}, err error) bool { |
| 1193 | isFound := (err != KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) |
| 1194 | isErr := (err != nil && err != KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) |
| 1195 | |
| 1196 | if test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr. != isErr { |
| 1197 | // If the call didn't match the error expectation, fail |
| 1198 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Value: %v", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc., test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isErr., isErr, err, value) |
| 1199 | return false |
| 1200 | } else if isErr { |
| 1201 | // Else, if there was an error, don't fail and don't check isFound or the value |
| 1202 | return false |
| 1203 | } else if test.isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound. != isFound { |
| 1204 | // Else, if the call didn't match the is-found expectation, fail |
| 1205 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' isFound mismatch: expected %t, obtained %t", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc., test.isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#isFound., isFound) |
| 1206 | return false |
| 1207 | } else if !isFound { |
| 1208 | // Else, if no value was found, don't fail and don't check the value |
| 1209 | return false |
| 1210 | } else { |
| 1211 | // Else, there was no error and a value was found, so check the value |
| 1212 | return true |
| 1213 | } |
| 1214 | } |
| 1215 | |
| 1216 | // Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011. |
| 1217 | func runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, tests []GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, runner func(GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (interface{}, ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, error), resultChecker func(GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, interface{}) (bool, interface{})) { |
| 1218 | for _, test := range tests { |
| 1219 | if activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. != "" && test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc. != activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. { |
| 1220 | continue |
| 1221 | } |
| 1222 | |
| 1223 | fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.13 fmt/Println().("Running:", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc.) |
| 1224 | |
| 1225 | value, dataType, err := runner(test) |
| 1226 | |
| 1227 | if getTestCheckFoundAndNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getTestCheckFoundAndNoError().(t, testKind, test, dataType, value, err) { |
| 1228 | if test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data. == nil { |
| 1229 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("MALFORMED TEST: %v", test) |
| 1230 | continue |
| 1231 | } |
| 1232 | |
| 1233 | if ok, expected := resultChecker(test, value); !ok { |
| 1234 | if expectedBytes, ok := expected.([]byte); ok { |
| 1235 | expected = string(expectedBytes) |
| 1236 | } |
| 1237 | if valueBytes, ok := value.([]byte); ok { |
| 1238 | value = string(valueBytes) |
| 1239 | } |
| 1240 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#desc., expected, value) |
| 1241 | } |
| 1242 | } |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | // Test helper for SYS-REQ-009. |
| 1247 | func setTestCheckFoundAndNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/setTestCheckFoundAndNoError().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, test SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#, value interface{}, err error) bool { |
| 1248 | isFound := (err != KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) |
| 1249 | isErr := (err != nil && err != KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) |
| 1250 | |
| 1251 | if test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isErr. != isErr { |
| 1252 | // If the call didn't match the error expectation, fail |
| 1253 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Value: %v", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc., test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isErr., isErr, err, value) |
| 1254 | return false |
| 1255 | } else if isErr { |
| 1256 | // Else, if there was an error, don't fail and don't check isFound or the value |
| 1257 | return false |
| 1258 | } else if test.isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound. != isFound { |
| 1259 | // Else, if the call didn't match the is-found expectation, fail |
| 1260 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' isFound mismatch: expected %t, obtained %t", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc., test.isFoundscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#isFound., isFound) |
| 1261 | return false |
| 1262 | } else if !isFound { |
| 1263 | // Else, if no value was found, don't fail and don't check the value |
| 1264 | return false |
| 1265 | } else { |
| 1266 | // Else, there was no error and a value was found, so check the value |
| 1267 | return true |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | // Test helper for SYS-REQ-009. |
| 1272 | func runSetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runSetTests().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, tests []SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#, runner func(SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#) (interface{}, ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, error), resultChecker func(SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#, interface{}) (bool, interface{})) { |
| 1273 | for _, test := range tests { |
| 1274 | if activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. != "" && test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc. != activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. { |
| 1275 | continue |
| 1276 | } |
| 1277 | |
| 1278 | fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.13 fmt/Println().("Running:", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.) |
| 1279 | |
| 1280 | value, _, err := runner(test) |
| 1281 | |
| 1282 | if setTestCheckFoundAndNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/setTestCheckFoundAndNoError().(t, testKind, test, value, err) { |
| 1283 | if test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data. == nil { |
| 1284 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("MALFORMED TEST: %v", test) |
| 1285 | continue |
| 1286 | } |
| 1287 | |
| 1288 | if string(value.([]byte)) != test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data. { |
| 1289 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Unexpected result on %s test '%s'", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#desc.) |
| 1290 | t.Logscip-go gomod github.com/golang/go/src go1.13 testing/common#Log().("Got: ", string(value.([]byte))) |
| 1291 | t.Logscip-go gomod github.com/golang/go/src go1.13 testing/common#Log().("Expected:", test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data.) |
| 1292 | t.Logscip-go gomod github.com/golang/go/src go1.13 testing/common#Log().("Error: ", err) |
| 1293 | } |
| 1294 | } |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | // Test helper for SYS-REQ-010. |
| 1299 | func runDeleteTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runDeleteTests().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, tests []DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#, runner func(DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#) (interface{}, []byte), resultChecker func(DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#, interface{}) (bool, interface{})) { |
| 1300 | for _, test := range tests { |
| 1301 | if activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. != "" && test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc. != activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. { |
| 1302 | continue |
| 1303 | } |
| 1304 | |
| 1305 | original := make([]byte, len(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.)) |
| 1306 | copy(original, test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.) |
| 1307 | |
| 1308 | fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.13 fmt/Println().("Running:", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc.) |
| 1309 | |
| 1310 | value, bytes := runner(test) |
| 1311 | |
| 1312 | if string(original) != string(bytes) { |
| 1313 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ORIGINAL DATA MALFORMED: %v, %v", string(original), string(bytes)) |
| 1314 | continue |
| 1315 | } |
| 1316 | |
| 1317 | if test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data. == nil { |
| 1318 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("MALFORMED TEST: %v", test) |
| 1319 | continue |
| 1320 | } |
| 1321 | |
| 1322 | if ok, expected := resultChecker(test, value); !ok { |
| 1323 | if expectedBytes, ok := expected.([]byte); ok { |
| 1324 | expected = string(expectedBytes) |
| 1325 | } |
| 1326 | if valueBytes, ok := value.([]byte); ok { |
| 1327 | value = string(valueBytes) |
| 1328 | } |
| 1329 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#desc., expected, value) |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | // Verifies: SYS-REQ-010 [example] |
| 1335 | // MCDC SYS-REQ-010: delete_path_is_provided=F, delete_returns_empty_document_without_path=T => TRUE |
| 1336 | // Verifies: SYS-REQ-033 [example] |
| 1337 | // MCDC SYS-REQ-033: delete_path_is_provided=T, delete_target_exists=T, delete_returns_document_without_target=T => TRUE |
| 1338 | // Verifies: SYS-REQ-034 [example] |
| 1339 | // MCDC SYS-REQ-034: delete_path_is_provided=T, delete_target_exists=F, delete_input_is_unusable_for_requested_path=F, delete_preserves_input_when_target_missing=T => TRUE |
| 1340 | func TestDeletescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestDelete().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1341 | runDeleteTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runDeleteTests().(t, "Delete()", deleteTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/deleteTests., |
| 1342 | func(test DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#) (interface{}, []byte) { |
| 1343 | ba := []byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#json.) |
| 1344 | return Deletescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Delete().(ba, test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#path....), ba |
| 1345 | }, |
| 1346 | func(test DeleteTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#, value interface{}) (bool, interface{}) { |
| 1347 | expected := []byte(test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/DeleteTest#data..(string)) |
| 1348 | return bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(expected, value.([]byte)), expected |
| 1349 | }, |
| 1350 | ) |
| 1351 | } |
| 1352 | |
| 1353 | // Verifies: SYS-REQ-001 [example] |
| 1354 | // MCDC SYS-REQ-001: addressed_path_exists=F, json_input_is_well_formed=T, key_path_is_provided=T, returns_existing_path_lookup_result=F => TRUE |
| 1355 | // MCDC SYS-REQ-001: addressed_path_exists=T, json_input_is_well_formed=F, key_path_is_provided=T, returns_existing_path_lookup_result=F => TRUE |
| 1356 | // MCDC SYS-REQ-001: addressed_path_exists=T, json_input_is_well_formed=T, key_path_is_provided=F, returns_existing_path_lookup_result=F => TRUE |
| 1357 | // MCDC SYS-REQ-001: addressed_path_exists=T, json_input_is_well_formed=T, key_path_is_provided=T, returns_existing_path_lookup_result=F => FALSE |
| 1358 | // MCDC SYS-REQ-001: addressed_path_exists=T, json_input_is_well_formed=T, key_path_is_provided=T, returns_existing_path_lookup_result=T => TRUE |
| 1359 | func TestGetscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGet().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1360 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "Get()", getTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getTests., |
| 1361 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1362 | value, dataType, _, err = Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1363 | return |
| 1364 | }, |
| 1365 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1366 | expected := []byte(test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(string)) |
| 1367 | return bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(expected, value.([]byte)), expected |
| 1368 | }, |
| 1369 | ) |
| 1370 | } |
| 1371 | |
| 1372 | // Verifies: SYS-REQ-016 [boundary] |
| 1373 | // MCDC SYS-REQ-016: N/A |
| 1374 | // Verifies: SYS-REQ-017 [boundary] |
| 1375 | // MCDC SYS-REQ-017: N/A |
| 1376 | // Verifies: SYS-REQ-018 [boundary] |
| 1377 | // MCDC SYS-REQ-018: N/A |
| 1378 | // Verifies: SYS-REQ-019 [boundary] |
| 1379 | // MCDC SYS-REQ-019: N/A |
| 1380 | // Verifies: SYS-REQ-020 [boundary] |
| 1381 | // MCDC SYS-REQ-020: N/A |
| 1382 | // Verifies: SYS-REQ-021 [boundary] |
| 1383 | // MCDC SYS-REQ-021: N/A |
| 1384 | // Verifies: SYS-REQ-022 [boundary] |
| 1385 | // MCDC SYS-REQ-022: N/A |
| 1386 | // Verifies: SYS-REQ-023 [boundary] |
| 1387 | // MCDC SYS-REQ-023: N/A |
| 1388 | // Verifies: SYS-REQ-024 [boundary] |
| 1389 | // MCDC SYS-REQ-024: N/A |
| 1390 | // Verifies: SYS-REQ-025 [boundary] |
| 1391 | // MCDC SYS-REQ-025: N/A |
| 1392 | // Verifies: SYS-REQ-026 [boundary] |
| 1393 | // MCDC SYS-REQ-026: N/A |
| 1394 | // Verifies: SYS-REQ-027 [boundary] |
| 1395 | // MCDC SYS-REQ-027: N/A |
| 1396 | func TestGetRequirementSlicesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetRequirementSlices().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1397 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("well formed missing path returns not found", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1398 | value, dataType, offset, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":"b"}`), "missing") |
| 1399 | if !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) { |
| 1400 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected KeyPathNotFoundError, got %v", err) |
| 1401 | } |
| 1402 | if dataType != NotExistscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/NotExist. || offset != -1 || value != nil { |
| 1403 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected not-found tuple, got value=%v type=%v offset=%d", value, dataType, offset) |
| 1404 | } |
| 1405 | }) |
| 1406 | |
| 1407 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("incomplete input returns parse error", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1408 | if _, _, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":`), "a"); err == nil { |
| 1409 | t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().("expected parse-related error for incomplete input") |
| 1410 | } |
| 1411 | }) |
| 1412 | |
| 1413 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("no key path returns closest root value", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1414 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":1}`)) |
| 1415 | if err != nil { |
| 1416 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Get without key path returned error: %v", err) |
| 1417 | } |
| 1418 | if dataType != Objectscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Object. || string(value) != `{"a":1}` { |
| 1419 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected root value result: value=%s type=%v", string(value), dataType) |
| 1420 | } |
| 1421 | }) |
| 1422 | |
| 1423 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("empty input with key path returns not found", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1424 | _, dataType, offset, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(""), "a") |
| 1425 | if !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) { |
| 1426 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected KeyPathNotFoundError, got %v", err) |
| 1427 | } |
| 1428 | if dataType != NotExistscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/NotExist. || offset != -1 { |
| 1429 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected empty-input not-found tuple, got type=%v offset=%d", dataType, offset) |
| 1430 | } |
| 1431 | }) |
| 1432 | |
| 1433 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("object key lookup respects current scope", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1434 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":{"b":1},"b":2}`), "a", "b") |
| 1435 | if err != nil { |
| 1436 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("nested object lookup returned error: %v", err) |
| 1437 | } |
| 1438 | if dataType != Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number. || string(value) != "1" { |
| 1439 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected nested object lookup result: value=%s type=%v", string(value), dataType) |
| 1440 | } |
| 1441 | }) |
| 1442 | |
| 1443 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("array index lookup returns in-bounds element", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1444 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":[{"b":1},"foo",3]}`), "a", "[1]") |
| 1445 | if err != nil { |
| 1446 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("array index lookup returned error: %v", err) |
| 1447 | } |
| 1448 | if dataType != Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String. || string(value) != "foo" { |
| 1449 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected array lookup result: value=%s type=%v", string(value), dataType) |
| 1450 | } |
| 1451 | }) |
| 1452 | |
| 1453 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("invalid array index syntax returns not found", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1454 | if _, _, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":[1,2]}`), "a", "["); !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) { |
| 1455 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected KeyPathNotFoundError for malformed array index, got %v", err) |
| 1456 | } |
| 1457 | }) |
| 1458 | |
| 1459 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("out of bounds array index returns not found", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1460 | if _, _, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":[1,2]}`), "a", "[9]"); !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, KeyPathNotFoundErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/KeyPathNotFoundError.) { |
| 1461 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected KeyPathNotFoundError for out-of-bounds array index, got %v", err) |
| 1462 | } |
| 1463 | }) |
| 1464 | |
| 1465 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("escaped keys are matched after decoding", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1466 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a\u00B0b":1}`), "a°b") |
| 1467 | if err != nil { |
| 1468 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("escaped-key lookup returned error: %v", err) |
| 1469 | } |
| 1470 | if dataType != Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number. || string(value) != "1" { |
| 1471 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected escaped-key lookup result: value=%s type=%v", string(value), dataType) |
| 1472 | } |
| 1473 | }) |
| 1474 | |
| 1475 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("string results are unquoted but not unescaped", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1476 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":"line\nbreak"}`), "a") |
| 1477 | if err != nil { |
| 1478 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("string lookup returned error: %v", err) |
| 1479 | } |
| 1480 | if dataType != Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String. || string(value) != `line\nbreak` { |
| 1481 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected raw string result: value=%s type=%v", string(value), dataType) |
| 1482 | } |
| 1483 | }) |
| 1484 | |
| 1485 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("best effort lookup succeeds when malformed data is outside addressed token", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1486 | value, dataType, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":1]`), "a") |
| 1487 | if err != nil { |
| 1488 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("best-effort lookup returned error: %v", err) |
| 1489 | } |
| 1490 | if dataType != Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number. || string(value) != "1" { |
| 1491 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("unexpected best-effort lookup result: value=%s type=%v", string(value), dataType) |
| 1492 | } |
| 1493 | }) |
| 1494 | |
| 1495 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("invalid addressed token shape returns value type error", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1496 | if _, _, _, err := Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(`{"a":u}`), "a"); !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, UnknownValueTypeErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/UnknownValueTypeError.) { |
| 1497 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected UnknownValueTypeError, got %v", err) |
| 1498 | } |
| 1499 | }) |
| 1500 | } |
| 1501 | |
| 1502 | // Verifies: SYS-REQ-002 [example] |
| 1503 | // MCDC SYS-REQ-002: addressed_value_is_string=F, raw_string_token_is_well_formed=T, returns_getstring_decoded_value=F => TRUE |
| 1504 | // MCDC SYS-REQ-002: addressed_value_is_string=T, raw_string_token_is_well_formed=F, returns_getstring_decoded_value=F => TRUE |
| 1505 | // MCDC SYS-REQ-002: addressed_value_is_string=T, raw_string_token_is_well_formed=T, returns_getstring_decoded_value=F => FALSE |
| 1506 | // MCDC SYS-REQ-002: addressed_value_is_string=T, raw_string_token_is_well_formed=T, returns_getstring_decoded_value=T => TRUE |
| 1507 | func TestGetStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetString().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1508 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "GetString()", getStringTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getStringTests., |
| 1509 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1510 | value, err = GetStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetString().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1511 | return value, Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., err |
| 1512 | }, |
| 1513 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1514 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(string) |
| 1515 | return expected == value.(string), expected |
| 1516 | }, |
| 1517 | ) |
| 1518 | } |
| 1519 | |
| 1520 | // Verifies: SYS-REQ-011 [example] |
| 1521 | // MCDC SYS-REQ-011: addressed_value_is_string=F, returns_unsafe_string_view=F => TRUE |
| 1522 | // MCDC SYS-REQ-011: addressed_value_is_string=T, returns_unsafe_string_view=F => FALSE |
| 1523 | // MCDC SYS-REQ-011: addressed_value_is_string=T, returns_unsafe_string_view=T => TRUE |
| 1524 | func TestGetUnsafeStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetUnsafeString().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1525 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "GetUnsafeString()", getUnsafeStringTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getUnsafeStringTests., |
| 1526 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1527 | value, err = GetUnsafeStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetUnsafeString().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1528 | return value, Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., err |
| 1529 | }, |
| 1530 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1531 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(string) |
| 1532 | return expected == value.(string), expected |
| 1533 | }, |
| 1534 | ) |
| 1535 | } |
| 1536 | |
| 1537 | // Verifies: SYS-REQ-003 [example] |
| 1538 | // MCDC SYS-REQ-003: addressed_value_is_number=F, raw_number_token_is_integer_parseable=T, returns_getint_value=F => TRUE |
| 1539 | // MCDC SYS-REQ-003: addressed_value_is_number=T, raw_number_token_is_integer_parseable=F, returns_getint_value=F => TRUE |
| 1540 | // MCDC SYS-REQ-003: addressed_value_is_number=T, raw_number_token_is_integer_parseable=T, returns_getint_value=F => FALSE |
| 1541 | // MCDC SYS-REQ-003: addressed_value_is_number=T, raw_number_token_is_integer_parseable=T, returns_getint_value=T => TRUE |
| 1542 | func TestGetIntscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetInt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1543 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "GetInt()", getIntTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getIntTests., |
| 1544 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1545 | value, err = GetIntscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetInt().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1546 | return value, Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., err |
| 1547 | }, |
| 1548 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1549 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(int64) |
| 1550 | return expected == value.(int64), expected |
| 1551 | }, |
| 1552 | ) |
| 1553 | } |
| 1554 | |
| 1555 | // Verifies: SYS-REQ-004 [example] |
| 1556 | // MCDC SYS-REQ-004: addressed_value_is_number=F, raw_number_token_is_float_parseable=T, returns_getfloat_value=F => TRUE |
| 1557 | // MCDC SYS-REQ-004: addressed_value_is_number=T, raw_number_token_is_float_parseable=F, returns_getfloat_value=F => TRUE |
| 1558 | // MCDC SYS-REQ-004: addressed_value_is_number=T, raw_number_token_is_float_parseable=T, returns_getfloat_value=F => FALSE |
| 1559 | // MCDC SYS-REQ-004: addressed_value_is_number=T, raw_number_token_is_float_parseable=T, returns_getfloat_value=T => TRUE |
| 1560 | func TestGetFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetFloat().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1561 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "GetFloat()", getFloatTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getFloatTests., |
| 1562 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1563 | value, err = GetFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetFloat().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1564 | return value, Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., err |
| 1565 | }, |
| 1566 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1567 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(float64) |
| 1568 | return expected == value.(float64), expected |
| 1569 | }, |
| 1570 | ) |
| 1571 | } |
| 1572 | |
| 1573 | // Verifies: SYS-REQ-005 [example] |
| 1574 | // MCDC SYS-REQ-005: addressed_value_is_boolean=F, raw_boolean_token_is_well_formed=T, returns_getboolean_value=F => TRUE |
| 1575 | // MCDC SYS-REQ-005: addressed_value_is_boolean=T, raw_boolean_token_is_well_formed=F, returns_getboolean_value=F => TRUE |
| 1576 | // MCDC SYS-REQ-005: addressed_value_is_boolean=T, raw_boolean_token_is_well_formed=T, returns_getboolean_value=F => FALSE |
| 1577 | // MCDC SYS-REQ-005: addressed_value_is_boolean=T, raw_boolean_token_is_well_formed=T, returns_getboolean_value=T => TRUE |
| 1578 | func TestGetBooleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetBoolean().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1579 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "GetBoolean()", getBoolTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getBoolTests., |
| 1580 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1581 | value, err = GetBooleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetBoolean().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1582 | return value, Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., err |
| 1583 | }, |
| 1584 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1585 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..(bool) |
| 1586 | return expected == value.(bool), expected |
| 1587 | }, |
| 1588 | ) |
| 1589 | } |
| 1590 | |
| 1591 | // Verifies: SYS-REQ-001 [example] |
| 1592 | // MCDC SYS-REQ-001: N/A |
| 1593 | func TestGetSlicescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestGetSlice().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1594 | runGetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runGetTests().(t, "Get()-for-arrays", getArrayTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/getArrayTests., |
| 1595 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1596 | value, dataType, _, err = Getscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Get().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#json.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#path....) |
| 1597 | return |
| 1598 | }, |
| 1599 | func(test GetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#, value interface{}) (bool, interface{}) { |
| 1600 | expected := test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/GetTest#data..([]string) |
| 1601 | return reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(expected, toStringArrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/toStringArray().(value.([]byte))), expected |
| 1602 | }, |
| 1603 | ) |
| 1604 | } |
| 1605 | |
| 1606 | // Verifies: SYS-REQ-006 [example] |
| 1607 | // MCDC SYS-REQ-006: addressed_array_is_empty=F, addressed_array_is_well_formed=T, array_callback_receives_elements_in_order=F => FALSE |
| 1608 | // MCDC SYS-REQ-006: addressed_array_is_empty=F, addressed_array_is_well_formed=T, array_callback_receives_elements_in_order=T => TRUE |
| 1609 | func TestArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestArrayEach().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1610 | mock := []byte(`{"a": { "b":[{"x": 1} ,{"x":2},{ "x":3}, {"x":4} ]}}`) |
| 1611 | count := 0 |
| 1612 | |
| 1613 | ArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ArrayEach().(mock, func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, offset int, err error) { |
| 1614 | count++ |
| 1615 | |
| 1616 | switch count { |
| 1617 | case 1: |
| 1618 | if string(value) != `{"x": 1}` { |
| 1619 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong first item: %s", string(value)) |
| 1620 | } |
| 1621 | case 2: |
| 1622 | if string(value) != `{"x":2}` { |
| 1623 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong second item: %s", string(value)) |
| 1624 | } |
| 1625 | case 3: |
| 1626 | if string(value) != `{ "x":3}` { |
| 1627 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong third item: %s", string(value)) |
| 1628 | } |
| 1629 | case 4: |
| 1630 | if string(value) != `{"x":4}` { |
| 1631 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong forth item: %s", string(value)) |
| 1632 | } |
| 1633 | default: |
| 1634 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should process only 4 items") |
| 1635 | } |
| 1636 | }, "a", "b") |
| 1637 | } |
| 1638 | |
| 1639 | // Verifies: SYS-REQ-029 [boundary] |
| 1640 | // MCDC SYS-REQ-029: addressed_array_is_well_formed=F, malformed_array_input_returns_error=T => TRUE |
| 1641 | func TestArrayEachWithWhiteSpacescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestArrayEachWithWhiteSpace().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1642 | // Issue #159 |
| 1643 | count := 0 |
| 1644 | funcError := func([]byte, ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, int, error) { t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Run func not allow") } |
| 1645 | funcSuccess := func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, index int, err error) { |
| 1646 | count++ |
| 1647 | |
| 1648 | switch count { |
| 1649 | case 1: |
| 1650 | if string(value) != `AAA` { |
| 1651 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong first item: %s", string(value)) |
| 1652 | } |
| 1653 | case 2: |
| 1654 | if string(value) != `BBB` { |
| 1655 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong second item: %s", string(value)) |
| 1656 | } |
| 1657 | case 3: |
| 1658 | if string(value) != `CCC` { |
| 1659 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Wrong third item: %s", string(value)) |
| 1660 | } |
| 1661 | default: |
| 1662 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should process only 3 items") |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | type args struct { |
| 1667 | data []byte |
| 1668 | cb func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, offset int, err error) |
| 1669 | keys []string |
| 1670 | } |
| 1671 | tests := []struct { |
| 1672 | name string |
| 1673 | args args |
| 1674 | wantErr bool |
| 1675 | }{ |
| 1676 | {"Array with white space", args{[]byte(` ["AAA", "BBB", "CCC"]`), funcSuccess, []string{}}, false}, |
| 1677 | {"Array with only one character after white space", args{[]byte(` 1`), funcError, []string{}}, true}, |
| 1678 | {"Only white space", args{[]byte(` `), funcError, []string{}}, true}, |
| 1679 | } |
| 1680 | for _, tt := range tests { |
| 1681 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1682 | _, err := ArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ArrayEach().(tt.args.data, tt.args.cb, tt.args.keys...) |
| 1683 | if (err != nil) != tt.wantErr { |
| 1684 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ArrayEach() error = %v, wantErr %v", err, tt.wantErr) |
| 1685 | return |
| 1686 | } |
| 1687 | }) |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | // Verifies: SYS-REQ-028 [boundary] |
| 1692 | // MCDC SYS-REQ-028: addressed_array_is_empty=T, addressed_array_is_well_formed=T, empty_array_produces_no_callbacks=T => TRUE |
| 1693 | func TestArrayEachEmptyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestArrayEachEmpty().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1694 | funcError := func([]byte, ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, int, error) { t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Run func not allow") } |
| 1695 | |
| 1696 | type args struct { |
| 1697 | data []byte |
| 1698 | cb func(value []byte, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, offset int, err error) |
| 1699 | keys []string |
| 1700 | } |
| 1701 | tests := []struct { |
| 1702 | name string |
| 1703 | args args |
| 1704 | wantOffset int |
| 1705 | wantErr bool |
| 1706 | }{ |
| 1707 | {"Empty array", args{[]byte("[]"), funcError, []string{}}, 1, false}, |
| 1708 | {"Empty array with space", args{[]byte("[ ]"), funcError, []string{}}, 2, false}, |
| 1709 | {"Empty array with \n", args{[]byte("[\n]"), funcError, []string{}}, 2, false}, |
| 1710 | {"Empty field array", args{[]byte("{\"data\": []}"), funcError, []string{"data"}}, 10, false}, |
| 1711 | {"Empty field array with space", args{[]byte("{\"data\": [ ]}"), funcError, []string{"data"}}, 11, false}, |
| 1712 | {"Empty field array with \n", args{[]byte("{\"data\": [\n]}"), funcError, []string{"data"}}, 11, false}, |
| 1713 | } |
| 1714 | for _, tt := range tests { |
| 1715 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1716 | gotOffset, err := ArrayEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ArrayEach().(tt.args.data, tt.args.cb, tt.args.keys...) |
| 1717 | if (err != nil) != tt.wantErr { |
| 1718 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ArrayEach() error = %v, wantErr %v", err, tt.wantErr) |
| 1719 | return |
| 1720 | } |
| 1721 | if gotOffset != tt.wantOffset { |
| 1722 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ArrayEach() = %v, want %v", gotOffset, tt.wantOffset) |
| 1723 | } |
| 1724 | }) |
| 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | type keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry# struct { |
| 1729 | keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key. string |
| 1730 | valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value. string |
| 1731 | valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType. ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType# |
| 1732 | } |
| 1733 | |
| 1734 | // Test helper for SYS-REQ-007. |
| 1735 | func (kv keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#) Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#String().() string { |
| 1736 | return fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("[%s: %s (%s)]", kv.keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key., kv.valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value., kv.valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.) |
| 1737 | } |
| 1738 | |
| 1739 | type ObjectEachTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest# struct { |
| 1740 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc. string |
| 1741 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json. string |
| 1742 | |
| 1743 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr. bool |
| 1744 | entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries. []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry# |
| 1745 | } |
| 1746 | |
| 1747 | var objectEachTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/objectEachTests. = []ObjectEachTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#{ |
| 1748 | { |
| 1749 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "empty object", |
| 1750 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{}`, |
| 1751 | entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.: []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{}, |
| 1752 | }, |
| 1753 | { |
| 1754 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "single key-value object", |
| 1755 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key": "value"}`, |
| 1756 | entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.: []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1757 | {"key", "value", Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String.}, |
| 1758 | }, |
| 1759 | }, |
| 1760 | { |
| 1761 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "multiple key-value object with many value types", |
| 1762 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{ |
| 1763 | "key1": null, |
| 1764 | "key2": true, |
| 1765 | "key3": 1.23, |
| 1766 | "key4": "string value", |
| 1767 | "key5": [1,2,3], |
| 1768 | "key6": {"a":"b"} |
| 1769 | }`, |
| 1770 | entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.: []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1771 | {"key1", "null", Nullscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Null.}, |
| 1772 | {"key2", "true", Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean.}, |
| 1773 | {"key3", "1.23", Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number.}, |
| 1774 | {"key4", "string value", Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String.}, |
| 1775 | {"key5", "[1,2,3]", Arrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Array.}, |
| 1776 | {"key6", `{"a":"b"}`, Objectscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Object.}, |
| 1777 | }, |
| 1778 | }, |
| 1779 | { |
| 1780 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "escaped key", |
| 1781 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key\"\\\/\b\f\n\r\t\u00B0": "value"}`, |
| 1782 | entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.: []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1783 | {"key\"\\/\b\f\n\r\t\u00B0", "value", Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String.}, |
| 1784 | }, |
| 1785 | }, |
| 1786 | // Error cases |
| 1787 | { |
| 1788 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "no object present", |
| 1789 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: ` \t\n\r`, |
| 1790 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1791 | }, |
| 1792 | { |
| 1793 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "unmatched braces 1", |
| 1794 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{`, |
| 1795 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1796 | }, |
| 1797 | { |
| 1798 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "unmatched braces 2", |
| 1799 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `}`, |
| 1800 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1801 | }, |
| 1802 | { |
| 1803 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "unmatched braces 3", |
| 1804 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `}{}`, |
| 1805 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1806 | }, |
| 1807 | { |
| 1808 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad key (number)", |
| 1809 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{123: "value"}`, |
| 1810 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1811 | }, |
| 1812 | { |
| 1813 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad key (unclosed quote)", |
| 1814 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key: 123}`, |
| 1815 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1816 | }, |
| 1817 | { |
| 1818 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad value (no value)", |
| 1819 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key":}`, |
| 1820 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1821 | }, |
| 1822 | { |
| 1823 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad value (bogus value)", |
| 1824 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key": notavalue}`, |
| 1825 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1826 | }, |
| 1827 | { |
| 1828 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad entry (missing colon)", |
| 1829 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key" "value"}`, |
| 1830 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1831 | }, |
| 1832 | { |
| 1833 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad entry (no trailing comma)", |
| 1834 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key": "value" "key2": "value2"}`, |
| 1835 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1836 | }, |
| 1837 | { |
| 1838 | descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc.: "bad entry (two commas)", |
| 1839 | jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.: `{"key": "value",, "key2": "value2"}`, |
| 1840 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr.: true, |
| 1841 | }, |
| 1842 | } |
| 1843 | |
| 1844 | // Verifies: SYS-REQ-031 [example] |
| 1845 | // MCDC SYS-REQ-031: addressed_object_is_well_formed=F, malformed_object_input_returns_error=T => TRUE |
| 1846 | // Verifies: SYS-REQ-030 [example] |
| 1847 | // MCDC SYS-REQ-030: addressed_object_is_empty=T, addressed_object_is_well_formed=T, empty_object_produces_no_entries=T => TRUE |
| 1848 | // Verifies: SYS-REQ-031 [example] |
| 1849 | // MCDC SYS-REQ-031: addressed_object_is_well_formed=F, malformed_object_input_returns_error=T => TRUE |
| 1850 | // Verifies: SYS-REQ-030 [example] |
| 1851 | // MCDC SYS-REQ-030: addressed_object_is_empty=T, addressed_object_is_well_formed=T, empty_object_produces_no_entries=T => TRUE |
| 1852 | // Verifies: SYS-REQ-007 [example] |
| 1853 | // MCDC SYS-REQ-007: addressed_object_is_empty=F, addressed_object_is_well_formed=T, object_callback_receives_entries=F => FALSE |
| 1854 | // MCDC SYS-REQ-007: addressed_object_is_empty=F, addressed_object_is_well_formed=T, object_callback_receives_entries=T => TRUE |
| 1855 | func TestObjectEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestObjectEach().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1856 | for _, test := range objectEachTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/objectEachTests. { |
| 1857 | if activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. != "" && test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc. != activeTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/activeTest. { |
| 1858 | continue |
| 1859 | } |
| 1860 | |
| 1861 | // Execute ObjectEach and capture all of the entries visited, in order |
| 1862 | var entries []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry# |
| 1863 | err := ObjectEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEach().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#json.), func(key, value []byte, valueType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, off int) error { |
| 1864 | entries = append(entries, keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1865 | keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key.: string(key), |
| 1866 | valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value.: string(value), |
| 1867 | valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.: valueType, |
| 1868 | }) |
| 1869 | return nil |
| 1870 | }) |
| 1871 | |
| 1872 | // Check the correctness of the result |
| 1873 | isErr := (err != nil) |
| 1874 | if test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr. != isErr { |
| 1875 | // If the call didn't match the error expectation, fail |
| 1876 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ObjectEach test '%s' isErr mismatch: expected %t, obtained %t (err %v)", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc., test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#isErr., isErr, err) |
| 1877 | } else if isErr { |
| 1878 | // Else, if there was an expected error, don't fail and don't check anything further |
| 1879 | } else if len(test.entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.) != len(entries) { |
| 1880 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ObjectEach test '%s' mismatch in number of key-value entries: expected %d, obtained %d (entries found: %s)", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc., len(test.entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.), len(entries), entries) |
| 1881 | } else { |
| 1882 | for i, entry := range entries { |
| 1883 | expectedEntry := test.entriesscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#entries.[i] |
| 1884 | if expectedEntry.keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key. != entry.keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key. { |
| 1885 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ObjectEach test '%s' key mismatch at entry %d: expected %s, obtained %s", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc., i, expectedEntry.keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key., entry.keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key.) |
| 1886 | break |
| 1887 | } else if expectedEntry.valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value. != entry.valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value. { |
| 1888 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ObjectEach test '%s' value mismatch at entry %d: expected %s, obtained %s", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc., i, expectedEntry.valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value., entry.valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value.) |
| 1889 | break |
| 1890 | } else if expectedEntry.valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType. != entry.valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType. { |
| 1891 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ObjectEach test '%s' value type mismatch at entry %d: expected %s, obtained %s", test.descscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEachTest#desc., i, expectedEntry.valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType., entry.valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.) |
| 1892 | break |
| 1893 | } else { |
| 1894 | // Success for this entry |
| 1895 | } |
| 1896 | } |
| 1897 | } |
| 1898 | } |
| 1899 | } |
| 1900 | |
| 1901 | // Verifies: SYS-REQ-032 [boundary] |
| 1902 | // MCDC SYS-REQ-032: addressed_object_is_well_formed=T, object_callback_returns_error=T, object_callback_error_is_returned=T => TRUE |
| 1903 | func TestObjectEachNestedPathAndCallbackErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestObjectEachNestedPathAndCallbackError().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1904 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("nested object path", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1905 | var entries []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry# |
| 1906 | err := ObjectEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEach().([]byte(`{"outer":{"a":1,"b":true}}`), func(key, value []byte, valueType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, off int) error { |
| 1907 | entries = append(entries, keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1908 | keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key.: string(key), |
| 1909 | valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value.: string(value), |
| 1910 | valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.: valueType, |
| 1911 | }) |
| 1912 | return nil |
| 1913 | }, "outer") |
| 1914 | if err != nil { |
| 1915 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ObjectEach nested path returned error: %v", err) |
| 1916 | } |
| 1917 | expected := []keyValueEntryscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#{ |
| 1918 | {keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key.: "a", valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value.: "1", valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number.}, |
| 1919 | {keyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#key.: "b", valuescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#value.: "true", valueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/keyValueEntry#valueType.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean.}, |
| 1920 | } |
| 1921 | if !reflectscip-go gomod github.com/golang/go/src go1.13 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.13 reflect/DeepEqual().(expected, entries) { |
| 1922 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ObjectEach nested path entries mismatch: expected %#v, got %#v", expected, entries) |
| 1923 | } |
| 1924 | }) |
| 1925 | |
| 1926 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("callback error is returned", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1927 | sentinel := errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Newscip-go gomod github.com/golang/go/src go1.13 errors/New().("stop iteration") |
| 1928 | err := ObjectEachscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ObjectEach().([]byte(`{"a":1}`), func(key, value []byte, valueType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, off int) error { |
| 1929 | return sentinel |
| 1930 | }) |
| 1931 | if !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, sentinel) { |
| 1932 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ObjectEach callback error mismatch: expected %v, got %v", sentinel, err) |
| 1933 | } |
| 1934 | }) |
| 1935 | } |
| 1936 | |
| 1937 | var testJsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/testJson. = []byte(`{ |
| 1938 | "name": "Name", |
| 1939 | "order": "Order", |
| 1940 | "sum": 100, |
| 1941 | "len": 12, |
| 1942 | "isPaid": true, |
| 1943 | "nested": {"a":"test", "b":2, "nested3":{"a":"test3","b":4}, "c": "unknown"}, |
| 1944 | "nested2": { |
| 1945 | "a":"test2", |
| 1946 | "b":3 |
| 1947 | }, |
| 1948 | "arr": [ |
| 1949 | { |
| 1950 | "a":"zxc", |
| 1951 | "b": 1 |
| 1952 | }, |
| 1953 | { |
| 1954 | "a":"123", |
| 1955 | "b":2 |
| 1956 | } |
| 1957 | ], |
| 1958 | "arrInt": [1,2,3,4], |
| 1959 | "intPtr": 10, |
| 1960 | "a\n":{ |
| 1961 | "b\n":99 |
| 1962 | } |
| 1963 | }`) |
| 1964 | |
| 1965 | // Verifies: SYS-REQ-008 [example] |
| 1966 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=F, eachkey_completes_requested_scan=F, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => FALSE |
| 1967 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=F, eachkey_completes_requested_scan=F, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=T, multipath_requests_are_provided=T => TRUE |
| 1968 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=F, eachkey_completes_requested_scan=T, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => TRUE |
| 1969 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=T, eachkey_completes_requested_scan=F, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => TRUE |
| 1970 | func TestEachKeyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestEachKey().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 1971 | paths := [][]string{ |
| 1972 | {"name"}, |
| 1973 | {"order"}, |
| 1974 | {"nested", "a"}, |
| 1975 | {"nested", "b"}, |
| 1976 | {"nested2", "a"}, |
| 1977 | {"nested", "nested3", "b"}, |
| 1978 | {"arr", "[1]", "b"}, |
| 1979 | {"arrInt", "[3]"}, |
| 1980 | {"arrInt", "[5]"}, // Should not find last key |
| 1981 | {"nested"}, |
| 1982 | {"arr", "["}, // issue#177 Invalid arguments |
| 1983 | {"a\n", "b\n"}, // issue#165 |
| 1984 | {"nested", "b"}, // Should find repeated key |
| 1985 | } |
| 1986 | |
| 1987 | keysFound := 0 |
| 1988 | |
| 1989 | EachKeyscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/EachKey().(testJsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/testJson., func(idx int, value []byte, vt ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 1990 | keysFound++ |
| 1991 | |
| 1992 | switch idx { |
| 1993 | case 0: |
| 1994 | if string(value) != "Name" { |
| 1995 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Should find 1 key", string(value)) |
| 1996 | } |
| 1997 | case 1: |
| 1998 | if string(value) != "Order" { |
| 1999 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 2 key") |
| 2000 | } |
| 2001 | case 2: |
| 2002 | if string(value) != "test" { |
| 2003 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 3 key") |
| 2004 | } |
| 2005 | case 3: |
| 2006 | if string(value) != "2" { |
| 2007 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 4 key") |
| 2008 | } |
| 2009 | case 4: |
| 2010 | if string(value) != "test2" { |
| 2011 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Should find 5 key", string(value)) |
| 2012 | } |
| 2013 | case 5: |
| 2014 | if string(value) != "4" { |
| 2015 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 6 key") |
| 2016 | } |
| 2017 | case 6: |
| 2018 | if string(value) != "2" { |
| 2019 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 7 key") |
| 2020 | } |
| 2021 | case 7: |
| 2022 | if string(value) != "4" { |
| 2023 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Should find 8 key", string(value)) |
| 2024 | } |
| 2025 | case 8: |
| 2026 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Found key #8 that should not be found") |
| 2027 | case 9: |
| 2028 | if string(value) != `{"a":"test", "b":2, "nested3":{"a":"test3","b":4}, "c": "unknown"}` { |
| 2029 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Should find 9 key", string(value)) |
| 2030 | } |
| 2031 | case 10: |
| 2032 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Found key #10 that should not be found") |
| 2033 | case 11: |
| 2034 | if string(value) != "99" { |
| 2035 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Should find 10 key", string(value)) |
| 2036 | } |
| 2037 | case 12: |
| 2038 | if string(value) != "2" { |
| 2039 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 11 key") |
| 2040 | } |
| 2041 | default: |
| 2042 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find only 10 keys, got %v key", idx) |
| 2043 | } |
| 2044 | }, paths...) |
| 2045 | |
| 2046 | if keysFound != 11 { |
| 2047 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Should find 11 keys: %d", keysFound) |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | type ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest# struct { |
| 2052 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in. string |
| 2053 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype. ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType# |
| 2054 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out. interface{} |
| 2055 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr. bool |
| 2056 | } |
| 2057 | |
| 2058 | var parseBoolTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseBoolTests. = []ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#{ |
| 2059 | { |
| 2060 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "true", |
| 2061 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2062 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: true, |
| 2063 | }, |
| 2064 | { |
| 2065 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "false", |
| 2066 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2067 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: false, |
| 2068 | }, |
| 2069 | { |
| 2070 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "foo", |
| 2071 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2072 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2073 | }, |
| 2074 | { |
| 2075 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "trux", |
| 2076 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2077 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2078 | }, |
| 2079 | { |
| 2080 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "truex", |
| 2081 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2082 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2083 | }, |
| 2084 | { |
| 2085 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "", |
| 2086 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., |
| 2087 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2088 | }, |
| 2089 | } |
| 2090 | |
| 2091 | var parseFloatTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseFloatTest. = []ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#{ |
| 2092 | { |
| 2093 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "0", |
| 2094 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2095 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(0), |
| 2096 | }, |
| 2097 | { |
| 2098 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "0.0", |
| 2099 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2100 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(0.0), |
| 2101 | }, |
| 2102 | { |
| 2103 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1", |
| 2104 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2105 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(1), |
| 2106 | }, |
| 2107 | { |
| 2108 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1.234", |
| 2109 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2110 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(1.234), |
| 2111 | }, |
| 2112 | { |
| 2113 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1.234e5", |
| 2114 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2115 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(1.234e5), |
| 2116 | }, |
| 2117 | { |
| 2118 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "-1.234e5", |
| 2119 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2120 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(-1.234e5), |
| 2121 | }, |
| 2122 | { |
| 2123 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "+1.234e5", // Note: + sign not allowed under RFC7159, but our parser accepts it since it uses strconv.ParseFloat |
| 2124 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2125 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: float64(1.234e5), |
| 2126 | }, |
| 2127 | { |
| 2128 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1.2.3", |
| 2129 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2130 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2131 | }, |
| 2132 | { |
| 2133 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1..1", |
| 2134 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2135 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2136 | }, |
| 2137 | { |
| 2138 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "1a", |
| 2139 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2140 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2141 | }, |
| 2142 | { |
| 2143 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: "", |
| 2144 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., |
| 2145 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2146 | }, |
| 2147 | } |
| 2148 | |
| 2149 | // parseTestCheckNoError checks the error return from Parse*() against the test case expectations. |
| 2150 | // Returns true the test should proceed to checking the actual data returned from Parse*(), or false if the test is finished. |
| 2151 | // Test helper for SYS-REQ-012, SYS-REQ-013, SYS-REQ-014, and SYS-REQ-015. |
| 2152 | func parseTestCheckNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseTestCheckNoError().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, value interface{}, err error) bool { |
| 2153 | if isErr := (err != nil); test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr. != isErr { |
| 2154 | // If the call didn't match the error expectation, fail |
| 2155 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Obtained value: %v", testKind, test.inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in., test.isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr., isErr, err, value) |
| 2156 | return false |
| 2157 | } else if isErr { |
| 2158 | // Else, if there was an error, don't fail and don't check isFound or the value |
| 2159 | return false |
| 2160 | } else { |
| 2161 | // Else, there was no error and a value was found, so check the value |
| 2162 | return true |
| 2163 | } |
| 2164 | } |
| 2165 | |
| 2166 | // Test helper for SYS-REQ-012, SYS-REQ-013, SYS-REQ-014, and SYS-REQ-015. |
| 2167 | func runParseTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runParseTests().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, testKind string, tests []ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, runner func(ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#) (interface{}, error), resultChecker func(ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, interface{}) (bool, interface{})) { |
| 2168 | for _, test := range tests { |
| 2169 | value, err := runner(test) |
| 2170 | |
| 2171 | if parseTestCheckNoErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseTestCheckNoError().(t, testKind, test, value, err) { |
| 2172 | if test.outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out. == nil { |
| 2173 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("MALFORMED TEST: %v", test) |
| 2174 | continue |
| 2175 | } |
| 2176 | |
| 2177 | if ok, expected := resultChecker(test, value); !ok { |
| 2178 | if expectedBytes, ok := expected.([]byte); ok { |
| 2179 | expected = string(expectedBytes) |
| 2180 | } |
| 2181 | if valueBytes, ok := value.([]byte); ok { |
| 2182 | value = string(valueBytes) |
| 2183 | } |
| 2184 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in., expected, value) |
| 2185 | } |
| 2186 | } |
| 2187 | } |
| 2188 | } |
| 2189 | |
| 2190 | // Verifies: SYS-REQ-036 [example] |
| 2191 | // MCDC SYS-REQ-036: raw_boolean_literal_is_valid=F, returns_parseboolean_error=T => TRUE |
| 2192 | // Verifies: SYS-REQ-012 [example] |
| 2193 | // MCDC SYS-REQ-012: raw_boolean_literal_is_valid=F, returns_parseboolean_value=F => TRUE |
| 2194 | // MCDC SYS-REQ-012: raw_boolean_literal_is_valid=T, returns_parseboolean_value=F => FALSE |
| 2195 | // MCDC SYS-REQ-012: raw_boolean_literal_is_valid=T, returns_parseboolean_value=T => TRUE |
| 2196 | func TestParseBooleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestParseBoolean().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2197 | runParseTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runParseTests().(t, "ParseBoolean()", parseBoolTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseBoolTests., |
| 2198 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#) (value interface{}, err error) { |
| 2199 | return ParseBooleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseBoolean().([]byte(test.inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.)) |
| 2200 | }, |
| 2201 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, obtained interface{}) (bool, interface{}) { |
| 2202 | expected := test.outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out..(bool) |
| 2203 | return obtained.(bool) == expected, expected |
| 2204 | }, |
| 2205 | ) |
| 2206 | } |
| 2207 | |
| 2208 | // Verifies: SYS-REQ-037 [example] |
| 2209 | // MCDC SYS-REQ-037: raw_float_token_is_well_formed=F, returns_parsefloat_error=T => TRUE |
| 2210 | // Verifies: SYS-REQ-013 [example] |
| 2211 | // MCDC SYS-REQ-013: raw_float_token_is_well_formed=F, returns_parsefloat_value=F => TRUE |
| 2212 | // MCDC SYS-REQ-013: raw_float_token_is_well_formed=T, returns_parsefloat_value=F => FALSE |
| 2213 | // MCDC SYS-REQ-013: raw_float_token_is_well_formed=T, returns_parsefloat_value=T => TRUE |
| 2214 | func TestParseFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestParseFloat().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2215 | runParseTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runParseTests().(t, "ParseFloat()", parseFloatTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseFloatTest., |
| 2216 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#) (value interface{}, err error) { |
| 2217 | return ParseFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseFloat().([]byte(test.inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.)) |
| 2218 | }, |
| 2219 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, obtained interface{}) (bool, interface{}) { |
| 2220 | expected := test.outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out..(float64) |
| 2221 | return obtained.(float64) == expected, expected |
| 2222 | }, |
| 2223 | ) |
| 2224 | } |
| 2225 | |
| 2226 | // Verifies: SYS-REQ-013 [fuzz] |
| 2227 | // MCDC SYS-REQ-013: N/A |
| 2228 | func TestFuzzParseFloatHarnessCoveragescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestFuzzParseFloatHarnessCoverage().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2229 | if got := FuzzParseFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/FuzzParseFloat().([]byte(`1.25`)); got != 1 { |
| 2230 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected FuzzParseFloat success path to return 1, got %d", got) |
| 2231 | } |
| 2232 | if got := FuzzParseFloatscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/FuzzParseFloat().([]byte(`1.2.3`)); got != 0 { |
| 2233 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected FuzzParseFloat failure path to return 0, got %d", got) |
| 2234 | } |
| 2235 | } |
| 2236 | |
| 2237 | // Verifies: STK-REQ-001 [boundary] |
| 2238 | // MCDC STK-REQ-001: N/A |
| 2239 | func TestValueTypeStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestValueTypeString().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2240 | cases := []struct { |
| 2241 | value ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType# |
| 2242 | expected string |
| 2243 | }{ |
| 2244 | {NotExistscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/NotExist., "non-existent"}, |
| 2245 | {Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., "string"}, |
| 2246 | {Numberscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Number., "number"}, |
| 2247 | {Objectscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Object., "object"}, |
| 2248 | {Arrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Array., "array"}, |
| 2249 | {Booleanscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Boolean., "boolean"}, |
| 2250 | {Nullscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Null., "null"}, |
| 2251 | {Unknownscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Unknown., "unknown"}, |
| 2252 | {ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#(255), "unknown"}, |
| 2253 | } |
| 2254 | |
| 2255 | for _, tc := range cases { |
| 2256 | if got := tc.value.Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#String().(); got != tc.expected { |
| 2257 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ValueType(%d).String() = %q, want %q", tc.value, got, tc.expected) |
| 2258 | } |
| 2259 | } |
| 2260 | } |
| 2261 | |
| 2262 | // Verifies: STK-REQ-001 [boundary] |
| 2263 | // MCDC STK-REQ-001: N/A |
| 2264 | func TestTokenStartscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestTokenStart().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2265 | cases := []struct { |
| 2266 | name string |
| 2267 | input string |
| 2268 | expected int |
| 2269 | }{ |
| 2270 | {name: "comma separator", input: `{"a":1,"b":2`, expected: 6}, |
| 2271 | {name: "array separator", input: `[1,2`, expected: 2}, |
| 2272 | {name: "opening object", input: `{"a":1`, expected: 0}, |
| 2273 | {name: "no separator", input: `value`, expected: 0}, |
| 2274 | } |
| 2275 | |
| 2276 | for _, tc := range cases { |
| 2277 | if got := tokenStartscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/tokenStart().([]byte(tc.input)); got != tc.expected { |
| 2278 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("%s: tokenStart(%q) = %d, want %d", tc.name, tc.input, got, tc.expected) |
| 2279 | } |
| 2280 | } |
| 2281 | } |
| 2282 | |
| 2283 | var parseStringTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseStringTest. = []ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#{ |
| 2284 | { |
| 2285 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: ``, |
| 2286 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., |
| 2287 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: "", |
| 2288 | }, |
| 2289 | { |
| 2290 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: `\uFF11`, |
| 2291 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., |
| 2292 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: "\uFF11", |
| 2293 | }, |
| 2294 | { |
| 2295 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: `line\nbreak`, |
| 2296 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., |
| 2297 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: "line\nbreak", |
| 2298 | }, |
| 2299 | { |
| 2300 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: `\uFFFF`, |
| 2301 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., |
| 2302 | outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out.: "\uFFFF", |
| 2303 | }, |
| 2304 | { |
| 2305 | inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.: `\uDF00`, |
| 2306 | intypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#intype.: Stringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/String., |
| 2307 | isErrscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#isErr.: true, |
| 2308 | }, |
| 2309 | } |
| 2310 | |
| 2311 | // Verifies: SYS-REQ-038 [example] |
| 2312 | // MCDC SYS-REQ-038: raw_string_literal_is_well_formed=F, returns_parsestring_error=T => TRUE |
| 2313 | // Verifies: SYS-REQ-014 [example] |
| 2314 | // MCDC SYS-REQ-014: raw_string_literal_is_well_formed=F, returns_parsestring_value=F => TRUE |
| 2315 | // MCDC SYS-REQ-014: raw_string_literal_is_well_formed=T, returns_parsestring_value=F => FALSE |
| 2316 | // MCDC SYS-REQ-014: raw_string_literal_is_well_formed=T, returns_parsestring_value=T => TRUE |
| 2317 | func TestParseStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestParseString().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2318 | runParseTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runParseTests().(t, "ParseString()", parseStringTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/parseStringTest., |
| 2319 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#) (value interface{}, err error) { |
| 2320 | return ParseStringscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseString().([]byte(test.inscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#in.)) |
| 2321 | }, |
| 2322 | func(test ParseTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#, obtained interface{}) (bool, interface{}) { |
| 2323 | expected := test.outscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseTest#out..(string) |
| 2324 | return obtained.(string) == expected, expected |
| 2325 | }, |
| 2326 | ) |
| 2327 | } |
| 2328 | |
| 2329 | // Verifies: SYS-REQ-040 [example] |
| 2330 | // MCDC SYS-REQ-040: raw_int_token_is_well_formed=F, raw_int_token_overflows_int64=F, returns_parseint_malformed_error=T => TRUE |
| 2331 | // Verifies: SYS-REQ-039 [example] |
| 2332 | // MCDC SYS-REQ-039: raw_int_token_overflows_int64=T, returns_parseint_overflow_error=T => TRUE |
| 2333 | // Verifies: SYS-REQ-015 [example] |
| 2334 | // MCDC SYS-REQ-015: raw_int_token_is_well_formed=F, returns_parseint_value=F => TRUE |
| 2335 | // MCDC SYS-REQ-015: raw_int_token_is_well_formed=T, returns_parseint_value=F => FALSE |
| 2336 | // MCDC SYS-REQ-015: raw_int_token_is_well_formed=T, returns_parseint_value=T => TRUE |
| 2337 | func TestParseIntscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestParseInt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2338 | tests := []struct { |
| 2339 | name string |
| 2340 | in string |
| 2341 | want int64 |
| 2342 | wantErr error |
| 2343 | }{ |
| 2344 | { |
| 2345 | name: "zero", |
| 2346 | in: "0", |
| 2347 | want: 0, |
| 2348 | }, |
| 2349 | { |
| 2350 | name: "negative integer", |
| 2351 | in: "-12345", |
| 2352 | want: -12345, |
| 2353 | }, |
| 2354 | { |
| 2355 | name: "max int64", |
| 2356 | in: "9223372036854775807", |
| 2357 | want: 9223372036854775807, |
| 2358 | }, |
| 2359 | { |
| 2360 | name: "empty input", |
| 2361 | in: "", |
| 2362 | wantErr: MalformedValueErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/MalformedValueError., |
| 2363 | }, |
| 2364 | { |
| 2365 | name: "fractional token", |
| 2366 | in: "1.2", |
| 2367 | wantErr: MalformedValueErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/MalformedValueError., |
| 2368 | }, |
| 2369 | { |
| 2370 | name: "alpha suffix", |
| 2371 | in: "123x", |
| 2372 | wantErr: MalformedValueErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/MalformedValueError., |
| 2373 | }, |
| 2374 | { |
| 2375 | name: "overflow", |
| 2376 | in: "9223372036854775808", |
| 2377 | wantErr: OverflowIntegerErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/OverflowIntegerError., |
| 2378 | }, |
| 2379 | { |
| 2380 | name: "underflow", |
| 2381 | in: "-9223372036854775809", |
| 2382 | wantErr: OverflowIntegerErrorscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/OverflowIntegerError., |
| 2383 | }, |
| 2384 | } |
| 2385 | |
| 2386 | for _, test := range tests { |
| 2387 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 2388 | got, err := ParseIntscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ParseInt().([]byte(test.in)) |
| 2389 | if test.wantErr != nil { |
| 2390 | if !errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Isscip-go gomod github.com/golang/go/src go1.13 errors/Is().(err, test.wantErr) { |
| 2391 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ParseInt(%q) error mismatch: expected %v, got %v", test.in, test.wantErr, err) |
| 2392 | } |
| 2393 | return |
| 2394 | } |
| 2395 | if err != nil { |
| 2396 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ParseInt(%q) returned unexpected error: %v", test.in, err) |
| 2397 | } |
| 2398 | if got != test.want { |
| 2399 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("ParseInt(%q) value mismatch: expected %d, got %d", test.in, test.want, got) |
| 2400 | } |
| 2401 | }) |
| 2402 | } |
| 2403 | } |