| 1 | package platform |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/go-quicktest/qt" |
| 7 | ) |
| 8 | |
| 9 | func TestConstant(t *testing.T) { |
| 10 | const maxConstant = uint32(1<<platformShift - 1) |
| 11 | for _, plat := range []string{ |
| 12 | Linux, |
| 13 | Windows, |
| 14 | } { |
| 15 | t.Run(plat, func(t *testing.T) { |
| 16 | c, err := EncodeConstant[uint32](plat, maxConstant) |
| 17 | qt.Assert(t, qt.IsNil(err)) |
| 18 | gotPlat, gotValue := DecodeConstant(c) |
| 19 | qt.Assert(t, qt.Equals(gotPlat, plat)) |
| 20 | qt.Assert(t, qt.Equals(gotValue, maxConstant)) |
| 21 | |
| 22 | _, err = EncodeConstant[uint32](plat, maxConstant+1) |
| 23 | qt.Assert(t, qt.IsNotNil(err)) |
| 24 | }) |
| 25 | } |
| 26 | } |