| 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 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 6 | ) |
| 7 | |
| 8 | // Verifies: SYS-REQ-009 [example] |
| 9 | // MCDC SYS-REQ-009: set_creates_missing_path=F, set_path_is_provided=F, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=F => TRUE |
| 10 | // MCDC SYS-REQ-009: set_creates_missing_path=F, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=F => FALSE |
| 11 | // MCDC SYS-REQ-009: set_creates_missing_path=F, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=T => TRUE |
| 12 | // MCDC SYS-REQ-009: set_creates_missing_path=F, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=T, set_target_exists=F => TRUE |
| 13 | // MCDC SYS-REQ-009: set_creates_missing_path=F, set_path_is_provided=T, set_returns_not_found_error=T, set_returns_updated_document=F, set_target_exists=F => TRUE |
| 14 | func TestSetscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestSet().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 15 | runSetTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/runSetTests().(t, "Set()", setTestsscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/setTests., |
| 16 | func(test SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#) (value interface{}, dataType ValueTypescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/ValueType#, err error) { |
| 17 | value, err = Setscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Set().([]byte(test.jsonscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#json.), []byte(test.setDatascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#setData.), test.pathscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#path....) |
| 18 | return |
| 19 | }, |
| 20 | func(test SetTestscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#, value interface{}) (bool, interface{}) { |
| 21 | expected := []byte(test.datascip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/SetTest#data..(string)) |
| 22 | 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 |
| 23 | }, |
| 24 | ) |
| 25 | } |
| 26 | |
| 27 | // Verifies: SYS-REQ-009 [boundary] |
| 28 | // MCDC SYS-REQ-009: set_creates_missing_path=T, set_path_is_provided=T, set_returns_not_found_error=F, set_returns_updated_document=F, set_target_exists=F => TRUE |
| 29 | func TestSetCreatesMissingEntryInExistingArrayscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestSetCreatesMissingEntryInExistingArray().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 30 | value, err := Setscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/Set().( |
| 31 | []byte(`{"top":[{"middle":[{"present":true}]}]}`), |
| 32 | []byte(`{"bottom":"value"}`), |
| 33 | "top", "[0]", "middle", "[1]", |
| 34 | ) |
| 35 | if err != nil { |
| 36 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Set returned error: %v", err) |
| 37 | } |
| 38 | |
| 39 | expected := `{"top":[{"middle":[{"present":true},{"bottom":"value"}]}]}` |
| 40 | if string(value) != expected { |
| 41 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Set result mismatch: expected %s, got %s", expected, string(value)) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // Verifies: SYS-REQ-009 [fuzz] |
| 46 | // MCDC SYS-REQ-009: N/A |
| 47 | func TestFuzzSetHarnessCoveragescip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/TestFuzzSetHarnessCoverage().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 48 | if got := FuzzSetscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/FuzzSet().([]byte(`{"test":"input"}`)); got != 1 { |
| 49 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected FuzzSet success path to return 1, got %d", got) |
| 50 | } |
| 51 | if got := FuzzSetscip-go gomod github.com/buger/jsonparser . `github.com/buger/jsonparser`/FuzzSet().([]byte(``)); got != 0 { |
| 52 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("expected FuzzSet failure path to return 0, got %d", got) |
| 53 | } |
| 54 | } |