size_test.go

44 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
package platform

import "testing"

func TestAllSizesCount(t *testing.T) {
	sizes := AllSizes()
	if len(sizes) != 5 {
		t.Errorf("AllSizes() returned %d sizes, want 5", len(sizes))
	}
}

func TestAllSizesContainsAll(t *testing.T) {
	expected := []Size{Micro, Small, Medium, Large, XLarge}
	sizes := AllSizes()

	if len(sizes) != len(expected) {
		t.Fatalf("AllSizes() length = %d, want %d", len(sizes), len(expected))
	}

	for i, s := range expected {
		if sizes[i] != s {
			t.Errorf("AllSizes()[%d] = %q, want %q", i, sizes[i], s)
		}
	}
}

func TestSizeStringValues(t *testing.T) {
	tests := []struct {
		size Size
		want string
	}{
		{Micro, "micro"},
		{Small, "small"},
		{Medium, "medium"},
		{Large, "large"},
		{XLarge, "xlarge"},
	}

	for _, tt := range tests {
		if string(tt.size) != tt.want {
			t.Errorf("Size %v = %q, want %q", tt.size, string(tt.size), tt.want)
		}
	}
}