| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package golang |
| 6 | |
| 7 | import "testing" |
| 8 | |
| 9 | func TestSizeClass(t *testing.T) { |
| 10 | // See GOROOT/src/runtime/msize.go for details. |
| 11 | for _, test := range [...]struct{ size, class int64 }{ |
| 12 | {8, 8}, |
| 13 | {9, 16}, |
| 14 | {16, 16}, |
| 15 | {17, 24}, |
| 16 | } { |
| 17 | got := sizeClass(test.size) |
| 18 | if got != test.class { |
| 19 | t.Errorf("sizeClass(%d) = %d, want %d", test.size, got, test.class) |
| 20 | } |
| 21 | } |
| 22 | } |