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

Function TestArrayEachEmpty

parser_test.go:1717–1750  ·  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

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

Callers

nothing calls this directly

Calls 1

ArrayEachFunction · 0.85

Tested by

no test coverage detected