blob: 5b612acf1401c1e154c9a8170fcc4df257f37ac4 [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 (
7 "encoding/binary"
8 "reflect"
9 "testing"
10)
11
12func TestStructureSizes(t *testing.T) {
13 cases := []struct {
14 StructInstance interface{}
15 ExpectedSize int
16 }{
17 {mbr{}, 512},
18 {mbrPartitionRecord{}, 16},
19 {header{}, 92},
20 {partition{}, 128},
21 }
22 for _, c := range cases {
23 t.Run(reflect.TypeOf(c.StructInstance).String(), func(t *testing.T) {
24 actualSize := binary.Size(c.StructInstance)
25 if actualSize != c.ExpectedSize {
26 t.Errorf("Expected %d bytes, got %d", c.ExpectedSize, actualSize)
27 }
28 })
29 }
30}