-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinput_stream_test.go
More file actions
98 lines (80 loc) · 2.1 KB
/
input_stream_test.go
File metadata and controls
98 lines (80 loc) · 2.1 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 osg
import (
"testing"
)
func TestOsgOptions(t *testing.T) {
opts := NewOsgOptions()
if opts.FileType != FileType {
t.Errorf("NewOsgOptions().FileType = %q, want %q", opts.FileType, FileType)
}
}
func TestOsgIstreamOptions(t *testing.T) {
opts := NewOsgIstreamOptions()
if opts.FileType != FileType {
t.Errorf("NewOsgIstreamOptions().FileType = %q, want %q", opts.FileType, FileType)
}
}
func TestOsgIstream_GetFileVersion(t *testing.T) {
opts := NewOsgIstreamOptions()
is := NewOsgIstream(opts)
is.FileVersion = 100
tests := []struct {
domain string
expected int32
}{
{"", 100},
{"unknown", 0},
}
for _, tt := range tests {
t.Run(tt.domain, func(t *testing.T) {
result := is.GetFileVersion(tt.domain)
if result != tt.expected {
t.Errorf("GetFileVersion(%q) = %d, want %d", tt.domain, result, tt.expected)
}
})
}
}
func TestOsgIstream_DomainVersionMap(t *testing.T) {
opts := NewOsgIstreamOptions()
opts.Domain = "TestDomain:50;AnotherDomain:100"
is := NewOsgIstream(opts)
if is.DomainVersionMap["TestDomain"] != 50 {
t.Errorf("DomainVersionMap[\"TestDomain\"] = %d, want 50", is.DomainVersionMap["TestDomain"])
}
if is.DomainVersionMap["AnotherDomain"] != 100 {
t.Errorf("DomainVersionMap[\"AnotherDomain\"] = %d, want 100", is.DomainVersionMap["AnotherDomain"])
}
}
func TestOsgIstream_ReadSize(t *testing.T) {
opts := NewOsgIstreamOptions()
is := NewOsgIstream(opts)
if is.ArrayMap == nil {
t.Error("ArrayMap should not be nil")
}
if is.IdentifierMap == nil {
t.Error("IdentifierMap should not be nil")
}
if is.DomainVersionMap == nil {
t.Error("DomainVersionMap should not be nil")
}
}
func TestTrimEnclosingSpaces(t *testing.T) {
tests := []struct {
input string
expected string
}{
{" hello ", "hello"},
{"\t\nworld\t\n", "world"},
{"", ""},
{" ", ""},
{"no-space", "no-space"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
result := trimEnclosingSpaces(tt.input)
if result != tt.expected {
t.Errorf("trimEnclosingSpaces(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}