(t *testing.T)
| 132 | ) |
| 133 | |
| 134 | func TestString(t *testing.T) { |
| 135 | s := MakeString([]byte(HARDSQL)) |
| 136 | b := bytes.NewBuffer(nil) |
| 137 | s.EncodeSql(b) |
| 138 | if b.String() != HARDESCAPED { |
| 139 | t.Errorf("Expecting %s, received %s", HARDESCAPED, b.String()) |
| 140 | } |
| 141 | b = bytes.NewBuffer(nil) |
| 142 | s.EncodeAscii(b) |
| 143 | if b.String() != HARDASCII { |
| 144 | t.Errorf("Expecting %s, received %#v", HARDASCII, b.String()) |
| 145 | } |
| 146 | s = MakeString([]byte("abcd")) |
| 147 | |
| 148 | // Now, just printable strings. |
| 149 | s, err := BuildValue(PRINTABLE) |
| 150 | if err != nil { |
| 151 | t.Errorf("BuildValue failed on printable: %s", PRINTABLE) |
| 152 | } |
| 153 | b = bytes.NewBuffer(nil) |
| 154 | s.EncodeSql(b) |
| 155 | if b.String() != PRINTABLE_ESCAPED { |
| 156 | t.Errorf("Expecting %s, received %s", PRINTABLE_ESCAPED, b.String()) |
| 157 | } |
| 158 | b = bytes.NewBuffer(nil) |
| 159 | s.EncodeAscii(b) |
| 160 | if b.String() != PRINTABLE_ASCII { |
| 161 | t.Errorf("Expecting %s, received %#v", PRINTABLE_ASCII, b.String()) |
| 162 | } |
| 163 | |
| 164 | s, err = BuildValue(SPECIAL_CASES) |
| 165 | if err != nil { |
| 166 | t.Errorf("BuildValue failed on special cases: %s", SPECIAL_CASES) |
| 167 | } |
| 168 | b = bytes.NewBuffer(nil) |
| 169 | s.EncodeSql(b) |
| 170 | if b.String() != SPECIAL_CASES_ESCAPED { |
| 171 | t.Errorf("Expecting %s, received %s", SPECIAL_CASES_ESCAPED, b.String()) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func (s *SqlTypesSuite) TestBuildValue(c *C) { |
| 176 | v, err := BuildValue(nil) |
nothing calls this directly
no test coverage detected