Patch 8.1.0821
Problem:    Xxd "usage" output and other arguments not tested.
Solution:   Add a test to trigger the usage output in various ways.  Fix
            uncovered problem.
Files:      src/testdir/test_xxd.vim, src/xxd/xxd.c


*** ../vim-8.1.0820/src/testdir/test_xxd.vim    2019-01-09 23:00:58.001176090 
+0100
--- src/testdir/test_xxd.vim    2019-01-25 21:49:26.831963075 +0100
***************
*** 20,26 ****
  func Test_xxd()
    call PrepareBuffer(range(1,30))
    set ff=unix
!   w XXDfile
  
    " Test 1: simple, filter the result through xxd
    let s:test = 1
--- 20,26 ----
  func Test_xxd()
    call PrepareBuffer(range(1,30))
    set ff=unix
!   w! XXDfile
  
    " Test 1: simple, filter the result through xxd
    let s:test = 1
***************
*** 39,53 ****
    exe '%!' . s:xxd_cmd . ' -r'
    call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), 
s:Mess(s:test))
  
!   " Test 3: Skip the first 30 bytes
    let s:test += 1
!   exe '%!' . s:xxd_cmd . ' -s 0x30 %'
!   call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test))
  
    " Test 4: Skip the first 30 bytes
    let s:test += 1
!   exe '%!' . s:xxd_cmd . ' -s -0x31 %'
!   call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test))
  
    " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line
    let s:test += 1
--- 39,57 ----
    exe '%!' . s:xxd_cmd . ' -r'
    call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), 
s:Mess(s:test))
  
!   " Test 3: Skip the first 0x30 bytes
    let s:test += 1
!   for arg in ['-s 0x30', '-s0x30', '-s+0x30', '-skip 0x030', '-seek 0x30', 
'-seek +0x30 --']
!     exe '%!' . s:xxd_cmd . ' ' . arg . ' %'
!     call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 4: Skip the first 30 bytes
    let s:test += 1
!   for arg in ['-s -0x31', '-s-0x31']
!     exe '%!' . s:xxd_cmd . ' ' . arg . ' %'
!     call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line
    let s:test += 1
***************
*** 56,62 ****
    if has('win32') && !filereadable(fname)
      let fname = '../../doc/xxd.1'
    endif
!   exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c 20 ' . fname
    $d
    let expected = [
        \ '2e54482058584420312022417567757374203139',
--- 60,66 ----
    if has('win32') && !filereadable(fname)
      let fname = '../../doc/xxd.1'
    endif
!   exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c20 ' . fname
    $d
    let expected = [
        \ '2e54482058584420312022417567757374203139',
***************
*** 69,78 ****
  
    " Test 6: Print the date from xxd.1
    let s:test += 1
!   %d
!   exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -c 13 ' . fname
!   $d
!   call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36  21st May 
1996', getline(1), s:Mess(s:test))
  
    " Test 7: Print C include
    let s:test += 1
--- 73,84 ----
  
    " Test 6: Print the date from xxd.1
    let s:test += 1
!   for arg in ['-l 13', '-l13', '-len 13']
!     %d
!     exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -cols 13 ' . fname
!     $d
!     call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36  21st May 
1996', getline(1), s:Mess(s:test))
!   endfor
  
    " Test 7: Print C include
    let s:test += 1
***************
*** 87,100 ****
  
    " Test 8: Print C include capitalized
    let s:test += 1
!   call writefile(['TESTabcd09'], 'XXDfile')
!   %d
!   exe '0r! ' . s:xxd_cmd . ' -i -C XXDfile'
!   $d
!   let expected = ['unsigned char XXDFILE[] = {',
!         \ '  0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 
0x0a', '};',
!         \ 'unsigned int XXDFILE_LEN = 11;']
!   call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
  
    " Test 9: Create a file with containing a single 'A'
    let s:test += 1
--- 93,108 ----
  
    " Test 8: Print C include capitalized
    let s:test += 1
!   for arg in ['-C', '-capitalize']
!     call writefile(['TESTabcd09'], 'XXDfile')
!     %d
!     exe '0r! ' . s:xxd_cmd . ' -i ' . arg . ' XXDfile'
!     $d
!     let expected = ['unsigned char XXDFILE[] = {',
!         \ '  0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 
0x0a', '};',
!         \ 'unsigned int XXDFILE_LEN = 11;']
!     call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 9: Create a file with containing a single 'A'
    let s:test += 1
