My dotfiles. Period.

test-Fargs2String.vim 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. "=============================================================================
  2. " $Id: test-Fargs2String.vim 520 2012-03-19 18:09:15Z luc.hermitte $
  3. " File: tests/lh/test-Fargs2String.vim {{{1
  4. " Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
  5. " <URL:http://code.google.com/p/lh-vim/>
  6. " License: GPLv3 with exceptions
  7. " <URL:http://code.google.com/p/lh-vim/wiki/License>
  8. " Version: 3.0.0
  9. " Created: 16th Apr 2007
  10. " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
  11. "------------------------------------------------------------------------
  12. " Description: Tests for lh-vim-lib . lh#command#Fargs2String
  13. "
  14. "------------------------------------------------------------------------
  15. " Installation:
  16. " Relies on the version «patched by myself|1?» of vim_units
  17. " History: «history»
  18. " TODO: «missing features»
  19. " }}}1
  20. "=============================================================================
  21. function! s:TestEmpty()
  22. let empty = []
  23. let res = lh#command#Fargs2String(empty)
  24. call VUAssertEquals(len(empty), 0, 'Expected empty', 22)
  25. call VUAssertEquals(res, '', 'Expected empty result', 23)
  26. endfunction
  27. function! s:TestSimpleText1()
  28. let expected = 'text'
  29. let one = [ expected ]
  30. let res = lh#command#Fargs2String(one)
  31. call VUAssertEquals(len(one), 0, 'Expected empty', 27)
  32. call VUAssertEquals(res, expected, 'Expected a simple result', 28)
  33. endfunction
  34. function! s:TestSimpleTextN()
  35. let expected = 'text'
  36. let list = [ expected , 'stuff1', 'stuff2']
  37. let res = lh#command#Fargs2String(list)
  38. call VUAssertEquals(len(list), 2, 'Expected not empty', 38)
  39. call VUAssertEquals(res, expected, 'Expected a simple result', 39)
  40. endfunction
  41. function! s:TestComposedN()
  42. let expected = '"a several tokens string"'
  43. let list = [ '"a', 'several', 'tokens', 'string"', 'stuff1', 'stuff2']
  44. let res = lh#command#Fargs2String(list)
  45. call VUAssertEquals(len(list), 2, 'Expected not empty', 46)
  46. call VUAssertEquals(res, expected, 'Expected a composed string', 47)
  47. call VUAssertEquals(list, ['stuff1', 'stuff2'], 'Expected a list', 48)
  48. call VUAssertNotSame(list, ['stuff1', 'stuff2'], 'Expected different lists', 49)
  49. endfunction
  50. function! s:TestComposed1()
  51. let expected = '"string"'
  52. let list = [ '"string"', 'stuff1', 'stuff2']
  53. let res = lh#command#Fargs2String(list)
  54. call VUAssertEquals(len(list), 2, 'Expected not empty', 56)
  55. call VUAssertEquals(res, expected, 'Expected a string', 57)
  56. call VUAssertEquals(list, ['stuff1', 'stuff2'], 'Expected a list', 58)
  57. call VUAssertNotSame(list, ['stuff1', 'stuff2'], 'Expected different lists', 59)
  58. endfunction
  59. function! s:TestInvalidString()
  60. let expected = '"a string'
  61. let list = [ '"a', 'string']
  62. let res = lh#command#Fargs2String(list)
  63. call VUAssertEquals(len(list), 0, 'Expected empty', 66)
  64. call VUAssertEquals(res, expected, 'Expected an invalid string', 67)
  65. endfunction
  66. function! AllTests()
  67. call s:TestEmpty()
  68. call s:TestSimpleText1()
  69. call s:TestSimpleTextN()
  70. call s:TestComposed1()
  71. call s:TestComposedN()
  72. endfunction
  73. " call VURunnerRunTest('AllTests')
  74. VURun % AllTests
  75. "=============================================================================
  76. " vim600: set fdm=marker: