-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstatus_test.go
More file actions
80 lines (72 loc) · 2.2 KB
/
status_test.go
File metadata and controls
80 lines (72 loc) · 2.2 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
/* Go IPP - IPP core protocol implementation in pure Go
*
* Copyright (C) 2020 and up by Alexander Pevzner (pzz@apevzner.com)
* See LICENSE for license terms and conditions
*
* IPP Status Codes tests
*/
package goipp
import (
"fmt"
"testing"
)
// TestStatusString tests Status.String method
func TestStatusString(t *testing.T) {
type testData struct {
status Status // Input Op code
s string // Expected output string
}
tests := []testData{
{StatusOk, "successful-ok"},
{StatusOkConflicting, "successful-ok-conflicting-attributes"},
{StatusOkEventsComplete, "successful-ok-events-complete"},
{StatusRedirectionOtherSite, "redirection-other-site"},
{StatusErrorBadRequest, "client-error-bad-request"},
{StatusErrorForbidden, "client-error-forbidden"},
{StatusErrorNotFetchable, "client-error-not-fetchable"},
{StatusErrorInternal, "server-error-internal-error"},
{StatusErrorTooManyDocuments, "server-error-too-many-documents"},
{0xabcd, "0xabcd"},
}
for _, test := range tests {
s := test.status.String()
if s != test.s {
t.Errorf("testing Status.String:\n"+
"input: 0x%4.4x\n"+
"expected: %s\n"+
"present: %s\n",
int(test.status), test.s, s,
)
}
}
}
// TestStatusGoString tests Status.GoString method
func TestStatusGoString(t *testing.T) {
type testData struct {
status Status // Input Op code
s string // Expected output string
}
tests := []testData{
{StatusOk, "goipp.StatusOk"},
{StatusOkConflicting, "goipp.StatusOkConflicting"},
{StatusOkEventsComplete, "goipp.StatusOkEventsComplete"},
{StatusRedirectionOtherSite, "goipp.StatusRedirectionOtherSite"},
{StatusErrorBadRequest, "goipp.StatusErrorBadRequest"},
{StatusErrorForbidden, "goipp.StatusErrorForbidden"},
{StatusErrorNotFetchable, "goipp.StatusErrorNotFetchable"},
{StatusErrorInternal, "goipp.StatusErrorInternal"},
{StatusErrorTooManyDocuments, "goipp.StatusErrorTooManyDocuments"},
{0xabcd, "goipp.Status(0xabcd)"},
}
for _, test := range tests {
s := fmt.Sprintf("%#v", test.status)
if s != test.s {
t.Errorf("testing Status.GoString:\n"+
"input: 0x%4.4x\n"+
"expected: %s\n"+
"present: %s\n",
int(test.status), test.s, s,
)
}
}
}