-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathutil_test.go
60 lines (52 loc) · 1.51 KB
/
util_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
// 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 (
"reflect"
"testing"
)
type testCategories struct {
in string
out ParsedCategory
}
type testGoName struct {
in string
out string
}
var allTestCategories = []testCategories{
{"VERSION_1_4", ParsedCategory{CategoryVersion, Version{1, 4}, "", ""}},
{"VERSION_2_0_DEPRECATED", ParsedCategory{CategoryDepVersion, Version{2, 0}, "", ""}},
{"ARB_multisample", ParsedCategory{CategoryExtension, Version{0, 0}, "ARB", "multisample"}},
{"EXT_12345678", ParsedCategory{CategoryExtension, Version{0, 0}, "EXT", "12345678"}},
{"ABC123_a_b_", ParsedCategory{CategoryExtension, Version{0, 0}, "ABC123", "a_b_"}},
{"A_", ParsedCategory{CategoryExtension, Version{0, 0}, "A", ""}},
}
var allTestGoName = []testGoName{
{"", ""},
{"_", ""},
{"ARB_multisample", "ARBMultisample"},
{"vertex_array_object", "VertexArrayObject"},
{"a_b_c_", "ABC"},
}
func TestParsedCategory(t *testing.T) {
for i := range allTestCategories {
te := &allTestCategories[i]
pc, err := ParseCategoryString(te.in)
if err != nil {
t.Fatalf(err.Error())
}
t.Logf("%s -> %v", te.in, te.out)
if !reflect.DeepEqual(pc, te.out) {
t.Errorf("not equal: out = %v", pc)
}
}
}
func TestGoName(t *testing.T) {
for i := range allTestGoName {
te := &allTestGoName[i]
if GoName(te.in) != te.out {
t.Errorf("String conversion failed: %v -> %v", te.in, te.out)
}
}
}