1 #include "CppUnitTest.h"
3 #include "../Hazelnupp/Hazelnupp.h"
5 using namespace Microsoft::VisualStudio::CppUnitTestFramework;
14 TEST_METHOD(KeysExist)
18 "/my/fake/path/wahoo.out",
41 nupp.RegisterAbbreviation(
"-ms",
"--my_string");
42 nupp.RegisterAbbreviation(
"-mv",
"--my_void");
43 nupp.RegisterAbbreviation(
"-mi",
"--my_int");
44 nupp.RegisterAbbreviation(
"-mf",
"--my_float");
45 nupp.RegisterAbbreviation(
"-mnl",
"--my_num_list");
46 nupp.RegisterAbbreviation(
"-msl",
"--my_str_list");
48 nupp.Parse(
C_Ify(args));
51 Assert::IsTrue(nupp.HasParam(
"--my_string"));
52 Assert::IsTrue(nupp.HasParam(
"--my_void"));
53 Assert::IsTrue(nupp.HasParam(
"--my_float"));
54 Assert::IsTrue(nupp.HasParam(
"--my_int"));
55 Assert::IsTrue(nupp.HasParam(
"--my_num_list"));
56 Assert::IsTrue(nupp.HasParam(
"--my_str_list"));
62 TEST_METHOD(CorrectType)
66 "/my/fake/path/wahoo.out",
89 nupp.RegisterAbbreviation(
"-ms",
"--my_string");
90 nupp.RegisterAbbreviation(
"-mv",
"--my_void");
91 nupp.RegisterAbbreviation(
"-mi",
"--my_int");
92 nupp.RegisterAbbreviation(
"-mf",
"--my_float");
93 nupp.RegisterAbbreviation(
"-mnl",
"--my_num_list");
94 nupp.RegisterAbbreviation(
"-msl",
"--my_str_list");
96 nupp.Parse(
C_Ify(args));
103 Assert::IsTrue(nupp[
"--my_num_list"].GetDataType() ==
DATA_TYPE::LIST);
104 Assert::IsTrue(nupp[
"--my_str_list"].GetDataType() ==
DATA_TYPE::LIST);
110 TEST_METHOD(CorrectValues)
114 "/my/fake/path/wahoo.out",
137 nupp.RegisterAbbreviation(
"-ms",
"--my_string");
138 nupp.RegisterAbbreviation(
"-mv",
"--my_void");
139 nupp.RegisterAbbreviation(
"-mi",
"--my_int");
140 nupp.RegisterAbbreviation(
"-mf",
"--my_float");
141 nupp.RegisterAbbreviation(
"-mnl",
"--my_num_list");
142 nupp.RegisterAbbreviation(
"-msl",
"--my_str_list");
144 nupp.Parse(
C_Ify(args));
147 Assert::AreEqual(nupp[
"--my_string"].GetString(), std::string(
"billybob"));
148 Assert::AreEqual(nupp[
"--my_float"].GetFloat32(), -23.199);
149 Assert::AreEqual(nupp[
"--my_int"].GetInt32(), 199);
150 Assert::AreEqual(nupp[
"--my_num_list"].GetList()[0]->GetInt32(), 1);
151 Assert::AreEqual(nupp[
"--my_num_list"].GetList()[1]->GetInt32(), 2);
152 Assert::AreEqual(nupp[
"--my_num_list"].GetList()[2]->GetInt32(), 3);
153 Assert::AreEqual(nupp[
"--my_num_list"].GetList()[3]->GetInt32(), 4);
154 Assert::AreEqual(nupp[
"--my_str_list"].GetList()[0]->GetString(), std::string(
"apple"));
155 Assert::AreEqual(nupp[
"--my_str_list"].GetList()[1]->GetString(), std::string(
"banana"));
156 Assert::AreEqual(nupp[
"--my_str_list"].GetList()[2]->GetString(), std::string(
"pumpkin"));