(t *testing.T, depth int)
| 99 | } |
| 100 | |
| 101 | func testEachKeyPathDepth(t *testing.T, depth int) { |
| 102 | t.Helper() |
| 103 | path := make([]string, depth) |
| 104 | var data strings.Builder |
| 105 | for i := range path { |
| 106 | path[i] = "key" + strconv.Itoa(i) |
| 107 | data.WriteString(`{"`) |
| 108 | data.WriteString(path[i]) |
| 109 | data.WriteString(`":`) |
| 110 | } |
| 111 | data.WriteString(`"found"`) |
| 112 | for range path { |
| 113 | data.WriteByte('}') |
| 114 | } |
| 115 | |
| 116 | callbacks := 0 |
| 117 | offset := EachKey([]byte(data.String()), func(idx int, value []byte, valueType ValueType, err error) { |
| 118 | callbacks++ |
| 119 | if err != nil { |
| 120 | t.Errorf("EachKey callback returned error: %v", err) |
| 121 | } |
| 122 | if idx != 0 { |
| 123 | t.Errorf("EachKey callback index = %d; want 0", idx) |
| 124 | } |
| 125 | if valueType != String { |
| 126 | t.Errorf("EachKey value type = %v; want %v", valueType, String) |
| 127 | } |
| 128 | if string(value) != "found" { |
| 129 | t.Errorf("EachKey value = %q; want %q", value, "found") |
| 130 | } |
| 131 | }, path) |
| 132 | |
| 133 | if offset < 0 { |
| 134 | t.Fatalf("EachKey did not find the %d-component path", depth) |
| 135 | } |
| 136 | if callbacks != 1 { |
| 137 | t.Fatalf("EachKey callbacks = %d; want 1", callbacks) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // Verifies: SYS-REQ-009 (Set) |
| 142 | // reqproof:proptest:skip targeted witness/regression test; not a property-test subject |
no test coverage detected