diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-03-01 00:11:43 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-01 10:47:19 +0100 |
commit | 500044906d1b90f1c8b1a2f5675a2f82ab92b758 (patch) | |
tree | 7d6aae259b188c1b6879c591eebdfd7f55d9b71c /Userland/Libraries/LibTest | |
parent | 60908adcbe2afd611233957bb3126f736eb18e25 (diff) | |
download | serenity-500044906d1b90f1c8b1a2f5675a2f82ab92b758.zip |
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in
StringViews and might have a non-properly-null-terminated string as a
value. As a bonus, using StringView (and DeprecatedString where
necessary) leads to nicer looking code too :^)
Diffstat (limited to 'Userland/Libraries/LibTest')
-rw-r--r-- | Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibTest/TestSuite.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index 6320fbb5d0..98a092a0cd 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -94,7 +94,7 @@ int main(int argc, char** argv) #endif bool print_json = false; bool per_file = false; - char const* specified_test_root = nullptr; + StringView specified_test_root; DeprecatedString common_path; DeprecatedString test_glob; @@ -143,7 +143,7 @@ int main(int argc, char** argv) DeprecatedString test_root; - if (specified_test_root) { + if (!specified_test_root.is_empty()) { test_root = DeprecatedString { specified_test_root }; } else { #ifdef AK_OS_SERENITY diff --git a/Userland/Libraries/LibTest/TestSuite.cpp b/Userland/Libraries/LibTest/TestSuite.cpp index 0c2238681a..d576f1d519 100644 --- a/Userland/Libraries/LibTest/TestSuite.cpp +++ b/Userland/Libraries/LibTest/TestSuite.cpp @@ -65,7 +65,7 @@ int TestSuite::main(DeprecatedString const& suite_name, Span<StringView> argumen bool do_tests_only = getenv("TESTS_ONLY") != nullptr; bool do_benchmarks_only = false; bool do_list_cases = false; - char const* search_string = "*"; + StringView search_string = "*"sv; args_parser.add_option(do_tests_only, "Only run tests.", "tests", 0); args_parser.add_option(do_benchmarks_only, "Only run benchmarks.", "bench", 0); |