aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-11-23 19:36:57 +0100
committerSimon Warta <[email protected]>2015-11-23 20:53:58 +0100
commit2e3ce27502555f9068a361218e5d10d0bf3218c2 (patch)
treed363c7f225face5c30a79e6e0bd85d0cdd7c1bfc /src
parent9bff61f4c577661bf4a62a860baf190d4ea8ed6a (diff)
Enhance tests main readability
Diffstat (limited to 'src')
-rw-r--r--src/tests/main.cpp (renamed from src/tests/test_main.cpp)25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/tests/test_main.cpp b/src/tests/main.cpp
index 009073ae1..41d29d542 100644
--- a/src/tests/test_main.cpp
+++ b/src/tests/main.cpp
@@ -29,21 +29,20 @@ namespace {
using Botan_Tests::Test;
-int help(std::ostream& out, char* argv0)
+int help(std::ostream& out, const std::string binary_name)
{
std::ostringstream err;
err << "Usage:\n"
- << argv0 << " test1 test2 ...\n"
+ << binary_name << " test1 test2 ...\n"
<< "Available tests: ";
for(auto&& test : Test::registered_tests())
{
err << test << " ";
}
- err << "\n";
- out << err.str();
+ out << err.str() << std::endl;
return 1;
}
@@ -191,15 +190,13 @@ setup_tests(std::ostream& out, size_t threads, size_t soak_level, bool log_succe
return rng;
}
-}
-
-int main(int argc, char* argv[])
+int cpp_main(const std::vector<std::string> args)
{
try
{
- if(argc == 2 && (std::string(argv[1]) == "--help" || std::string(argv[1])== "help"))
+ if(args.size() == 2 && (args[1] == "--help" || args[1] == "help"))
{
- return help(std::cout, argv[0]);
+ return help(std::cout, args[0]);
}
size_t threads = 0;//std::thread::hardware_concurrency();
@@ -207,7 +204,7 @@ int main(int argc, char* argv[])
const std::string drbg_seed = "";
bool log_success = false;
- std::vector<std::string> req(argv + 1, argv + argc);
+ std::vector<std::string> req(args.begin()+1, args.end());
if(req.empty())
{
@@ -242,3 +239,11 @@ int main(int argc, char* argv[])
return 3;
}
}
+
+}
+
+int main(int argc, char* argv[])
+ {
+ std::vector<std::string> args(argv, argv + argc);
+ return cpp_main(args);
+ }