philhanna / xxd

Python version of xxd
MIT License
0 stars 0 forks source link

-b option is not working #36

Closed philhanna closed 2 years ago

philhanna commented 2 years ago

The original C code with xxd -b testdata/short produces this:

00000000: 01001110 01101111 01110111 00100000 01101001 01110011  Now is
00000006: 00100000 01110100 01101000 01100101 00100000 01110100   the t
0000000c: 01101001 01101101 01100101 00100000 01100110 01101111  ime fo
00000012: 01110010 00100000 01100001 01101100 01101100 00100000  r all 
00000018: 01100111 01101111 01101111 01100100 00100000 01101101  good m
0000001e: 01100101 01101110 00100000 01110100 01101111 00100000  en to 
00000024: 01100011 01101111 01101101 01100101 00100000 01110100  come t
0000002a: 01101111 00100000 01110100 01101000 01100101 00100000  o the 
00000030: 01100001 01101001 01100100 00100000 01101111 01100110  aid of
00000036: 00100000 01110100 01101000 01100101 01101001 01110010   their
0000003c: 00100000 01110000 01100001 01110010 01110100 01111001   party
00000042: 00101110 00001010                                      ..

but pxxd -b testdata/short produces this:

00000000: 4e 6f 77 20 69 73              Now is
00000006: 20 74 68 65 20 74               the t
0000000c: 69 6d 65 20 66 6f              ime fo
00000012: 72 20 61 6c 6c 20              r all 
00000018: 67 6f 6f 64 20 6d              good m
0000001e: 65 6e 20 74 6f 20              en to 
00000024: 63 6f 6d 65 20 74              come t
0000002a: 6f 20 74 68 65 20              o the 
00000030: 61 69 64 20 6f 66              aid of
00000036: 20 74 68 65 69 72               their
0000003c: 20 70 61 72 74 79               party
00000042: 2e 0a                          ..

Why didn't I have a unit test that would have caught this?

philhanna commented 2 years ago

In set_hextype(args), I was only checking for the existence of some options, not whether they were set to False.