/test/lib/cli/test_cli_07.e

http://github.com/tybor/Liberty · Specman e · 82 lines · 72 code · 9 blank · 1 comment · 1 complexity · 52a906ce950cb1519737a728af879a31 MD5 · raw file

  1. class TEST_CLI_07
  2. insert
  3. ARGUMENTS
  4. EIFFELTEST_TOOLS
  5. COMMAND_LINE_ARGUMENT_CUSTOM_FACTORY[AUX_CLI_07_CUSTOM_OPTION]
  6. create {}
  7. make
  8. feature {}
  9. make
  10. local
  11. custom_option: COMMAND_LINE_TYPED_ARGUMENT[TRAVERSABLE[AUX_CLI_07_CUSTOM_OPTION]]
  12. do
  13. custom_option := option_customs("c", "custom", "custom", "The custom option", agent validate(?), agent decode(?))
  14. create args.make(custom_option and no_parameters)
  15. -- check the custom option building
  16. setup
  17. command_arguments.add_last("-c")
  18. command_arguments.add_last("foo")
  19. assert(args.parse_command_line)
  20. assert(custom_option.item.count = 1)
  21. assert(custom_option.item.first.items.count = 1)
  22. assert(custom_option.item.first.items.fast_reference_at("foo".intern) = Void)
  23. setup
  24. command_arguments.add_last("-c")
  25. command_arguments.add_last("foo = ")
  26. assert(args.parse_command_line)
  27. assert(custom_option.item.count = 1)
  28. assert(custom_option.item.first.items.count = 1)
  29. assert(custom_option.item.first.items.fast_reference_at("foo".intern).is_empty)
  30. setup
  31. command_arguments.add_last("-cc")
  32. command_arguments.add_last("foo=something")
  33. command_arguments.add_last("bar=anything")
  34. assert(args.parse_command_line)
  35. assert(custom_option.item.count = 2)
  36. assert(custom_option.item.first.items.count = 1)
  37. assert(custom_option.item.first.items.fast_reference_at("foo".intern).is_equal("something"))
  38. assert(custom_option.item.last.items.count = 1)
  39. assert(custom_option.item.last.items.fast_reference_at("bar".intern).is_equal("anything"))
  40. setup
  41. command_arguments.add_last("-c")
  42. command_arguments.add_last("foo=something")
  43. command_arguments.add_last("-c")
  44. command_arguments.add_last("bar=anything")
  45. assert(args.parse_command_line)
  46. assert(custom_option.item.count = 2)
  47. assert(custom_option.item.first.items.count = 1)
  48. assert(custom_option.item.first.items.fast_reference_at("foo".intern).is_equal("something"))
  49. assert(custom_option.item.last.items.count = 1)
  50. assert(custom_option.item.last.items.fast_reference_at("bar".intern).is_equal("anything"))
  51. setup
  52. command_arguments.add_last("-c")
  53. command_arguments.add_last("foo = something else; bar = anything else ")
  54. assert(args.parse_command_line)
  55. assert(custom_option.item.count = 1)
  56. assert(custom_option.item.first.items.count = 2)
  57. assert(custom_option.item.first.items.fast_reference_at("foo".intern).is_equal("something else"))
  58. assert(custom_option.item.first.items.fast_reference_at("bar".intern).is_equal("anything else"))
  59. end
  60. setup
  61. do
  62. command_arguments.make(1)
  63. end
  64. args: COMMAND_LINE_ARGUMENTS
  65. validate (arg: STRING): BOOLEAN
  66. do
  67. Result := not arg.is_empty
  68. end
  69. decode (arg: STRING): AUX_CLI_07_CUSTOM_OPTION
  70. do
  71. create Result.make(arg)
  72. end
  73. end