forked from mirror/gjson
add test of different strings
Added test for each of the different accepted values for ParseBool, and a few arbitrary results that should return false.
This commit is contained in:
parent
7db3b02e3f
commit
78a59792a3
|
@ -313,10 +313,25 @@ func TestTypes(t *testing.T) {
|
|||
assert(t, (Result{Type: JSON}).Type.String() == "JSON")
|
||||
assert(t, (Result{Type: 100}).Type.String() == "")
|
||||
// bool
|
||||
assert(t, (Result{Type: String, Str: "true"}).Bool())
|
||||
assert(t, (Result{Type: True}).Bool())
|
||||
assert(t, (Result{Type: False}).Bool() == false)
|
||||
assert(t, (Result{Type: Number, Num: 1}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "1"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "T"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "t"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "true"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "True"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "TRUE"}).Bool())
|
||||
assert(t, (Result{Type: String, Str: "tRuE"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "0"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "f"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "F"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "false"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "False"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "FALSE"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "fAlSe"}).Bool() == false)
|
||||
assert(t, (Result{Type: String, Str: "random"}).Bool() == false)
|
||||
|
||||
// int
|
||||
assert(t, (Result{Type: String, Str: "1"}).Int() == 1)
|
||||
assert(t, (Result{Type: True}).Int() == 1)
|
||||
|
|
Loading…
Reference in New Issue