From a3e95c34322a600fe57cab43cee5f752096a9cf0 Mon Sep 17 00:00:00 2001 From: Juan Jose Comellas Date: Mon, 22 Jul 2013 12:00:43 -0300 Subject: [PATCH] Add tests for the different arguments that format_error/2 can receive --- test/getopt_test.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/getopt_test.erl b/test/getopt_test.erl index a642382..f8cf779 100644 --- a/test/getopt_test.erl +++ b/test/getopt_test.erl @@ -295,10 +295,19 @@ check_test_() -> ?_assertEqual({error, {missing_required_option, arg}}, check(OptSpecList, Opts))}, {"Parse arguments and check required options", ?_assertEqual({error, {missing_required_option, arg}}, parse_and_check(OptSpecList, ""))}, - {"Format error test 1", + {"Format missing option error test 1", ?_assertEqual("missing required option: -a (arg)", format_error(OptSpecList, {error, {missing_required_option, arg}}))}, - {"Format error test 2", + {"Format missing option error test 2", ?_assertEqual("missing required option: -a (arg)", - format_error(OptSpecList, {missing_required_option, arg}))} + format_error(OptSpecList, {missing_required_option, arg}))}, + {"Format invalid option error test 1", + ?_assertEqual("invalid option: --verbose", + format_error(OptSpecList, {error, {invalid_option, "--verbose"}}))}, + {"Format invalid option argument error test 1", + ?_assertEqual("invalid option argument: arg_value", + format_error(OptSpecList, {error, {invalid_option_arg, "arg_value"}}))}, + {"Format invalid option argument error test 2", + ?_assertEqual("option 'verbose' has invalid argument: 100", + format_error(OptSpecList, {error, {invalid_option_arg, {verbose, "100"}}}))} ].