File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1916,3 +1916,36 @@ func TestInterruptBySignal(t *testing.T) {
1916
1916
}
1917
1917
})
1918
1918
}
1919
+
1920
+ func TestColumnsReusesSlice (t * testing.T ) {
1921
+ rows := mysqlRows {
1922
+ rs : resultSet {
1923
+ columns : []mysqlField {
1924
+ {
1925
+ tableName : "test" ,
1926
+ name : "A" ,
1927
+ },
1928
+ {
1929
+ tableName : "test" ,
1930
+ name : "B" ,
1931
+ },
1932
+ },
1933
+ },
1934
+ }
1935
+
1936
+ allocs := testing .AllocsPerRun (1 , func () {
1937
+ cols := rows .Columns ()
1938
+
1939
+ if len (cols ) != 2 {
1940
+ t .Fatalf ("expected 2 columns, got %d" , len (cols ))
1941
+ }
1942
+ })
1943
+
1944
+ if allocs != 0 {
1945
+ t .Fatalf ("expected 0 allocations, got %d" , int (allocs ))
1946
+ }
1947
+
1948
+ if rows .rs .columnNames == nil {
1949
+ t .Fatalf ("expected columnNames to be set, got nil" )
1950
+ }
1951
+ }
You can’t perform that action at this time.
0 commit comments