1 #include "CppUnitTest.h"
3 #include "../Hazelnupp/Hazelnupp.h"
4 #include "../Hazelnupp/HazelnuppException.h"
6 using namespace Microsoft::VisualStudio::CppUnitTestFramework;
15 TEST_METHOD(Convert_String)
19 "/my/fake/path/wahoo.out",
26 nupp.SetCrashOnFail(
false);
31 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
34 (*ptnupp)[
"--pud"].GetInt64();
38 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
41 (*ptnupp)[
"--pud"].GetInt32();
45 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
48 (*ptnupp)[
"--pud"].GetFloat64();
52 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
55 (*ptnupp)[
"--pud"].GetFloat32();
59 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
62 (*ptnupp)[
"--pud"].GetList();
71 TEST_METHOD(Convert_Void)
75 "/my/fake/path/wahoo.out",
81 nupp.SetCrashOnFail(
false);
86 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
89 (*ptnupp)[
"--pud"].GetInt64();
93 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
96 (*ptnupp)[
"--pud"].GetInt32();
100 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
103 (*ptnupp)[
"--pud"].GetFloat64();
107 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
110 (*ptnupp)[
"--pud"].GetFloat32();
114 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
117 (*ptnupp)[
"--pud"].GetString();
121 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
124 (*ptnupp)[
"--pud"].GetList();
133 TEST_METHOD(Convert_Int)
137 "/my/fake/path/wahoo.out",
144 nupp.SetCrashOnFail(
false);
149 Assert::AreEqual(39ll, nupp[
"--pud"].GetInt64(), L
"Int64");
150 Assert::AreEqual(39, nupp[
"--pud"].GetInt32(), L
"Int32");
151 Assert::IsTrue(39.0l == nupp[
"--pud"].GetFloat64(), L
"Float64");
152 Assert::AreEqual(39.0, nupp[
"--pud"].GetFloat32(), L
"Float32");
153 Assert::AreEqual(std::string(
"39"), nupp[
"--pud"].GetString(), L
"String");
155 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
158 (*ptnupp)[
"--pud"].GetList();
167 TEST_METHOD(Convert_Float)
171 "/my/fake/path/wahoo.out",
178 nupp.SetCrashOnFail(
false);
183 Assert::AreEqual(39ll, nupp[
"--pud"].GetInt64(), L
"Int64");
184 Assert::AreEqual(39, nupp[
"--pud"].GetInt32(), L
"Int32");
185 Assert::IsTrue(39.5l == nupp[
"--pud"].GetFloat64(), L
"Float64");
186 Assert::AreEqual(39.5, nupp[
"--pud"].GetFloat32(), L
"Float32");
187 Assert::AreEqual(std::string(
"39.5"), nupp[
"--pud"].GetString(), L
"String");
189 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
192 (*ptnupp)[
"--pud"].GetList();
201 TEST_METHOD(Convert_List)
205 "/my/fake/path/wahoo.out",
215 nupp.SetCrashOnFail(
false);
220 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
223 (*ptnupp)[
"--pud"].GetInt64();
227 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
230 (*ptnupp)[
"--pud"].GetInt32();
234 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
237 (*ptnupp)[
"--pud"].GetFloat64();
241 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
244 (*ptnupp)[
"--pud"].GetFloat32();
248 Assert::ExpectException<HazelnuppValueNotConvertibleException>(
251 (*ptnupp)[
"--pud"].GetString();