blob: b52f7855aa0a8fc2bfa69a5807210f3cf657aa47 [file] [log] [blame]
#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#include <string>
#include <vector>
int program(int argc, const char** argv);
class dt_removed
{
public:
dt_removed(const char** argv)
: vec(0) {
for(; *argv; ++argv)
if(!starts_with(*argv, "--dt-"))
vec.push_back(*argv);
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif // > gcc 4.6
vec.push_back(NULL);
}
int argc() { return static_cast<int>(vec.size()) - 1; }
const char** argv() { return &vec[0]; } // Note: non-const char **:
private:
static bool starts_with(std::string text, std::string with) {
return with == text.substr(0, with.length());
}
std::vector<const char*> vec;
};
int main(int argc, const char** argv) {
doctest::Context context(argc, argv);
int test_result = context.run(); // run queries, or run tests unless --no-run
if(context.shouldExit()) // honor query flags and --exit
return test_result;
dt_removed args(argv);
int app_result = program(args.argc(), args.argv());
return test_result + app_result;
}
TEST_CASE("Fail") { REQUIRE(0); }
TEST_CASE("Pass") { REQUIRE(1); }
int program(int argc, const char** argv) {
printf("Program: %d arguments received:\n", argc - 1);
while(*++argv)
printf("'%s'\n", *argv);
return EXIT_SUCCESS;
}