MCPcopy Create free account
hub / github.com/buger/jsonparser / TestArrayEachEmpty

Function TestArrayEachEmpty

parser_test.go:1718–1751  ·  view source on GitHub ↗

Verifies: SYS-REQ-028 [boundary] MCDC SYS-REQ-028: addressed_array_is_empty=T, addressed_array_is_well_formed=T, empty_array_produces_no_callbacks=T => TRUE

(t *testing.T)

Source from the content-addressed store, hash-verified

1716// Verifies: SYS-REQ-028 [boundary]
1717// MCDC SYS-REQ-028: addressed_array_is_empty=T, addressed_array_is_well_formed=T, empty_array_produces_no_callbacks=T => TRUE
1718func TestArrayEachEmpty(t *testing.T) {
1719 funcError := func([]byte, ValueType, int, error) { t.Errorf("Run func not allow") }
1720
1721 type args struct {
1722 data []byte
1723 cb func(value []byte, dataType ValueType, offset int, err error)
1724 keys []string
1725 }
1726 tests := []struct {
1727 name string
1728 args args
1729 wantOffset int
1730 wantErr bool
1731 }{
1732 {"Empty array", args{[]byte("[]"), funcError, []string{}}, 1, false},
1733 {"Empty array with space", args{[]byte("[ ]"), funcError, []string{}}, 2, false},
1734 {"Empty array with \n", args{[]byte("[\n]"), funcError, []string{}}, 2, false},
1735 {"Empty field array", args{[]byte("{\"data\": []}"), funcError, []string{"data"}}, 10, false},
1736 {"Empty field array with space", args{[]byte("{\"data\": [ ]}"), funcError, []string{"data"}}, 11, false},
1737 {"Empty field array with \n", args{[]byte("{\"data\": [\n]}"), funcError, []string{"data"}}, 11, false},
1738 }
1739 for _, tt := range tests {
1740 t.Run(tt.name, func(t *testing.T) {
1741 gotOffset, err := ArrayEach(tt.args.data, tt.args.cb, tt.args.keys...)
1742 if (err != nil) != tt.wantErr {
1743 t.Errorf("ArrayEach() error = %v, wantErr %v", err, tt.wantErr)
1744 return
1745 }
1746 if gotOffset != tt.wantOffset {
1747 t.Errorf("ArrayEach() = %v, want %v", gotOffset, tt.wantOffset)
1748 }
1749 })
1750 }
1751}
1752
1753type keyValueEntry struct {
1754 key string

Callers

nothing calls this directly

Calls 1

ArrayEachFunction · 0.85

Tested by

no test coverage detected