-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_test.go
42 lines (39 loc) · 930 Bytes
/
format_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
41
42
package thousints
import (
"testing"
)
func TestFormatByThousandsDefaultSep(t *testing.T) {
testCases := []struct{
given int
expect string
}{
{1, "1"},
{100, "100"},
{1000, "1,000"},
{1000000, "1,000,000"},
}
for _, tc := range testCases {
actual := AddSeparatorsTo(tc.given)
if actual != tc.expect {
t.Errorf("Wanted: %s, Got: %s", tc.expect, actual)
}
}
}
func TestFormatByThousandsAltSep(t *testing.T) {
testCases := []struct{
given int
sep rune
expect string
}{
{1, '_', "1"},
{100, '_', "100"},
{1000, '_', "1_000"},
{1000000, '_', "1_000_000"},
}
for _, tc := range testCases {
actual := AddSeparatorsTo(tc.given, tc.sep)
if actual != tc.expect {
t.Errorf("Wanted: %s, Got: %s", tc.expect, actual)
}
}
}