forked from gillesdemey/go-dicom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer_test.go
51 lines (33 loc) · 1.01 KB
/
buffer_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
44
45
46
47
48
49
50
51
package dicom
import (
"testing"
)
func TestReadString(t *testing.T) {
const expect string = "OsiriX"
// OsiriX
b := newDicomBuffer([]byte{0x4f, 0x73, 0x69, 0x72, 0x69, 0x58})
l := uint32(b.Len())
if s := b.readString(l); s != expect {
t.Errorf("Incorrect string comparison %#x. Should be %#x.", s, expect)
}
}
func TestReadStringWithNullBytes(t *testing.T) {
const expect string = "OsiriX"
// null byte (0x00)
// OsiriX
b := newDicomBuffer([]byte{0x00, 0x4f, 0x73, 0x69, 0x72, 0x69, 0x58, 0x00})
l := uint32(b.Len())
if s := b.readString(l); s != expect {
t.Errorf("Incorrect string comparison %#x. Should be %#x.", s, expect)
}
}
func TestReadStringWithZeroWidthCharacter(t *testing.T) {
const expect string = "OsiriX"
// zero-width character (0xE2, 0x80, 0x8B)
// OsiriX
b := newDicomBuffer([]byte{0x4f, 0x73, 0x69, 0x72, 0x69, 0x58, 0xE2, 0x80, 0x8B})
l := uint32(b.Len())
if s := b.readString(l); s != expect {
t.Errorf("Incorrect string comparison %#x. Should be %#x.", s, expect)
}
}