-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnum_write_test.go
More file actions
52 lines (47 loc) · 861 Bytes
/
num_write_test.go
File metadata and controls
52 lines (47 loc) · 861 Bytes
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
45
46
47
48
49
50
51
52
package fmt
import (
"testing"
)
func TestWriteInt(t *testing.T) {
tests := []struct {
val int64
want string
}{
{0, "0"},
{1, "1"},
{123, "123"},
{-1, "-1"},
{-123, "-123"},
{9223372036854775807, "9223372036854775807"},
{-9223372036854775808, "-9223372036854775808"},
}
for _, tt := range tests {
c := Convert()
c.WriteInt(tt.val)
got := c.String()
if got != tt.want {
t.Errorf("WriteInt(%d) = %q, want %q", tt.val, got, tt.want)
}
}
}
func TestWriteFloat(t *testing.T) {
tests := []struct {
val float64
want string
}{
{0.0, "0"},
{1.0, "1"},
{1.1, "1.1"},
{3.14, "3.14"},
{-1.1, "-1.1"},
{123.456, "123.456"},
}
for _, tt := range tests {
c := Convert()
c.WriteFloat(tt.val)
got := c.String()
if got != tt.want {
t.Errorf("WriteFloat(%f) = %q, want %q", tt.val, got, tt.want)
}
}
}