@@ -3,20 +3,20 @@ if empty($XXD) || !executable($XXD)
33 finish
44endif
55
6- func ! PrepareBuffer (command )
7- % d
8- call append (0 , a: command )
6+ func ! PrepareBuffer (lines )
7+ new
8+ call append (0 , a: lines )
99 $d
10- w XXDfile
1110endfunc
1211
1312func ! s: Mess (counter)
1413 return printf (" Failed xxd test %d:" , a: counter )
1514endfunc
1615
1716func ! Test_xxd ()
18- new
1917 call PrepareBuffer (range (1 ,30 ))
18+ w XXDfile
19+
2020 " Test 1: simple, filter the result through xxd
2121 let s: test = 1
2222 % ! $XXD %
@@ -28,6 +28,7 @@ func! Test_xxd()
2828 \ ' 00000040: 350a 3236 0a32 370a 3238 0a32 390a 3330 5.26.27.28.29.30' ,
2929 \ ' 00000050: 0a .' ]
3030 call assert_equal (expected, getline (1 ,' $' ), s: Mess (s: test ))
31+
3132 " Test 2: reverse the result
3233 let s: test += 1
3334 % ! $XXD - r
@@ -56,12 +57,14 @@ func! Test_xxd()
5657 \ ' 20617574686f723a0a2e5c2220202020546f6e79' ,
5758 \ ' 204e7567656e74203c746f6e79407363746e7567' ]
5859 call assert_equal (expected, getline (1 ,' $' ), s: Mess (s: test ))
60+
5961 " Test 6: Print the date from xxd.1
6062 let s: test += 1
6163 % d
6264 0 r! $XXD - s 0x36 - l 13 - c 13 ../../ runtime /doc/ xxd.1
6365 $d
6466 call assert_equal (' 00000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996' , getline (1 ), s: Mess (s: test ))
67+
6568 " Test 7: Print C include
6669 let s: test += 1
6770 call writefile ([' TESTabcd09' ], ' XXDfile' )
@@ -72,6 +75,7 @@ func! Test_xxd()
7275 \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a' , ' };' ,
7376 \ ' unsigned int XXDfile_len = 11;' ]
7477 call assert_equal (expected, getline (1 ,' $' ), s: Mess (s: test ))
78+
7579 " Test 8: Print C include capitalized
7680 let s: test += 1
7781 call writefile ([' TESTabcd09' ], ' XXDfile' )
@@ -82,9 +86,11 @@ func! Test_xxd()
8286 \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a' , ' };' ,
8387 \ ' unsigned int XXDFILE_LEN = 11;' ]
8488 call assert_equal (expected, getline (1 ,' $' ), s: Mess (s: test ))
85- " Test 9: Create a file with containing a single 'A'
89+
90+ " Test 9: Create a file with containing a single 'A'
8691 let s: test += 1
8792 call delete (' XXDfile' )
93+ bwipe! XXDfile
8894 call system (' echo "010000: 41"|' .$XXD .' -r -s -0x10000 > XXDfile' )
8995 call PrepareBuffer (readfile (' XXDfile' )[0 ])
9096 call assert_equal (' A' , getline (1 ), s: Mess (s: test ))
0 commit comments