From 1a8c5c4b5038286a346c3d5e3eb69813d1aa1be3 Mon Sep 17 00:00:00 2001 From: Lydia Buntrock Date: Fri, 17 Dec 2021 12:15:08 +0100 Subject: [PATCH] [MISC] Remove dependency of seqan3::detail::test_accessor. Signed-off-by: Lydia Buntrock --- include/sharg/argument_parser.hpp | 4 +- include/sharg/detail/format_help.hpp | 12 +-- include/sharg/detail/test_accessor.hpp | 26 +++++ test/unit/detail/format_help_test.cpp | 36 +++---- test/unit/detail/version_check_test.hpp | 6 +- test/unit/format_parse_validators_test.cpp | 114 ++++++++++----------- 6 files changed, 107 insertions(+), 91 deletions(-) create mode 100644 include/sharg/detail/test_accessor.hpp diff --git a/include/sharg/argument_parser.hpp b/include/sharg/argument_parser.hpp index 8351a87f..3bca795a 100644 --- a/include/sharg/argument_parser.hpp +++ b/include/sharg/argument_parser.hpp @@ -605,8 +605,8 @@ class argument_parser //!\brief Whether the **user** specified to perform the version check (true) or not (false), default unset. std::optional version_check_user_decision; - //!\brief Befriend seqan3::detail::test_accessor to grant access to version_check_future and format. - friend struct ::seqan3::detail::test_accessor; + //!\brief Befriend sharg::detail::test_accessor to grant access to version_check_future and format. + friend struct ::sharg::detail::test_accessor; //!\brief The future object that keeps track of the detached version check call thread. std::future version_check_future; diff --git a/include/sharg/detail/format_help.hpp b/include/sharg/detail/format_help.hpp index 0726c477..3b65953b 100644 --- a/include/sharg/detail/format_help.hpp +++ b/include/sharg/detail/format_help.hpp @@ -16,13 +16,7 @@ #include #include - -namespace seqan3::detail -{ - -struct test_accessor; - -} // seqan3::detail +#include namespace sharg::detail { @@ -380,8 +374,8 @@ class format_help : public format_help_base //!\brief Needed for correct formatting while calling different print functions. bool prev_was_paragraph{false}; - //!\brief Befriend seqan3::detail::test_accessor to grant access to layout. - friend struct ::seqan3::detail::test_accessor; + //!\brief Befriend sharg::detail::test_accessor to grant access to layout. + friend struct ::sharg::detail::test_accessor; //!\brief Stores the relevant parameters of the documentation on the screen. console_layout_struct layout{}; diff --git a/include/sharg/detail/test_accessor.hpp b/include/sharg/detail/test_accessor.hpp new file mode 100644 index 00000000..76d3e9e5 --- /dev/null +++ b/include/sharg/detail/test_accessor.hpp @@ -0,0 +1,26 @@ +// ----------------------------------------------------------------------------------------------------------- +// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin +// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik +// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md +// ----------------------------------------------------------------------------------------------------------- + +/*!\file + * \brief Forward declares sharg::detail::test_accessor. + * \author Lydia Buntrock + */ + +#pragma once + +#include + +namespace sharg::detail +{ + +/*!\brief Attorney-Client pattern for accessing private / protected class members in test cases. + * \attention You can currently only have one definition of test_accessor in one translation unit. + * \see https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Friendship_and_the_Attorney-Client + */ +struct test_accessor; + +} // sharg::detail diff --git a/test/unit/detail/format_help_test.cpp b/test/unit/detail/format_help_test.cpp index 73336ff3..c59a41ef 100644 --- a/test/unit/detail/format_help_test.cpp +++ b/test/unit/detail/format_help_test.cpp @@ -55,7 +55,7 @@ std::string license_text() return str.substr(license_start, license_end - license_start); } -namespace seqan3::detail +namespace sharg::detail { struct test_accessor { @@ -68,15 +68,13 @@ struct test_accessor }, parser.format); } }; -} // seqan3::detail - -using seqan3::detail::test_accessor; +} // sharg::detail TEST(help_page_printing, short_help) { // Empty call with no options given. For sharg::detail::format_short_help sharg::argument_parser parser0{"empty_options", 1, argv0}; - test_accessor::set_terminal_width(parser0, 80); + sharg::detail::test_accessor::set_terminal_width(parser0, 80); parser0.info.synopsis.push_back("./some_binary_name synopsis"); testing::internal::CaptureStdout(); EXPECT_EXIT(parser0.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -93,7 +91,7 @@ TEST(help_page_printing, no_information) { // Empty help call with -h sharg::argument_parser parser1{"test_parser", 2, argv1}; - test_accessor::set_terminal_width(parser1, 80); + sharg::detail::test_accessor::set_terminal_width(parser1, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser1.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); std_cout = testing::internal::GetCapturedStdout(); @@ -110,7 +108,7 @@ TEST(help_page_printing, with_short_copyright) { // Again, but with short copyright, long copyright, and citation. sharg::argument_parser short_copy("test_parser", 2, argv1); - test_accessor::set_terminal_width(short_copy, 80); + sharg::detail::test_accessor::set_terminal_width(short_copy, 80); short_copy.info.short_copyright = "short"; testing::internal::CaptureStdout(); EXPECT_EXIT(short_copy.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -132,7 +130,7 @@ TEST(help_page_printing, with_short_copyright) TEST(help_page_printing, with_long_copyright) { sharg::argument_parser long_copy("test_parser", 2, argv1); - test_accessor::set_terminal_width(long_copy, 80); + sharg::detail::test_accessor::set_terminal_width(long_copy, 80); long_copy.info.long_copyright = "long"; testing::internal::CaptureStdout(); EXPECT_EXIT(long_copy.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -154,7 +152,7 @@ TEST(help_page_printing, with_long_copyright) TEST(help_page_printing, with_citation) { sharg::argument_parser citation("test_parser", 2, argv1); - test_accessor::set_terminal_width(citation, 80); + sharg::detail::test_accessor::set_terminal_width(citation, 80); citation.info.citation = "citation"; testing::internal::CaptureStdout(); EXPECT_EXIT(citation.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -176,7 +174,7 @@ TEST(help_page_printing, with_citation) TEST(help_page_printing, with_author) { sharg::argument_parser author("test_parser", 2, argv1); - test_accessor::set_terminal_width(author, 80); + sharg::detail::test_accessor::set_terminal_width(author, 80); author.info.author = "author"; testing::internal::CaptureStdout(); EXPECT_EXIT(author.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -198,7 +196,7 @@ TEST(help_page_printing, with_author) TEST(help_page_printing, with_email) { sharg::argument_parser email("test_parser", 2, argv1); - test_accessor::set_terminal_width(email, 80); + sharg::detail::test_accessor::set_terminal_width(email, 80); email.info.email = "email"; testing::internal::CaptureStdout(); EXPECT_EXIT(email.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -221,7 +219,7 @@ TEST(help_page_printing, empty_advanced_help) { // Empty help call with -hh sharg::argument_parser parser2{"test_parser", 2, argv2}; - test_accessor::set_terminal_width(parser2, 80); + sharg::detail::test_accessor::set_terminal_width(parser2, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser2.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); std_cout = testing::internal::GetCapturedStdout(); @@ -238,7 +236,7 @@ TEST(help_page_printing, empty_version_call) { // Empty version call sharg::argument_parser parser3{"test_parser", 2, argv3}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser3.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); std_cout = testing::internal::GetCapturedStdout(); @@ -253,7 +251,7 @@ TEST(help_page_printing, version_call) { // Version call with url and options. sharg::argument_parser parser4{"test_parser", 2, argv3}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.info.url = "https://seqan.de"; parser4.add_option(option_value, 'i', "int", "this is a int option."); parser4.add_flag(flag_value, 'f', "flag", "this is a flag."); @@ -275,7 +273,7 @@ TEST(help_page_printing, do_not_print_hidden_options) { // Add an option and request help. sharg::argument_parser parser5{"test_parser", 2, argv1}; - test_accessor::set_terminal_width(parser5, 80); + sharg::detail::test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_value, 'i', "int", "this is a int option.", sharg::option_spec::hidden); parser5.add_flag(flag_value, 'f', "flag", "this is a flag.", sharg::option_spec::hidden); testing::internal::CaptureStdout(); @@ -325,7 +323,7 @@ TEST(help_page_printing, advanced_options) // without -hh, only the non/advanced information are shown sharg::argument_parser parser_normal_help{"test_parser", 2, argv1}; - test_accessor::set_terminal_width(parser_normal_help, 80); + sharg::detail::test_accessor::set_terminal_width(parser_normal_help, 80); set_up(parser_normal_help); testing::internal::CaptureStdout(); EXPECT_EXIT(parser_normal_help.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -351,7 +349,7 @@ TEST(help_page_printing, advanced_options) // with -hh everything is shown sharg::argument_parser parser_advanced_help{"test_parser", 2, argv2}; - test_accessor::set_terminal_width(parser_advanced_help, 80); + sharg::detail::test_accessor::set_terminal_width(parser_advanced_help, 80); set_up(parser_advanced_help); testing::internal::CaptureStdout(); EXPECT_EXIT(parser_advanced_help.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -407,7 +405,7 @@ TEST(help_page_printing, full_information) // Add synopsis, description, short description, positional option, option, flag, and example. sharg::argument_parser parser6{"test_parser", 2, argv1}; - test_accessor::set_terminal_width(parser6, 80); + sharg::detail::test_accessor::set_terminal_width(parser6, 80); parser6.info.synopsis.push_back("./some_binary_name synopsis"); parser6.info.synopsis.push_back("./some_binary_name synopsis2"); parser6.info.description.push_back("description"); @@ -551,7 +549,7 @@ TEST(parse_test, subcommand_argument_parser) argv, sharg::update_notifications::on, {"sub1", "sub2"}}; - test_accessor::set_terminal_width(top_level_parser, 80); + sharg::detail::test_accessor::set_terminal_width(top_level_parser, 80); top_level_parser.info.description.push_back("description"); top_level_parser.add_option(option_value, 'f', "foo", "foo bar."); diff --git a/test/unit/detail/version_check_test.hpp b/test/unit/detail/version_check_test.hpp index f7c6b1c9..0c438db0 100644 --- a/test/unit/detail/version_check_test.hpp +++ b/test/unit/detail/version_check_test.hpp @@ -14,7 +14,7 @@ // test fixtures //------------------------------------------------------------------------------ -namespace seqan3::detail +namespace sharg::detail { struct test_accessor { @@ -23,11 +23,11 @@ struct test_accessor return parser.version_check_future; } }; -} // seqan3::detail +} // sharg::detail bool wait_for(sharg::argument_parser & parser) { - auto & future = seqan3::detail::test_accessor::version_check_future(parser); + auto & future = sharg::detail::test_accessor::version_check_future(parser); if (future.valid()) return future.get(); diff --git a/test/unit/format_parse_validators_test.cpp b/test/unit/format_parse_validators_test.cpp index 54174865..4987680e 100644 --- a/test/unit/format_parse_validators_test.cpp +++ b/test/unit/format_parse_validators_test.cpp @@ -46,7 +46,7 @@ std::string const basic_version_str = "VERSION\n" " test_parser version:\n" " SeqAn version: " + std::string{sharg::sharg_version_cstring} + "\n"; -namespace seqan3::detail +namespace sharg::detail { struct test_accessor { @@ -59,9 +59,7 @@ struct test_accessor }, parser.format); } }; -} // seqan3::detail - -using seqan3::detail::test_accessor; +} // sharg::detail TEST(validator_test, fullfill_concept) { @@ -145,7 +143,7 @@ TEST(validator_test, input_file) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-i", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(file_in_path, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::input_file_validator{formats}); @@ -162,7 +160,7 @@ TEST(validator_test, input_file) const char * argv[] = {"./argument_parser_test", path.c_str(), path_2.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(input_files, "desc", sharg::input_file_validator{formats}); EXPECT_NO_THROW(parser.parse()); @@ -175,7 +173,7 @@ TEST(validator_test, input_file) std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", sharg::input_file_validator{formats}); testing::internal::CaptureStdout(); @@ -276,7 +274,7 @@ TEST(validator_test, output_file) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-o", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(file_out_path, 'o', "out-option", "desc", sharg::option_spec::standard, sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); @@ -294,7 +292,7 @@ TEST(validator_test, output_file) const char * argv[] = {"./argument_parser_test", path.c_str(), path_3.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(output_files, "desc", sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); @@ -309,7 +307,7 @@ TEST(validator_test, output_file) std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); @@ -336,7 +334,7 @@ TEST(validator_test, output_file) std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", sharg::output_file_validator{sharg::output_file_open_options::open_or_create, formats}); @@ -412,7 +410,7 @@ TEST(validator_test, input_directory) std::string const & path = p.string(); const char * argv[] = {"./argument_parser_test", "-i", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(dir_in_path, 'i', "input-option", "desc", sharg::option_spec::standard, sharg::input_directory_validator{}); @@ -426,7 +424,7 @@ TEST(validator_test, input_directory) std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", sharg::input_directory_validator{}); testing::internal::CaptureStdout(); @@ -464,7 +462,7 @@ TEST(validator_test, output_directory) std::string const & path = p.string(); const char * argv[] = {"./argument_parser_test", "-o", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(dir_out_path, 'o', "output-option", "desc", sharg::option_spec::standard, sharg::output_directory_validator{}); @@ -489,7 +487,7 @@ TEST(validator_test, output_directory) std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", sharg::output_directory_validator{}); testing::internal::CaptureStdout(); @@ -689,7 +687,7 @@ TEST(validator_test, arithmetic_range_validator_success) // option const char * argv[] = {"./argument_parser_test", "-i", "10"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); @@ -701,7 +699,7 @@ TEST(validator_test, arithmetic_range_validator_success) // option - negative values const char * argv2[] = {"./argument_parser_test", "-i", "-10"}; sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser2, 80); + sharg::detail::test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{-20, 20}); @@ -713,7 +711,7 @@ TEST(validator_test, arithmetic_range_validator_success) // positional option const char * argv3[] = {"./argument_parser_test", "10"}; sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{1, 20}); testing::internal::CaptureStderr(); @@ -724,7 +722,7 @@ TEST(validator_test, arithmetic_range_validator_success) // positional option - negative values const char * argv4[] = {"./argument_parser_test", "--", "-10"}; sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{-20, 20}); testing::internal::CaptureStderr(); @@ -735,7 +733,7 @@ TEST(validator_test, arithmetic_range_validator_success) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "48"}; sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser5, 80); + sharg::detail::test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{-50,50}); @@ -749,7 +747,7 @@ TEST(validator_test, arithmetic_range_validator_success) option_vector.clear(); const char * argv6[] = {"./argument_parser_test", "--", "-10", "1"}; sharg::argument_parser parser6{"test_parser", 4, argv6, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser6, 80); + sharg::detail::test_accessor::set_terminal_width(parser6, 80); parser6.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20,20}); testing::internal::CaptureStderr(); @@ -762,7 +760,7 @@ TEST(validator_test, arithmetic_range_validator_success) option_vector.clear(); const char * argv7[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser7{"test_parser", 2, argv7, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser7, 80); + sharg::detail::test_accessor::set_terminal_width(parser7, 80); parser7.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20,20}); testing::internal::CaptureStdout(); @@ -784,7 +782,7 @@ TEST(validator_test, arithmetic_range_validator_success) double double_option_value; const char * argv8[] = {"./argument_parser_test", "-i", "10.9"}; sharg::argument_parser parser8{"test_parser", 3, argv8, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser8, 80); + sharg::detail::test_accessor::set_terminal_width(parser8, 80); parser8.add_option(double_option_value, 'i', "double-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); @@ -802,7 +800,7 @@ TEST(validator_test, arithmetic_range_validator_error) // option - above max const char * argv[] = {"./argument_parser_test", "-i", "30"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); @@ -811,7 +809,7 @@ TEST(validator_test, arithmetic_range_validator_error) // option - below min const char * argv2[] = {"./argument_parser_test", "-i", "-21"}; sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser2, 80); + sharg::detail::test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{-20, 20}); @@ -820,7 +818,7 @@ TEST(validator_test, arithmetic_range_validator_error) // positional option - above max const char * argv3[] = {"./argument_parser_test", "30"}; sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{1, 20}); EXPECT_THROW(parser3.parse(), sharg::validation_error); @@ -828,7 +826,7 @@ TEST(validator_test, arithmetic_range_validator_error) // positional option - below min const char * argv4[] = {"./argument_parser_test", "--", "-21"}; sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{-20, 20}); EXPECT_THROW(parser4.parse(), sharg::validation_error); @@ -836,7 +834,7 @@ TEST(validator_test, arithmetic_range_validator_error) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-100"}; sharg::argument_parser parser5{"test_parser", 3, argv5, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser5, 80); + sharg::detail::test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{-50, 50}); @@ -846,7 +844,7 @@ TEST(validator_test, arithmetic_range_validator_error) option_vector.clear(); const char * argv6[] = {"./argument_parser_test", "--", "-10", "100"}; sharg::argument_parser parser6{"test_parser", 4, argv6, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser6, 80); + sharg::detail::test_accessor::set_terminal_width(parser6, 80); parser6.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20, 20}); EXPECT_THROW(parser6.parse(), sharg::validation_error); @@ -855,7 +853,7 @@ TEST(validator_test, arithmetic_range_validator_error) double double_option_value; const char * argv7[] = {"./argument_parser_test", "-i", "0.9"}; sharg::argument_parser parser7{"test_parser", 3, argv7, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser7, 80); + sharg::detail::test_accessor::set_terminal_width(parser7, 80); parser7.add_option(double_option_value, 'i', "double-option", "desc", sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); @@ -915,7 +913,7 @@ TEST(validator_test, value_list_validator_success) std::vector valid_str_values{"ha", "ba", "ma"}; const char * argv[] = {"./argument_parser_test", "-s", "ba"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{valid_str_values | std::views::take(2)}); @@ -928,7 +926,7 @@ TEST(validator_test, value_list_validator_success) // option with integers const char * argv2[] = {"./argument_parser_test", "-i", "-21"}; sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser2, 80); + sharg::detail::test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value_int, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{0, -21, 10}); @@ -940,7 +938,7 @@ TEST(validator_test, value_list_validator_success) // positional option const char * argv3[] = {"./argument_parser_test", "ma"}; sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_value, "desc", sharg::value_list_validator{valid_str_values}); testing::internal::CaptureStderr(); @@ -951,7 +949,7 @@ TEST(validator_test, value_list_validator_success) // positional option - vector const char * argv4[] = {"./argument_parser_test", "ha", "ma"}; sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.add_positional_option(option_vector, "desc", sharg::value_list_validator{"ha", "ba", "ma"}); testing::internal::CaptureStderr(); @@ -963,7 +961,7 @@ TEST(validator_test, value_list_validator_success) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "48"}; sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser5, 80); + sharg::detail::test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector_int, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); @@ -977,7 +975,7 @@ TEST(validator_test, value_list_validator_success) option_vector_int.clear(); const char * argv7[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser7{"test_parser", 2, argv7, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser7, 80); + sharg::detail::test_accessor::set_terminal_width(parser7, 80); parser7.add_option(option_vector_int, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); @@ -1005,7 +1003,7 @@ TEST(validator_test, value_list_validator_error) // option const char * argv[] = {"./argument_parser_test", "-s", "sa"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{"ha", "ba", "ma"}); @@ -1014,7 +1012,7 @@ TEST(validator_test, value_list_validator_error) // positional option const char * argv3[] = {"./argument_parser_test", "30"}; sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_value_int, "desc", sharg::value_list_validator{0, 5, 10}); EXPECT_THROW(parser3.parse(), sharg::validation_error); @@ -1022,7 +1020,7 @@ TEST(validator_test, value_list_validator_error) // positional option - vector const char * argv4[] = {"./argument_parser_test", "fo", "ma"}; sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.add_positional_option(option_vector, "desc", sharg::value_list_validator{"ha", "ba", "ma"}); @@ -1031,7 +1029,7 @@ TEST(validator_test, value_list_validator_error) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "488"}; sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser5, 80); + sharg::detail::test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector_int, 'i', "int-option", "desc", sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); @@ -1048,7 +1046,7 @@ TEST(validator_test, regex_validator_success) { // option const char * argv[] = {"./argument_parser_test", "-s", "ballo@rollo.com"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, email_validator); @@ -1061,7 +1059,7 @@ TEST(validator_test, regex_validator_success) { // positional option const char * argv[] = {"./argument_parser_test", "chr1"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(option_value, "desc", sharg::regex_validator{"^chr[0-9]+"}); @@ -1074,7 +1072,7 @@ TEST(validator_test, regex_validator_success) { // positional option - vector const char * argv[] = {"./argument_parser_test", "rollo", "bollo", "lollo"}; sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(option_vector, "desc", sharg::regex_validator{".*oll.*"}); @@ -1090,7 +1088,7 @@ TEST(validator_test, regex_validator_success) option_vector.clear(); const char * argv[] = {"./argument_parser_test", "-s", "rita@rambo.com", "-s", "tina@rambo.com"}; sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_vector, 's', "string-option", "desc", sharg::option_spec::standard, email_vector_validator); @@ -1105,7 +1103,7 @@ TEST(validator_test, regex_validator_success) std::filesystem::path path_option; const char * argv[] = {"./argument_parser_test", "-s", "rita@rambo.com"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(path_option, 's', "string-option", "desc", sharg::option_spec::standard, email_vector_validator); @@ -1119,7 +1117,7 @@ TEST(validator_test, regex_validator_success) option_vector.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_vector, 's', "string-option", "desc", sharg::option_spec::standard, email_vector_validator); @@ -1148,7 +1146,7 @@ TEST(validator_test, regex_validator_error) // option const char * argv[] = {"./argument_parser_test", "--string-option", "sally"}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, '\0', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"tt"}); @@ -1157,7 +1155,7 @@ TEST(validator_test, regex_validator_error) // positional option const char * argv2[] = {"./argument_parser_test", "jessy"}; sharg::argument_parser parser2{"test_parser", 2, argv2, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser2, 80); + sharg::detail::test_accessor::set_terminal_width(parser2, 80); parser2.add_positional_option(option_value, "desc", sharg::regex_validator{"[0-9]"}); @@ -1166,7 +1164,7 @@ TEST(validator_test, regex_validator_error) // positional option - vector const char * argv3[] = {"./argument_parser_test", "rollo", "bttllo", "lollo"}; sharg::argument_parser parser3{"test_parser", 4, argv3, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser3, 80); + sharg::detail::test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_vector, "desc", sharg::regex_validator{".*oll.*"}); @@ -1176,7 +1174,7 @@ TEST(validator_test, regex_validator_error) option_vector.clear(); const char * argv4[] = {"./argument_parser_test", "-s", "gh", "-s", "tt"}; sharg::argument_parser parser4{"test_parser", 5, argv4, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser4, 80); + sharg::detail::test_accessor::set_terminal_width(parser4, 80); parser4.add_option(option_vector, 's', "", "desc", sharg::option_spec::standard, sharg::regex_validator{"tt"}); @@ -1277,7 +1275,7 @@ TEST(validator_test, chaining_validators) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); @@ -1291,7 +1289,7 @@ TEST(validator_test, chaining_validators) auto rel_path = tmp_name.get_path().relative_path().string(); const char * argv[] = {"./argument_parser_test", "-s", rel_path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); @@ -1302,7 +1300,7 @@ TEST(validator_test, chaining_validators) std::string const & path = invalid_extension.string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); @@ -1314,7 +1312,7 @@ TEST(validator_test, chaining_validators) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | @@ -1331,7 +1329,7 @@ TEST(validator_test, chaining_validators) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | @@ -1349,7 +1347,7 @@ TEST(validator_test, chaining_validators) option_value.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | @@ -1378,7 +1376,7 @@ TEST(validator_test, chaining_validators) option_value.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | @@ -1407,7 +1405,7 @@ TEST(validator_test, chaining_validators) std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - test_accessor::set_terminal_width(parser, 80); + sharg::detail::test_accessor::set_terminal_width(parser, 80); parser.add_option(option_list_value, 's', "string-option", "desc", sharg::option_spec::standard, sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} |