-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathenums_test.go
43 lines (38 loc) · 962 Bytes
/
enums_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
43
package room
import "testing"
func TestHTTPMethod_String(t *testing.T) {
tests := []struct {
method HTTPMethod
expected string
}{
{GET, "GET"},
{POST, "POST"},
{PUT, "PUT"},
{PATCH, "PATCH"},
{DELETE, "DELETE"},
{HEAD, "HEAD"},
{"INVALID", "GET"}, // Test case for invalid method, should default to GET
}
for _, test := range tests {
result := test.method.String()
if result != test.expected {
t.Errorf("HTTPMethod.String() returned %s, expected %s", result, test.expected)
}
}
}
func TestHTTPProtocol_String(t *testing.T) {
tests := []struct {
protocol HTTPProtocol
expected string
}{
{Http, "http://"},
{Https, "https://"},
{HTTPProtocol(999), "https://"}, // Test case for invalid protocol, should default to HTTPS
}
for _, test := range tests {
result := test.protocol.String()
if result != test.expected {
t.Errorf("HTTPProtocol.String() returned %s, expected %s", result, test.expected)
}
}
}