(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestDecoderFlat(t *testing.T) { |
| 67 | var ( |
| 68 | counter int |
| 69 | mv *MetaValue |
| 70 | body = `[ |
| 71 | "1st test string", |
| 72 | "Roberto*Maestro", "Charles", |
| 73 | 0, null, false, |
| 74 | 1, 2.5 |
| 75 | ]` |
| 76 | expected = []struct { |
| 77 | Value interface{} |
| 78 | ValueType ValueType |
| 79 | }{ |
| 80 | { |
| 81 | "1st test string", |
| 82 | String, |
| 83 | }, |
| 84 | { |
| 85 | "Roberto*Maestro", |
| 86 | String, |
| 87 | }, |
| 88 | { |
| 89 | "Charles", |
| 90 | String, |
| 91 | }, |
| 92 | { |
| 93 | 0.0, |
| 94 | Number, |
| 95 | }, |
| 96 | { |
| 97 | nil, |
| 98 | Null, |
| 99 | }, |
| 100 | { |
| 101 | false, |
| 102 | Boolean, |
| 103 | }, |
| 104 | { |
| 105 | 1.0, |
| 106 | Number, |
| 107 | }, |
| 108 | { |
| 109 | 2.5, |
| 110 | Number, |
| 111 | }, |
| 112 | } |
| 113 | ) |
| 114 | |
| 115 | decoder := NewDecoder(mkReader(body), 1) |
| 116 | |
| 117 | for mv = range decoder.Stream() { |
| 118 | if mv.Value != expected[counter].Value { |
| 119 | t.Fatalf("got %v, expected: %v", mv.Value, expected[counter]) |
| 120 | } |
| 121 | if mv.ValueType != expected[counter].ValueType { |
| 122 | t.Fatalf("got %v value type, expected: %v value type", mv.ValueType, expected[counter].ValueType) |
| 123 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…