File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -373,7 +373,7 @@ void WriteEccLevelAndVersion()
373
373
#endif
374
374
private static void TrimLeadingZeros ( BitArray fStrEcc , ref int index , ref int count )
375
375
{
376
- while ( ! fStrEcc [ index ] )
376
+ while ( count > 0 && ! fStrEcc [ index ] )
377
377
{
378
378
index ++ ;
379
379
count -- ;
Original file line number Diff line number Diff line change @@ -191,6 +191,16 @@ public void can_generate_from_bytes()
191
191
result . ShouldBe ( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111011001011111110000000010000010010010100000100000000101110101010101011101000000001011101010010010111010000000010111010111000101110100000000100000100000001000001000000001111111010101011111110000000000000000011000000000000000000111100101010010011101000000001011100001001001001110000000010101011111011111110100000000000101000000110000000000000001011001001010100110000000000000000000110001000101000000000111111100110011011110000000001000001001111110111010000000010111010011100100101100000000101110101110010010010000000001011101011010100011000000000010000010110110101000100000000111111101011100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) ;
192
192
}
193
193
194
+ [ Fact ]
195
+ [ Category ( "QRGenerator/TextEncoding" ) ]
196
+ public void trim_leading_zeros_works ( )
197
+ {
198
+ var gen = new QRCodeGenerator ( ) ;
199
+ var qrData = gen . CreateQrCode ( "this is a test" , QRCodeGenerator . ECCLevel . M ) ;
200
+ var result = string . Join ( "" , qrData . ModuleMatrix . Select ( x => x . ToBitString ( ) ) . ToArray ( ) ) ;
201
+ result . ShouldBe ( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111001101011111110000000010000010010000100000100000000101110101101101011101000000001011101010001010111010000000010111010101010101110100000000100000101010101000001000000001111111010101011111110000000000000000110010000000000000000101111100011101111100000000001110100011110001100010000000001100011010110010011000000000100111000011010011100000000001001011001101011000100000000000000000100100001001100000000111111100111110001110000000001000001010011000011010000000010111010101110111101100000000101110101000000110100000000001011101011111000010000000000010000010010011010010000000000111111101101111100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) ;
202
+ }
203
+
194
204
[ Fact ]
195
205
[ Category ( "QRGenerator/TextEncoding" ) ]
196
206
public void isValidIso_works ( )
You can’t perform that action at this time.
0 commit comments