diff options
| author | dobrokot <[email protected]> | 2022-02-10 16:49:07 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:07 +0300 | 
| commit | 8d57b69dee81198a59c39e64704f7dc9f04b4fbf (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/getopt | |
| parent | 25d83bf841d8b3ce3886525078f1964ac3c293c5 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt')
| -rw-r--r-- | library/cpp/getopt/small/opt.h | 6 | ||||
| -rw-r--r-- | library/cpp/getopt/ut/opt_ut.cpp | 48 | 
2 files changed, 27 insertions, 27 deletions
diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index 6bd81e62cb0..ecb57439bcf 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -94,9 +94,9 @@ public:      }      TVector<TString> GetFreeArgs() const { -        return NLastGetopt::TOptsParseResult(&*Opts_, GetArgC(), GetArgV()).GetFreeArgs();  -    }  -  +        return NLastGetopt::TOptsParseResult(&*Opts_, GetArgC(), GetArgV()).GetFreeArgs(); +    } +      // obsolete, use GetArg() instead      char* Arg; /* option argument if any or NULL */ diff --git a/library/cpp/getopt/ut/opt_ut.cpp b/library/cpp/getopt/ut/opt_ut.cpp index 01488317997..441aa493a0a 100644 --- a/library/cpp/getopt/ut/opt_ut.cpp +++ b/library/cpp/getopt/ut/opt_ut.cpp @@ -1,7 +1,7 @@  #include <library/cpp/getopt/opt.h>  #include <library/cpp/testing/unittest/registar.h> -#include <util/string/vector.h>  +#include <util/string/vector.h>  Y_UNIT_TEST_SUITE(OptTest) {      Y_UNIT_TEST(TestSimple) { @@ -15,38 +15,38 @@ Y_UNIT_TEST_SUITE(OptTest) {          UNIT_ASSERT_VALUES_EQUAL(EOF, opt.Get());          UNIT_ASSERT_VALUES_EQUAL(EOF, opt.Get());      } -  +      Y_UNIT_TEST(TestFreeArguments) { -        Opt::Ion options[] = {  +        Opt::Ion options[] = {              {"some-option", Opt::WithArg, nullptr, 123},              {nullptr, Opt::WithoutArg, nullptr, 0}};          const char* argv[] = {"cmd", "ARG1", "-some-option", "ARG2", "ARG3", nullptr}; -        int argc = 5;  -        Opt opts(argc, argv, "", options);  -  +        int argc = 5; +        Opt opts(argc, argv, "", options); +          UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3"); -    }  -  +    } +      Y_UNIT_TEST(TestLongOption) { -        const int SOME_OPTION_ID = 12345678;  -        Opt::Ion options[] = {  +        const int SOME_OPTION_ID = 12345678; +        Opt::Ion options[] = {              {"some-option", Opt::WithArg, nullptr, SOME_OPTION_ID},              {nullptr, Opt::WithoutArg, nullptr, 0}}; -        for (int doubleDash = 0; doubleDash <= 1; ++doubleDash) {  +        for (int doubleDash = 0; doubleDash <= 1; ++doubleDash) {              const char* argv[] = {"cmd", "ARG1", (doubleDash ? "--some-option" : "-some-option"), "ARG2", "ARG3", nullptr}; -            int argc = 5;  -            Opt opts(argc, argv, "", options);  -  +            int argc = 5; +            Opt opts(argc, argv, "", options); +              TString optionValue = ""; -            int optlet = 0;  -            while ((optlet = opts.Get()) != EOF) {  -                if (optlet == SOME_OPTION_ID) {  -                    optionValue = opts.GetArg();  +            int optlet = 0; +            while ((optlet = opts.Get()) != EOF) { +                if (optlet == SOME_OPTION_ID) { +                    optionValue = opts.GetArg();                  } else { -                    UNIT_FAIL("don't expected any options, except -some-option");  -                }  -            }  -            UNIT_ASSERT_VALUES_EQUAL(optionValue, "ARG2");  -        }  -    }  +                    UNIT_FAIL("don't expected any options, except -some-option"); +                } +            } +            UNIT_ASSERT_VALUES_EQUAL(optionValue, "ARG2"); +        } +    }  }  | 
