(t *testing.T, pb *GoTest, expected string)
| 175 | } |
| 176 | |
| 177 | func overify(t *testing.T, pb *GoTest, expected string) { |
| 178 | o := old() |
| 179 | err := o.Marshal(pb) |
| 180 | if err != nil { |
| 181 | fmt.Printf("overify marshal-1 err = %v", err) |
| 182 | o.DebugPrint("", o.Bytes()) |
| 183 | t.Fatalf("expected = %s", expected) |
| 184 | } |
| 185 | if !equal(o.Bytes(), expected, t) { |
| 186 | o.DebugPrint("overify neq 1", o.Bytes()) |
| 187 | t.Fatalf("expected = %s", expected) |
| 188 | } |
| 189 | |
| 190 | // Now test Unmarshal by recreating the original buffer. |
| 191 | pbd := new(GoTest) |
| 192 | err = o.Unmarshal(pbd) |
| 193 | if err != nil { |
| 194 | t.Fatalf("overify unmarshal err = %v", err) |
| 195 | o.DebugPrint("", o.Bytes()) |
| 196 | t.Fatalf("string = %s", expected) |
| 197 | } |
| 198 | o.Reset() |
| 199 | err = o.Marshal(pbd) |
| 200 | if err != nil { |
| 201 | t.Errorf("overify marshal-2 err = %v", err) |
| 202 | o.DebugPrint("", o.Bytes()) |
| 203 | t.Fatalf("string = %s", expected) |
| 204 | } |
| 205 | if !equal(o.Bytes(), expected, t) { |
| 206 | o.DebugPrint("overify neq 2", o.Bytes()) |
| 207 | t.Fatalf("string = %s", expected) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | // Simple tests for numeric encode/decode primitives (varint, etc.) |
| 212 | func TestNumericPrimitives(t *testing.T) { |
no test coverage detected
searching dependent graphs…