mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
fix typo & add test for noCopy
This commit is contained in:
@@ -89,7 +89,7 @@ Besides standart json tag options like 'omitempty' the following are supported:
|
||||
objects which are not hold in memory after decoding and immediate usage.
|
||||
Note if string requires unescaping it will be processed as normally.
|
||||
* 'intern' - string "interning" (deduplication) to save memory when the very
|
||||
same string dictionory values are often met all over the structure.
|
||||
same string dictionary values are often met all over the structure.
|
||||
See below for more details.
|
||||
|
||||
## Generated Marshaler/Unmarshaler Funcs
|
||||
|
||||
+12
-1
@@ -48,6 +48,17 @@ func TestNocopy(t *testing.T) {
|
||||
}
|
||||
})
|
||||
if allocsPerRun != 1 {
|
||||
t.Fatalf("expected 1 allocs, got %f", allocsPerRun)
|
||||
t.Fatalf("noCopy field unmarshal: expected 1 allocs, got %f", allocsPerRun)
|
||||
}
|
||||
|
||||
data = []byte(`{"a": "valueNoCopy"}`)
|
||||
allocsPerRun = testing.AllocsPerRun(1000, func() {
|
||||
easyjson.Unmarshal(data, &res)
|
||||
if res.A != "valueNoCopy" {
|
||||
t.Fatalf("wrong value: %q", res.A)
|
||||
}
|
||||
})
|
||||
if allocsPerRun != 2 {
|
||||
t.Fatalf("copy field unmarshal: expected 2 allocs, got %f", allocsPerRun)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user