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