@@ -528,37 +528,24 @@ func prepareCompareDatums() ([]Datum, []Datum) {
528528
529529func  TestStringToMysqlBit (t  * testing.T ) {
530530	tests  :=  []struct  {
531- 		a          Datum 
532- 		out        []byte 
533- 		flen       int 
534- 		truncated  bool 
531+ 		a    Datum 
532+ 		out  []byte 
535533	}{
536- 		{NewStringDatum ("true" ), []byte {1 }, 1 , true },
537- 		{NewStringDatum ("true" ), []byte {0x74 , 0x72 , 0x75 , 0x65 }, 32 , false },
538- 		{NewStringDatum ("false" ), []byte {0x1 }, 1 , true },
539- 		{NewStringDatum ("false" ), []byte {0x66 , 0x61 , 0x6c , 0x73 , 0x65 }, 40 , false },
540- 		{NewStringDatum ("1" ), []byte {1 }, 1 , true },
541- 		{NewStringDatum ("1" ), []byte {0x31 }, 8 , false },
542- 		{NewStringDatum ("0" ), []byte {1 }, 1 , true },
543- 		{NewStringDatum ("0" ), []byte {0x30 }, 8 , false },
544- 		{NewStringDatum ("b'1'" ), []byte {0x62 , 0x27 , 0x31 , 0x27 }, 32 , false },
545- 		{NewStringDatum ("b'0'" ), []byte {0x62 , 0x27 , 0x30 , 0x27 }, 32 , false },
534+ 		{NewStringDatum ("true" ), []byte {1 }},
535+ 		{NewStringDatum ("false" ), []byte {0 }},
536+ 		{NewStringDatum ("1" ), []byte {1 }},
537+ 		{NewStringDatum ("0" ), []byte {0 }},
538+ 		{NewStringDatum ("b'1'" ), []byte {1 }},
539+ 		{NewStringDatum ("b'0'" ), []byte {0 }},
546540	}
547541	sc  :=  new (stmtctx.StatementContext )
548542	sc .IgnoreTruncate  =  true 
543+ 	tp  :=  NewFieldType (mysql .TypeBit )
544+ 	tp .SetFlen (1 )
549545	for  _ , tt  :=  range  tests  {
550- 		t .Run (fmt .Sprintf ("%s %d %t" , tt .a .GetString (), tt .flen , tt .truncated ), func (t  * testing.T ) {
551- 			tp  :=  NewFieldType (mysql .TypeBit )
552- 			tp .SetFlen (tt .flen )
553- 
554- 			bin , err  :=  tt .a .convertToMysqlBit (sc , tp )
555- 			if  tt .truncated  {
556- 				require .Contains (t , err .Error (), "Data Too Long" )
557- 			} else  {
558- 				require .NoError (t , err )
559- 			}
560- 			require .Equal (t , tt .out , bin .b )
561- 		})
546+ 		bin , err  :=  tt .a .convertToMysqlBit (nil , tp )
547+ 		require .NoError (t , err )
548+ 		require .Equal (t , tt .out , bin .b )
562549	}
563550}
564551
0 commit comments