@@ -1679,6 +1679,7 @@ var testTables = []string{"foo", "bar", "t", "bench"}
16791679var tests = []testing.InternalTest {
16801680 {Name : "TestResult" , F : testResult },
16811681 {Name : "TestBlobs" , F : testBlobs },
1682+ {Name : "TestMultiBlobs" , F : testMultiBlobs },
16821683 {Name : "TestManyQueryRow" , F : testManyQueryRow },
16831684 {Name : "TestTxQuery" , F : testTxQuery },
16841685 {Name : "TestPreparedStmt" , F : testPreparedStmt },
@@ -1834,6 +1835,56 @@ func testBlobs(t *testing.T) {
18341835 }
18351836}
18361837
1838+ func testMultiBlobs (t * testing.T ) {
1839+ db .tearDown ()
1840+ db .mustExec ("create table foo (id integer primary key, bar " + db .blobType (16 ) + ")" )
1841+ var blob0 = []byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 }
1842+ db .mustExec (db .q ("insert into foo (id, bar) values(?,?)" ), 0 , blob0 )
1843+ var blob1 = []byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }
1844+ db .mustExec (db .q ("insert into foo (id, bar) values(?,?)" ), 1 , blob1 )
1845+
1846+ r , err := db .Query (db .q ("select bar from foo order by id" ))
1847+ if err != nil {
1848+ t .Fatal (err )
1849+ }
1850+ defer r .Close ()
1851+ if ! r .Next () {
1852+ if r .Err () != nil {
1853+ t .Fatal (err )
1854+ }
1855+ t .Fatal ("expected one rows" )
1856+ }
1857+
1858+ want0 := fmt .Sprintf ("%x" , blob0 )
1859+ b0 := make ([]byte , 8 )
1860+ err = r .Scan (& b0 )
1861+ if err != nil {
1862+ t .Fatal (err )
1863+ }
1864+ got0 := fmt .Sprintf ("%x" , b0 )
1865+
1866+ if ! r .Next () {
1867+ if r .Err () != nil {
1868+ t .Fatal (err )
1869+ }
1870+ t .Fatal ("expected one rows" )
1871+ }
1872+
1873+ want1 := fmt .Sprintf ("%x" , blob1 )
1874+ b1 := make ([]byte , 16 )
1875+ err = r .Scan (& b1 )
1876+ if err != nil {
1877+ t .Fatal (err )
1878+ }
1879+ got1 := fmt .Sprintf ("%x" , b1 )
1880+ if got0 != want0 {
1881+ t .Errorf ("for []byte, got %q; want %q" , got0 , want0 )
1882+ }
1883+ if got1 != want1 {
1884+ t .Errorf ("for []byte, got %q; want %q" , got1 , want1 )
1885+ }
1886+ }
1887+
18371888// testManyQueryRow is test for many query row
18381889func testManyQueryRow (t * testing.T ) {
18391890 if testing .Short () {
0 commit comments