-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathoptiontest.cpp
More file actions
27 lines (25 loc) · 817 Bytes
/
optiontest.cpp
File metadata and controls
27 lines (25 loc) · 817 Bytes
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 <options.hpp>
#include <unit.hpp>
struct Config {
int value = 0;
};
UNITTEST(optiontest) {
const char* argv[14] = {"./optiontest", "--test", "1", "-b",
"true", "-c", "3", "-f", "0", "--funs", "1", "-f", "2", "-h"};
int argc = 13;
Config config;
bool b = "false";
int c;
std::vector<int> fs;
sweet::Options opt(argc, const_cast<char**>(argv));
opt.get("-bt", "--bool", "test if bool were set alot more bool"
"more boring test sjfalaskjdflkjsdfl kjasldfkjalsdkfj "
" asldfjasldf jalsdfkj ksjdfl jlksjdfl kjljfdsaf", b);
opt.get("-c", "--intlong", "test if int were set", config.value);
opt.getMultiple("-f", "--funs", "test if multiple int were set", fs);
opt.finalize();
std::cout<<__LINE__<<" "<<b<<" "<<config.value<<std::endl;
for(auto f : fs) {
std::cout<<f<<std::endl;
}
}