Logo white

Peter M. Groen / CLI11

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • CLI11
  • tests
  • OptionalTest.cpp
  • Adding optional, refactor single file
    7a7064df
    Henry Fredrick Schreiner authored
    2018-04-04 18:29:32 +0200  
    Browse Code ยป
OptionalTest.cpp 425 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <cstdlib>
#include <iostream>

#if CLI11_OPTIONAL

#include "app_helper.hpp"

TEST_F(TApp, OptionalTest) {
    optional<int> opt;
    app.add_option("-c,--count", opt);
    run();
    EXPECT_FALSE(opt);

    app.reset();
    args = {"-c", "1"};
    run();
    EXPECT_TRUE(opt);
    EXPECT_EQ(*opt, 1);

    app.reset();
    args = {"--count", "3"};
    run();
    EXPECT_TRUE(opt);
    EXPECT_EQ(*opt, 3);
}

#endif