Lorenz Brun | ee17d83 | 2022-10-18 12:02:45 +0000 | [diff] [blame] | 1 | package gpt |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func 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 | } |