| Tim Windelschmidt | 6d33a43 | 2025-02-04 14:34:25 +0100 | [diff] [blame^] | 1 | // Copyright The Monogon Project Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| Lorenz Brun | bd2ce6d | 2022-07-22 00:00:13 +0000 | [diff] [blame] | 4 | package fat32 |
| 5 | |
| 6 | import ( |
| 7 | "encoding/binary" |
| 8 | "reflect" |
| 9 | "testing" |
| 10 | ) |
| 11 | |
| 12 | func TestStructureSizes(t *testing.T) { |
| 13 | cases := []struct { |
| 14 | StructInstance interface{} |
| 15 | ExpectedSize int |
| 16 | }{ |
| 17 | {bootSector{}, 512}, |
| 18 | {fsinfo{}, 512}, |
| 19 | {dirEntry{}, 32}, |
| 20 | {lfnEntry{}, 32}, |
| 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 | } |