***************
*** 110,115 ****
--- 118,156 ----
    call PrepareBuffer(readfile('XXDfile')[0])
    call assert_equal('A', getline(1), s:Mess(s:test))
    call delete('XXDfile')
+ 
+   " Test 10: group with 4 octets
+   let s:test += 1
+   for arg in ['-g 4', '-group 4', '-g4']
+     call writefile(['TESTabcd09'], 'XXDfile')
+     %d
+     exe '0r! ' . s:xxd_cmd . ' ' . arg . ' XXDfile'
+     $d
+     let expected = ['00000000: 54455354 61626364 30390a             
TESTabcd09.']
+     call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
+     call delete('XXDfile')
+   endfor
+ 
+   " TODO:
+   " -o -offset
+ 
    %d
    bw!
  endfunc
+ 
+ " Various ways with wrong arguments that trigger the usage output.
+ func Test_xxd_usage()
+   for arg in ['-c', '-g', '-o', '-s', '-l', '-X', 'one two three']
+     new
+     exe 'r! ' . s:xxd_cmd . ' ' . arg
+     call assert_match("Usage:", join(getline(1, 3)))
+     bwipe!
+   endfor
+ endfunc
+ 
+ func Test_xxd_version()
+   new
+   exe 'r! ' . s:xxd_cmd . ' -v'
+   call assert_match("xxd V1.10 .* by Juergen Weigert", join(getline(1, 3)))
+   bwipe!
+ endfunc
*** ../vim-8.1.0820/src/xxd/xxd.c       2018-04-03 14:11:10.000000000 +0200
--- src/xxd/xxd.c       2019-01-25 21:46:21.129278533 +0100
***************
*** 508,517 ****
        }
        else if (!STRNCMP(pp, "-c", 2))
        {
!         if (pp[2] && STRNCMP("ols", pp + 2, 3))
!           cols = (int)strtol(pp + 2, NULL, 0);
!         else if (pp[2] && STRNCMP("apitalize", pp + 2, 9))
            capitalize = 1;
          else
            {
              if (!argv[2])
--- 508,517 ----
        }
        else if (!STRNCMP(pp, "-c", 2))
        {
!         if (pp[2] && !STRNCMP("apitalize", pp + 2, 9))
            capitalize = 1;
+         else if (pp[2] && STRNCMP("ols", pp + 2, 3))
+           cols = (int)strtol(pp + 2, NULL, 0);
          else
            {
              if (!argv[2])
***************
*** 523,529 ****
        }
        else if (!STRNCMP(pp, "-g", 2))
        {
!         if (pp[2] && STRNCMP("group", pp + 2, 5))
            octspergrp = (int)strtol(pp + 2, NULL, 0);
          else
            {
--- 523,529 ----
        }
        else if (!STRNCMP(pp, "-g", 2))
        {
!         if (pp[2] && STRNCMP("roup", pp + 2, 4))
            octspergrp = (int)strtol(pp + 2, NULL, 0);
          else
            {
*** ../vim-8.1.0820/src/version.c       2019-01-25 21:01:13.240877414 +0100
--- src/version.c       2019-01-25 21:51:57.926996288 +0100
***************
*** 789,790 ****
--- 789,792 ----
  {   /* Add new patch number below this line */
+ /**/
+     821,
  /**/

-- 
FATHER:    Who are you?
PRINCE:    I'm ... your son ...
FATHER:    Not you.
LAUNCELOT: I'm ... er ... Sir Launcelot, sir.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui