| 98 | } |
| 99 | |
| 100 | func TestDecoder(t *testing.T) { //nolint:maintidx,tparallel |
| 101 | t.Parallel() |
| 102 | |
| 103 | ctx := context.TODO() |
| 104 | refTime := time.Date(2022, time.February, 15, 9, 51, 0, 0, time.UTC) |
| 105 | |
| 106 | cases := []struct { |
| 107 | Desc string |
| 108 | Stmt testStmt |
| 109 | ColumnDef []ColumnDef |
| 110 | Result interface{} |
| 111 | Expected interface{} |
| 112 | }{ |
| 113 | { |
| 114 | "Decoding into nil is not allowed", |
| 115 | testStmt{ |
| 116 | columns: nil, |
| 117 | values: nil, |
| 118 | types: nil, |
| 119 | }, |
| 120 | nil, |
| 121 | nil, |
| 122 | nil, |
| 123 | }, |
| 124 | { |
| 125 | "Decoding into basic types", |
| 126 | testStmt{ |
| 127 | columns: []string{"S", "I", "F", "B"}, |
| 128 | types: []sqlite.ColumnType{ |
| 129 | sqlite.TypeText, |
| 130 | sqlite.TypeInteger, |
| 131 | sqlite.TypeFloat, |
| 132 | sqlite.TypeInteger, |
| 133 | }, |
| 134 | values: []interface{}{ |
| 135 | "string value", |
| 136 | 1, |
| 137 | 1.2, |
| 138 | true, |
| 139 | }, |
| 140 | }, |
| 141 | nil, |
| 142 | &exampleFieldTypes{}, |
| 143 | &exampleFieldTypes{ |
| 144 | S: "string value", |
| 145 | I: 1, |
| 146 | F: 1.2, |
| 147 | B: true, |
| 148 | }, |
| 149 | }, |
| 150 | { |
| 151 | "Decoding into basic types with different order", |
| 152 | testStmt{ |
| 153 | columns: []string{"I", "S", "B", "F"}, |
| 154 | types: []sqlite.ColumnType{ |
| 155 | sqlite.TypeInteger, |
| 156 | sqlite.TypeText, |
| 157 | sqlite.TypeInteger, |