Esempio n. 1
0
void ArgumentsTest::parseArgumentAfterSeparator() {
    Arguments args;
    args.addBooleanOption('b', "bar");

    const char* argv[] = { "", "--", "-b" };
    const int argc = std::extent<decltype(argv)>();

    std::ostringstream out;
    Error redirectError{&out};
    CORRADE_VERIFY(!args.tryParse(argc, argv));
    CORRADE_COMPARE(out.str(), "Superfluous command-line argument -b\n");
}
Esempio n. 2
0
void ArgumentsTest::parseHelp() {
    Arguments args;
    args.addBooleanOption("no-foo-bars");

    const char* argv[] = { "", "-h", "--no-foo-bars", "error" };
    const int argc = std::extent<decltype(argv)>();

    /* The parse() will not exit if help is set, but tryParse() should indicate
       the error */
    CORRADE_VERIFY(!args.tryParse(argc, argv));
    CORRADE_VERIFY(args.isSet("help"));
    CORRADE_VERIFY(args.isSet("no-foo-bars"));
}