(t *testing.T)
| 614 | } |
| 615 | |
| 616 | func TestEncode(t *testing.T) { |
| 617 | testcases := []struct { |
| 618 | in Value |
| 619 | outSQL string |
| 620 | outASCII string |
| 621 | }{{ |
| 622 | in: NULL, |
| 623 | outSQL: "null", |
| 624 | outASCII: "null", |
| 625 | }, { |
| 626 | in: testVal(Int64, "1"), |
| 627 | outSQL: "1", |
| 628 | outASCII: "1", |
| 629 | }, { |
| 630 | in: testVal(VarChar, "foo"), |
| 631 | outSQL: "'foo'", |
| 632 | outASCII: "'Zm9v'", |
| 633 | }, { |
| 634 | in: testVal(VarChar, "\x00'\"\b\n\r\t\x1A\\"), |
| 635 | outSQL: "'\\0\\'\\\"\\b\\n\\r\\t\\Z\\\\'", |
| 636 | outASCII: "'ACciCAoNCRpc'", |
| 637 | }} |
| 638 | for _, tcase := range testcases { |
| 639 | buf := &bytes.Buffer{} |
| 640 | tcase.in.EncodeSQL(buf) |
| 641 | if tcase.outSQL != buf.String() { |
| 642 | t.Errorf("%v.EncodeSQL = %q, want %q", makePretty(tcase.in), buf.String(), tcase.outSQL) |
| 643 | } |
| 644 | buf = &bytes.Buffer{} |
| 645 | tcase.in.EncodeASCII(buf) |
| 646 | if tcase.outASCII != buf.String() { |
| 647 | t.Errorf("%v.EncodeASCII = %q, want %q", makePretty(tcase.in), buf.String(), tcase.outASCII) |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | // TestEncodeMap ensures DontEscape is not escaped |
| 653 | func TestEncodeMap(t *testing.T) { |
nothing calls this directly
no test coverage detected