-
Notifications
You must be signed in to change notification settings - Fork 1
/
abnf_02-fun_test.go
96 lines (62 loc) · 3.34 KB
/
abnf_02-fun_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package abnf
import (
"testing"
"strings"
)
func compile_new_ABNF_compilator(build string,t *testing.T, abnf ABNFEngine, text_grammar string ) ABNFEngine {
valid_ABNF,tree := abnf.Valid([]byte(text_grammar))
if !valid_ABNF {
t.Errorf("build -> [%s], errors found in \n%s\n---------------------------\n", build, text_grammar)
for _,c := range tree.Childs {
t.Logf("[%s]\n", c.String())
}
t.Logf("--[%s]--\n", string(tree.Value))
}
return ABNFEngine { abnf.Compile(tree,"rulelist") }
}
func Test_ABNF_for_7405(t *testing.T) {
sorted_ABNF_7405:= normalize(strings.ToUpper(ABNF_ABNF_7405))
// using standard ABNF to create a new ABNF compilator abnf_1
abnf_1 := compile_new_ABNF_compilator("1", t, ABNF(), sorted_ABNF_7405 )
// using custom abnf_1 compilator to compile a new custome compilator abnf_2
abnf_2 := compile_new_ABNF_compilator("2", t, abnf_1, sorted_ABNF_7405 )
// using custom abnf_2 compilator to compile a new custome compilator abnf_3
abnf_3 := compile_new_ABNF_compilator("3", t, abnf_2, sorted_ABNF_7405 )
// using custom abnf_3 compilator to compile a new custome compilator abnf_4
abnf_4 := compile_new_ABNF_compilator("4", t, abnf_3, sorted_ABNF_7405 )
sorted_ABNF := normalize(strings.ToUpper(abnf_4.String()))
if sorted_ABNF != sorted_ABNF_7405 {
t.Errorf("build -> [%s], difference between \n---------\n%s\n---------\nand\n---------\n%s\n---------\n ", sorted_ABNF_7405, sorted_ABNF )
}
}
func Test_ABNF_for_5234(t *testing.T) {
sorted_ABNF_5234:= normalize(strings.ToUpper(ABNF_ABNF_5234))
// using standard ABNF to create a new ABNF compilator abnf_1
abnf_1 := compile_new_ABNF_compilator("1", t, ABNF(), sorted_ABNF_5234 )
// using custom abnf_1 compilator to compile a new custome compilator abnf_2
abnf_2 := compile_new_ABNF_compilator("2", t, abnf_1, sorted_ABNF_5234 )
// using custom abnf_2 compilator to compile a new custome compilator abnf_3
abnf_3 := compile_new_ABNF_compilator("3", t, abnf_2, sorted_ABNF_5234 )
// using custom abnf_3 compilator to compile a new custome compilator abnf_4
abnf_4 := compile_new_ABNF_compilator("4", t, abnf_3, sorted_ABNF_5234 )
sorted_ABNF := normalize(strings.ToUpper(abnf_4.String()))
if sorted_ABNF != sorted_ABNF_5234 {
t.Errorf("build -> [%s], difference between \n---------\n%s\n---------\nand\n---------\n%s\n---------\n ", sorted_ABNF_5234, sorted_ABNF )
}
}
func Test_ABNF_for_Everyone(t *testing.T) {
sorted_ABNF_7405:= normalize(strings.ToUpper(ABNF_ABNF_7405))
sorted_ABNF_5234:= normalize(strings.ToUpper(ABNF_ABNF_5234))
// using standard ABNF to create a new ABNF compilator abnf_1
abnf_1 := compile_new_ABNF_compilator("1", t, ABNF(), sorted_ABNF_5234 )
// using custom abnf_1 compilator to compile a new custome compilator abnf_2
abnf_2 := compile_new_ABNF_compilator("2", t, abnf_1, sorted_ABNF_7405 )
// using custom abnf_2 compilator to compile a new custome compilator abnf_3
abnf_3 := compile_new_ABNF_compilator("3", t, abnf_2, sorted_ABNF_5234 )
// using custom abnf_3 compilator to compile a new custome compilator abnf_4
abnf_4 := compile_new_ABNF_compilator("4", t, abnf_3, sorted_ABNF_7405 )
sorted_ABNF := normalize(strings.ToUpper(abnf_4.String()))
if sorted_ABNF != sorted_ABNF_7405 {
t.Errorf("build -> [%s], difference between \n---------\n%s\n---------\nand\n---------\n%s\n---------\n ", sorted_ABNF_7405, sorted_ABNF )
}
}