package ircclient import ( "testing" ) type colortext struct { Text string Color int } func TestColor(t *testing.T) { var sent colortext var expect string var got string var plain string for sent, expect = range map[colortext]string{{Text: "One", Color: 1}: "\x0301One\x0f", {"Two", 2}: "\x0302Two\x0f", {"Three", 3}: "\x0303Three\x0f"} { got = ColorString(sent.Color, sent.Text) if got != expect { t.Errorf("Got %s, expected %s", got, expect) } plain = Stripper(got) if plain != sent.Text { t.Errorf("Got %s, expected %s", plain, sent.Text) } } } func TestBold(t *testing.T) { var sent string var expect string var got string var plain string for sent, expect = range map[string]string{"One": "\x02One\x02", "Two": "\x02Two\x02", "Three": "\x02Three\x02"} { got = Bold(sent) if got != expect { t.Errorf("Got %s, expected %s", got, expect) } plain = Stripper(got) if plain != sent { t.Errorf("Got %s, expected %s", plain, sent) } } } func TestUnderline(t *testing.T) { var sent string var expect string var got string var plain string for sent, expect = range map[string]string{"One": "\x16One\x16", "Two": "\x16Two\x16", "Three": "\x16Three\x16"} { got = Underline(sent) if got != expect { t.Errorf("Got %s, expected %s", got, expect) } plain = Stripper(got) if plain != sent { t.Errorf("Got %s, expected %s", plain, sent) } } }