-
Notifications
You must be signed in to change notification settings - Fork 16
/
tmreader_test.go
45 lines (38 loc) · 1.03 KB
/
tmreader_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
// Copyright 2011 The GoGL Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE.mkd file.
package main
import (
"strings"
"testing"
)
var testTypeMapStr = "Test1,*,*, GLType1,*,*\n" +
"Test2,*,*, GLType2,*,*\n" +
"Test3,*,*, GLType3,*,*\n" +
"Test_4,*,*, G L Type_3 *,*,*\n"
func checkType(tn, gltype string, tm TypeMap, t *testing.T) {
if ty, ok := tm[tn]; ok {
if ty == gltype {
t.Logf("Type found: %v::%v", tn, gltype)
return
}
t.Errorf("Type not found: %v::%v", tn, gltype)
return
}
t.Errorf("Type not found: %v", tn)
}
func TestTypeMapReader(t *testing.T) {
r := strings.NewReader(testTypeMapStr)
tm, err := ReadTypeMap(r)
if err != nil {
t.Fatalf("Read type map failed: %v", err)
}
t.Logf("%v", tm)
if len(tm) != 4 {
t.Errorf("Wrong number of types.")
}
checkType("Test1", "GLType1", tm, t)
checkType("Test2", "GLType2", tm, t)
checkType("Test3", "GLType3", tm, t)
checkType("Test_4", "G L Type_3 *", tm, t)
}