This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ins_test.go
55 lines (48 loc) · 1.46 KB
/
ins_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
package antlraci
import (
"testing"
)
/*
TestParseInstruction iterates the testInstructionManifest, parses each member value
and compares the return result with the original.
*/
func TestParseInstruction(t *testing.T) {
ct := len(testInstructionManifest)
for idx, want := range testInstructionManifest {
/*
// TODO: add bad instruction testers
// similar to the other tests ...
want, found := testInstructionManifest[idx]
if !found {
t.Errorf("%s [VALID] failed [idx[%d]::%d/%d]: MISSING MAP ENTRY FOR INDEX %d?",
t.Name(), idx, idx+1, ct, idx)
return
}
*/
r, err := ParseInstruction(want)
if err != nil {
// There was an error
if idx%2 == 0 {
// Valid test should have worked, but did not.
t.Errorf("%s [VALID] failed [idx[%d]::%d/%d]: %v\nwant: '%s'\ngot: '%s'",
t.Name(), idx, idx+1, ct, err, want, r)
return
}
continue
} else {
// There was no error
if idx%2 != 0 {
// Invalid test should have failed, but did not.
t.Errorf("%s [INVALID] failed [idx[%d]::%d/%d]: %T (%s) parse attempt returned no error",
t.Name(), idx, idx+1, ct, r, r.String())
return
}
}
if got := r.String(); want != got {
// There was an (unexpected) result during strcmp.
t.Errorf("%s [VALID] failed [idx:%d/%d]:\nwant '%s'\ngot '%s'",
t.Name(), idx, ct, want, got)
return
}
}
}