blob: 2ed4ed151b52abcbf81ee1561e5deb51b25d7e71 [file] [log] [blame]
Lorenz Brunee17d832022-10-18 12:02:45 +00001package gpt
2
3import "testing"
4
5func TestToCHS(t *testing.T) {
6 cases := []struct {
7 name string
8 lba int64
9 expectedCHS [3]byte
10 }{
11 { // See UEFI Specification 2.9 Table 5-4 StartingCHS
12 name: "One",
13 lba: 1,
14 expectedCHS: [3]byte{0x00, 0x02, 0x00},
15 },
16 {
17 name: "TooBig",
18 lba: (1023 * 255 * 63) + 1,
19 expectedCHS: [3]byte{0xff, 0xff, 0xff},
20 },
21 }
22 for _, c := range cases {
23 t.Run(c.name, func(t *testing.T) {
24 chs := toCHS(c.lba)
25 if chs != c.expectedCHS {
26 t.Errorf("expected %x, got %x", c.expectedCHS, chs)
27 }
28 })
29 }
30}