| 1 |
package gojsonq |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
) |
| 6 |
|
| 7 |
func TestWithDecoder(t *testing.T) { |
| 8 |
jq := New(WithDecoder(&cDecoder{})) |
| 9 |
if jq.option.decoder == nil { |
| 10 |
t.Error("failed to set decoder as option") |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
func TestWithDecoder_with_nil_expecting_an_error(t *testing.T) { |
| 15 |
jq := New(WithDecoder(nil)) |
| 16 |
if jq.Error() == nil { |
| 17 |
t.Error("failed to catch nil in WithDecoder") |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
func TestWithSeparator(t *testing.T) { |
| 22 |
jq := New(WithSeparator("->")) |
| 23 |
if jq.option.separator != "->" { |
| 24 |
t.Error("failed to set separator as option") |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
func TestWithSeparator_with_nil_expecting_an_error(t *testing.T) { |
| 29 |
jq := New(WithSeparator("")) |
| 30 |
if jq.Error() == nil { |
| 31 |
t.Error("failed to catch nil in WithSeparator") |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
func TestSetDecoder(t *testing.T) { |
| 37 |
jq := New(SetDecoder(&cDecoder{})) |
| 38 |
if jq.option.decoder == nil { |
| 39 |
t.Error("failed to set decoder as option") |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
func TestSetDecoder_with_nil_expecting_an_error(t *testing.T) { |
| 44 |
jq := New(SetDecoder(nil)) |
| 45 |
if jq.Error() == nil { |
| 46 |
t.Error("failed to catch nil in SetDecoder") |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
func TestSetSeparator(t *testing.T) { |
| 51 |
jq := New(SetSeparator("->")) |
| 52 |
if jq.option.separator != "->" { |
| 53 |
t.Error("failed to set separator as option") |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
func TestSetSeparator_with_nil_expecting_an_error(t *testing.T) { |
| 58 |
jq := New(SetSeparator("")) |
| 59 |
if jq.Error() == nil { |
| 60 |
t.Error("failed to catch nil in SetSeparator") |
| 61 |
} |
| 62 |
} |