blob: dc53635c4b52b8e820487071ac1f79261f4d7c4a [file] [log] [blame]
Lorenz Brunee17d832022-10-18 12:02:45 +00001package gpt
2
3import (
4 "encoding/binary"
5 "reflect"
6 "testing"
7)
8
9func TestStructureSizes(t *testing.T) {
10 cases := []struct {
11 StructInstance interface{}
12 ExpectedSize int
13 }{
14 {mbr{}, 512},
15 {mbrPartitionRecord{}, 16},
16 {header{}, 92},
17 {partition{}, 128},
18 }
19 for _, c := range cases {
20 t.Run(reflect.TypeOf(c.StructInstance).String(), func(t *testing.T) {
21 actualSize := binary.Size(c.StructInstance)
22 if actualSize != c.ExpectedSize {
23 t.Errorf("Expected %d bytes, got %d", c.ExpectedSize, actualSize)
24 }
25 })
26 }
27}