Lorenz Brun | ee17d83 | 2022-10-18 12:02:45 +0000 | [diff] [blame^] | 1 | package gpt |
| 2 | |
| 3 | import ( |
| 4 | "encoding/binary" |
| 5 | "reflect" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func 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 | } |