forked from gillesdemey/go-dicom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary_test.go
72 lines (53 loc) · 1.14 KB
/
dictionary_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package dicom
import (
"fmt"
"testing"
)
var parser *Parser
func init() {
parser, _ = NewParser()
}
func TestDefaultDictionary(t *testing.T) {
if _, err := NewParser(); err != nil {
t.Error(err)
}
}
func TestGetDictEntry(t *testing.T) {
elem, err := parser.getDictEntry(32736, 16)
if err != nil {
t.Error(err)
}
if elem.name != "PixelData" {
t.Errorf("Wrong element name: %s", elem.name)
}
if elem.vr != "OX" {
t.Errorf("Wrong element VR: %s", elem.vr)
}
}
// TODO: add a test for correctly splitting ranges
func TestSplitTag(t *testing.T) {
group, element, err := splitTag("(7FE0,0010)")
if err != nil {
t.Error(err)
}
if group != 0x7FE0 {
t.Errorf("Error splitting tag. Wrong group: %#x", group)
}
if element != 0x0010 {
t.Errorf("Error splitting tag. Wrong element: %#x", element)
}
}
func BenchmarkFindMetaGroupLengthTag(b *testing.B) {
for i := 0; i < b.N; i++ {
if _, err := parser.getDictEntry(2, 0); err != nil {
fmt.Println(err)
}
}
}
func BenchmarkFindPixelDataTag(b *testing.B) {
for i := 0; i < b.N; i++ {
if _, err := parser.getDictEntry(32736, 16); err != nil {
fmt.Println(err)
}
}
}