Skip to content

Commit 52ae641

Browse files
committed
fix allocs expectations in tests
1 parent eecedd1 commit 52ae641

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/intern_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func TestStringIntern(t *testing.T) {
2020
t.Fatalf("wrong value: %q", i.Field)
2121
}
2222
})
23-
if allocsPerRun != 1 {
24-
t.Fatalf("expected 1 allocs, got %f", allocsPerRun)
23+
if allocsPerRun > 1 {
24+
t.Fatalf("expected <= 1 allocs, got %f", allocsPerRun)
2525
}
2626

2727
var n NoIntern
@@ -35,7 +35,7 @@ func TestStringIntern(t *testing.T) {
3535
t.Fatalf("wrong value: %q", n.Field)
3636
}
3737
})
38-
if allocsPerRun != 2 {
39-
t.Fatalf("expected 2 allocs, got %f", allocsPerRun)
38+
if allocsPerRun > 2 {
39+
t.Fatalf("expected <= 2 allocs, got %f", allocsPerRun)
4040
}
4141
}

tests/nocopy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func TestNocopy(t *testing.T) {
5353
t.Fatalf("wrong value: %q", res.B)
5454
}
5555
})
56-
if allocsPerRun != 1 {
57-
t.Fatalf("noCopy field unmarshal: expected 1 allocs, got %f", allocsPerRun)
56+
if allocsPerRun > 1 {
57+
t.Fatalf("noCopy field unmarshal: expected <= 1 allocs, got %f", allocsPerRun)
5858
}
5959

6060
data = []byte(`{"a": "valueNoCopy"}`)
@@ -67,7 +67,7 @@ func TestNocopy(t *testing.T) {
6767
t.Fatalf("wrong value: %q", res.A)
6868
}
6969
})
70-
if allocsPerRun != 2 {
71-
t.Fatalf("copy field unmarshal: expected 2 allocs, got %f", allocsPerRun)
70+
if allocsPerRun > 2 {
71+
t.Fatalf("copy field unmarshal: expected <= 2 allocs, got %f", allocsPerRun)
7272
}
7373
}

0 commit comments

Comments
 (0)