Skip to content
Permalink
Browse files

error: Testcase fix and error message improvement

  • Loading branch information...
Piankero committed Jun 24, 2019
1 parent 56ebd3e commit b3c46c9443858c9caec4edcb98da6f2244336788
Showing with 8 additions and 8 deletions.
  1. +3 −3 src/libs/opts/opts.c
  2. +5 −5 tests/ctest/test_opts.c
@@ -558,7 +558,7 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio
if (shortOpt == '-')
{
ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey,
"'-' cannot be used as a short option. It would collide with the "
"Character '-' cannot be used as a short option. It would collide with the "
"special string '--'. Offending key: %s",
keyName (key));
return false;
@@ -567,7 +567,7 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio
if (shortOpt == 'h')
{
ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey,
"'h' cannot be used as a short option. It would collide with the "
"Character 'h' cannot be used as a short option. It would collide with the "
"help option '-h'. Offending key: %s",
keyName (key));
return false;
@@ -651,7 +651,7 @@ bool processLongOptSpec (struct Specification * spec, struct OptionData * option
if (elektraStrCmp (longOpt, "help") == 0)
{
ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey,
"'help' cannot be used as a long option. It would collide with the "
"Option 'help' cannot be used as a long option. It would collide with the "
"help option '--help'. Offending key: %s",
keyName (key));
return false;
@@ -557,7 +557,7 @@ static void test_illegal_spec (void)

RUN_TEST_ERROR (ks, errorKey, NO_ARGS, NO_ENVP);
succeed_if (checkError (errorKey, ELEKTRA_ERROR_VALIDATION_SEMANTIC,
"'-' cannot be used as a short option. It would collide with the "
"Character '-' cannot be used as a short option. It would collide with the "
"special string '--'. Offending key: " SPEC_BASE_KEY "/apple"),
"'-' option should be illegal");
clearValues (ks);
@@ -574,7 +574,7 @@ static void test_illegal_spec (void)

RUN_TEST_ERROR (ks, errorKey, NO_ARGS, NO_ENVP);
succeed_if (checkError (errorKey, ELEKTRA_ERROR_VALIDATION_SEMANTIC,
"'h' cannot be used as a short option. It would collide with the "
"Character 'h' cannot be used as a short option. It would collide with the "
"help option '-h'. Offending key: " SPEC_BASE_KEY "/apple"),
"'h' option should be illegal");
clearValues (ks);
@@ -591,7 +591,7 @@ static void test_illegal_spec (void)

RUN_TEST_ERROR (ks, errorKey, NO_ARGS, NO_ENVP);
succeed_if (checkError (errorKey, ELEKTRA_ERROR_VALIDATION_SEMANTIC,
"'help' cannot be used as a long option. It would collide with the "
"Option 'help' cannot be used as a long option. It would collide with the "
"help option '--help'. Offending key: " SPEC_BASE_KEY "/apple"),
"'help' option should be illegal");
clearValues (ks);
@@ -673,15 +673,15 @@ static void test_illegal_use (void)
RUN_TEST_ERROR (ks, errorKey, ARGS ("-a", "short0", "-ashort1", "-a", "short2", "-b", "short3", "-bshort4"), NO_ENVP);
succeed_if (checkError (errorKey, ELEKTRA_ERROR_VALIDATION_SEMANTIC,
"The option '-b' cannot be used, because another option has already been used for the key "
"'" SPEC_BASE_KEY "/apple/#'."),
"'" SPEC_BASE_KEY "/apple/#'"),
"multiple repeated short options should have failed");
clearValues (ks);

RUN_TEST_ERROR (ks, errorKey, ARGS ("--apple", "long0", "--apple=long1", "--apple", "long2", "--banana=long3", "--banana", "long4"),
NO_ENVP);
succeed_if (checkError (errorKey, ELEKTRA_ERROR_VALIDATION_SEMANTIC,
"The option '--banana' cannot be used, because another option has already been used for the key "
"'" SPEC_BASE_KEY "/apple/#'."),
"'" SPEC_BASE_KEY "/apple/#'"),
"multiple repeated long options should have failed");
clearValues (ks);

0 comments on commit b3c46c9

Please sign in to comment.
You can’t perform that action at this time.