/test/lib/cli/test_cli_01.e

http://github.com/tybor/Liberty · Specman e · 60 lines · 43 code · 11 blank · 6 comment · 0 complexity · db08bc4d5d1bf0b846b13019ba973ba8 MD5 · raw file

  1. class TEST_CLI_01
  2. insert
  3. ARGUMENTS
  4. EIFFELTEST_TOOLS
  5. COMMAND_LINE_ARGUMENT_FACTORY
  6. create {}
  7. make
  8. feature {}
  9. make
  10. do
  11. -- the program takes no argument
  12. create args.make(no_parameters)
  13. args.set_helper(agent call_usage(?))
  14. -- an empty command line is valid
  15. setup
  16. assert(args.parse_command_line)
  17. assert(not usage_called)
  18. -- an extra argument is not valid...
  19. setup
  20. command_arguments.add_last(once "foo")
  21. assert(not args.parse_command_line)
  22. assert(not usage_called)
  23. -- ... except -h...
  24. setup
  25. command_arguments.add_last(once "-h")
  26. assert(args.parse_command_line)
  27. assert(usage_called)
  28. -- ... and --help
  29. setup
  30. command_arguments.add_last(once "--help")
  31. assert(args.parse_command_line)
  32. assert(usage_called)
  33. end
  34. setup
  35. do
  36. command_arguments.make(1)
  37. usage_called := False
  38. end
  39. args: COMMAND_LINE_ARGUMENTS
  40. usage_called: BOOLEAN
  41. call_usage (a_args: COMMAND_LINE_ARGUMENTS)
  42. do
  43. assert(a_args = args)
  44. -- a_args.usage(std_output)
  45. usage_called := True
  46. ensure
  47. usage_called
  48. end
  49. end