diff src/testdir/test_xxd.vim @ 27118:2f854597399f v8.2.4088

patch 8.2.4088: xxd cannot output everything in one line Commit: https://github.com/vim/vim/commit/c0a1d370fa655cea9eaa74f5e605b95825dc9de1 Author: Erik Auerswald <auerswal@unix-ag.uni-kl.de> Date: Fri Jan 14 11:58:48 2022 +0000 patch 8.2.4088: xxd cannot output everything in one line Problem: Xxd cannot output everything in one line. Solution: Make zero columns mean infinite columns. (Erik Auerswald, closes #9524)
author Bram Moolenaar <Bram@vim.org>
date Fri, 14 Jan 2022 13:00:07 +0100
parents 4061623aa316
children 948c947cb1ed
line wrap: on
line diff
--- a/src/testdir/test_xxd.vim
+++ b/src/testdir/test_xxd.vim
@@ -320,10 +320,11 @@ func Test_xxd_max_cols()
 endfunc
 
 " -c0 selects the format specific default column value, as if no -c was given
+" except for -ps, where it disables extra newlines
 func Test_xxd_c0_is_def_cols()
   call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin')
   for cols in ['-c0', '-c 0', '-cols 0']
-    for fmt in ['', '-b', '-e', '-i', '-p', ]
+    for fmt in ['', '-b', '-e', '-i']
       exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1'
       exe 'r! ' . s:xxd_cmd . ' ' . cols . ' ' . fmt ' Xxdin > Xxdout2'
       call assert_equalfile('Xxdout1', 'Xxdout2')
@@ -334,4 +335,27 @@ func Test_xxd_c0_is_def_cols()
   call delete('Xxdout2')
 endfunc
 
+" all output in a single line for -c0 -ps
+func Test_xxd_plain_one_line()
+  call writefile([
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+        \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"],
+        \ 'Xxdin')
+  for cols in ['-c0', '-c 0', '-cols 0']
+    exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin'
+    " output seems to start in line 2
+    let out = join(getline(2, '$'))
+    bwipe!
+    " newlines in xxd output result in spaces in the string variable out
+    call assert_notmatch(" ", out)
+    " xxd output must be non-empty and comprise only lower case hex digits
+    call assert_match("^[0-9a-f][0-9a-f]*$", out)
+  endfor
+  call delete('Xxdin')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab