-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathmain_test.go
40 lines (38 loc) · 940 Bytes
/
main_test.go
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
package main
import (
"testing"
)
func TestComma(t *testing.T) {
tests := []struct {
s, want string
}{
{"1", "1"},
{"12", "12"},
{"123", "123"},
{"1234", "1,234"},
{"12345", "12,345"},
{"123456", "123,456"},
{"1234567", "1,234,567"},
{"12345678", "12,345,678"},
{"123456789", "123,456,789"},
{"1234567890", "1,234,567,890"},
{"1.1234", "1.1234"},
{"12.1234", "12.1234"},
{"123.1234", "123.1234"},
{"1234.1234", "1,234.1234"},
{"12345.1234", "12,345.1234"},
{"123456.1234", "123,456.1234"},
{"1234567.1234", "1,234,567.1234"},
{"12345678.1234", "12,345,678.1234"},
{"123456789.1234", "123,456,789.1234"},
{"1234567890.1234", "1,234,567,890.1234"},
{"+123456789.1234", "+123,456,789.1234"},
{"-1234567890.1234", "-1,234,567,890.1234"},
}
for _, test := range tests {
got := comma(test.s)
if got != test.want {
t.Errorf("comma(%q), got %q, want %q", test.s, got, test.want)
}
}
}