~mendelmaleh/tg_colorbot

tg_colorbot/main_test.go -rw-r--r-- 482 bytes
9db4c00eMendel E Minor updates 1 year, 2 days ago
                                                                                
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
package main

import "testing"

func TestGetColor(t *testing.T) {
	cases := []struct {
		c string
		n uint
	}{
		{"red", 0},
		{"green", 3},
		// {"yellow", 7},
		{"blue", 5},
		{"purple", 2},
		{"pink", 6},
		{"sea", 4},
		{"orange", 1},
	}

	for _, test := range cases {
		c, ok := colors[test.n]
		if !ok {
			t.Fatalf("no value for %d in colors\n", test.n)
		}

		if c.Color != test.c {
			t.Errorf("wrong color for %d, expected %s, got %s\n", test.n, test.c, c.Color)
		}
	}
}