-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator_test.go
35 lines (28 loc) · 954 Bytes
/
validator_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
package efp
import (
"testing"
"github.com/end-r/goutil"
)
func TestValidateField(t *testing.T) {
}
func TestValidateKey(t *testing.T) {
p := createPrototypeParserString("name : string")
parsePrototypeField(p)
goutil.AssertNow(t, p.prototype.fields["name"] != nil, "fields is nil")
// valid example
key := p.validateKey("name")
goutil.AssertNow(t, p.errs == nil, "Errors not nil")
goutil.Assert(t, key == "name", "Failed equality test")
p = createPrototypeParserString(`"[a-z]+" : string`)
parsePrototypeField(p)
goutil.AssertNow(t, p.prototype.fields["[a-z]+"] != nil, "fields is nil")
// valid example
key = p.validateKey("name")
goutil.AssertNow(t, p.errs == nil, "Errors not nil")
goutil.Assert(t, key == "[a-z]+", "Failed equality test")
}
func TestValidateKeyInvalidRegex(t *testing.T) {
p := createPrototypeParserString(`"[a-z" : string`)
parsePrototypeField(p)
goutil.AssertNow(t, p.errs != nil, "should be an error")
}