-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathvalued_argument_test.cpp
More file actions
87 lines (70 loc) · 2.14 KB
/
Copy pathvalued_argument_test.cpp
File metadata and controls
87 lines (70 loc) · 2.14 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <cmdstan/arguments/valued_argument.hpp>
#include <stan/callbacks/stream_writer.hpp>
#include <stan/callbacks/writer.hpp>
#include <gtest/gtest.h>
class test_arg_impl : public cmdstan::valued_argument {
std::string print_value() { return ""; }
std::string print_valid() { return ""; }
bool is_default() { return true; }
};
class CmdStanArgumentsValuedArgument : public testing::Test {
public:
void SetUp() { arg = new test_arg_impl; }
void TearDown() { delete (arg); }
cmdstan::argument *arg;
std::stringstream ss;
};
TEST_F(CmdStanArgumentsValuedArgument, Constructor) {
// test fixture would have created the argument.
}
TEST_F(CmdStanArgumentsValuedArgument, name) { EXPECT_EQ("", arg->name()); }
TEST_F(CmdStanArgumentsValuedArgument, description) {
EXPECT_EQ("", arg->description());
}
TEST_F(CmdStanArgumentsValuedArgument, print) {
// FIXME: write test
}
TEST_F(CmdStanArgumentsValuedArgument, print_help) {
// FIXME: write test
}
TEST_F(CmdStanArgumentsValuedArgument, parse_args) {
bool return_value;
std::vector<std::string> args;
bool help_flag;
stan::callbacks::stream_writer out(std::cout);
stan::callbacks::writer err;
return_value = false;
args.clear();
help_flag = false;
return_value = arg->parse_args(args, out, err, help_flag);
EXPECT_TRUE(return_value);
EXPECT_FALSE(help_flag);
EXPECT_EQ(0U, args.size());
return_value = false;
args.clear();
args.push_back("help");
help_flag = false;
return_value = arg->parse_args(args, out, err, help_flag);
EXPECT_TRUE(return_value);
EXPECT_FALSE(help_flag);
EXPECT_EQ(1U, args.size());
}
TEST_F(CmdStanArgumentsValuedArgument, parse_args_unexpected) {
bool return_value;
std::vector<std::string> args;
bool help_flag;
stan::callbacks::stream_writer out(ss);
stan::callbacks::writer err;
return_value = false;
args.clear();
args.push_back("foo=bar");
help_flag = false;
return_value = arg->parse_args(args, out, err, help_flag);
EXPECT_TRUE(return_value);
EXPECT_FALSE(help_flag);
EXPECT_EQ(1U, args.size());
}
TEST_F(CmdStanArgumentsValuedArgument, arg) {
EXPECT_EQ(0, arg->arg(""));
EXPECT_EQ(0, arg->arg("foo"));
}