-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_test.go
More file actions
98 lines (70 loc) · 1.86 KB
/
format_test.go
File metadata and controls
98 lines (70 loc) · 1.86 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package core_test
import (
. "dappco.re/go"
)
func TestFormat_Errorf_Good(t *T) {
err := Errorf("dispatch %s: %w", "agent", AnError)
AssertError(t, err, "dispatch agent")
AssertTrue(t, Is(err, AnError))
}
func TestFormat_Errorf_Bad(t *T) {
err := Errorf("agent %s", "codex")
AssertError(t, err, "agent codex")
AssertFalse(t, Is(err, AnError))
}
func TestFormat_Errorf_Ugly(t *T) {
err := Errorf("")
AssertError(t, err)
AssertEqual(t, "", err.Error())
}
func TestFormat_Print_Good(t *T) {
buf := NewBuffer()
Print(buf, "agent %s", "ready")
AssertEqual(t, "agent ready\n", buf.String())
}
func TestFormat_Print_Bad(t *T) {
buf := NewBuffer()
Print(buf, "")
AssertEqual(t, "\n", buf.String())
}
func TestFormat_Print_Ugly(t *T) {
buf := NewBuffer()
Print(buf, "agent %s")
AssertEqual(t, "agent %!s(MISSING)\n", buf.String())
}
func TestFormat_Println_Good(t *T) {
AssertNotPanics(t, func() { Println("agent", "ready") })
}
func TestFormat_Println_Bad(t *T) {
AssertNotPanics(t, func() { Println() })
}
func TestFormat_Println_Ugly(t *T) {
AssertNotPanics(t, func() { Println(nil) })
}
func TestFormat_Sprint_Good(t *T) {
AssertEqual(t, "agent42", Sprint("agent", 42))
}
func TestFormat_Sprint_Bad(t *T) {
AssertEqual(t, "", Sprint())
}
func TestFormat_Sprint_Ugly(t *T) {
AssertEqual(t, "<nil>", Sprint(nil))
}
func TestFormat_Sprintf_Good(t *T) {
AssertEqual(t, "agent codex ready", Sprintf("agent %s ready", "codex"))
}
func TestFormat_Sprintf_Bad(t *T) {
AssertEqual(t, `""`, Sprintf("%q", ""))
}
func TestFormat_Sprintf_Ugly(t *T) {
AssertEqual(t, "100% ready", Sprintf("%d%% ready", 100))
}
func TestFormat_Sprintln_Good(t *T) {
AssertEqual(t, "agent ready\n", Sprintln("agent", "ready"))
}
func TestFormat_Sprintln_Bad(t *T) {
AssertEqual(t, "\n", Sprintln())
}
func TestFormat_Sprintln_Ugly(t *T) {
AssertEqual(t, "<nil>\n", Sprintln(nil))
}