9using namespace Microsoft::VisualStudio::CppUnitTestFramework;
16 TEST_CLASS_INITIALIZE (ClassInitialize)
18 Logger::WriteMessage (
"class initialize.\n");
21 TEST_CLASS_CLEANUP (ClassCleanup)
23 Logger::WriteMessage (
"class cleanup.\n");
26 TEST_METHOD_INITIALIZE (MethodInitialize)
28 Logger::WriteMessage (
"method initialize.\n");
31 TEST_METHOD_CLEANUP (MethodCleanup)
33 Logger::WriteMessage (
"method cleanup.\n");
36 void ShowValue (std::string key, std::string value)
38 std::string response = key +
":" + value +
"\n";
39 Logger::WriteMessage (response.c_str ());
42 TEST_METHOD (PicoJsonTest1)
45 ifs.open (
"test.json");
48 std::cerr <<
"fail to read test.json" << std::endl;
49 Assert::Fail (_T (
"test.jsonのオープンに失敗しました。"));
52 const std::string json (
53 (std::istreambuf_iterator<char> (ifs)),
54 std::istreambuf_iterator<char> ());
61 std::cerr << error << std::endl;
62 Assert::Fail (_T (
"picojson::parse()に失敗しました。"));
79 int Numeric = (int)Root[
"Numeric"].get<double> ();
80 ShowValue (
"Numeric", std::to_string (Numeric));
82 auto String = Root[
"String"].get<std::string> ();
83 ShowValue (
"String", String);
85 bool Boolean = Root[
"Boolean"].get<
bool> ();
86 ShowValue (
"Boolean", std::to_string (Boolean));
88 ShowValue (
"Object",
">>");
91 double _Numeric = Object[
"numeric"].get<
double> ();
92 ShowValue (
">numeric", std::to_string (_Numeric));
94 auto _String = Object[
"string"].get<std::string> ();
95 ShowValue (
">string", _String);
97 bool _Boolean = Object[
"boolean"].get<
bool> ();
98 ShowValue (
">boolean", std::to_string (_Boolean));
101 ShowValue (
">Array1",
">>");
102 for (
auto item : _Array1)
104 ShowValue (
">>Array1Value", std::to_string (item.get<
double> ()));
108 ShowValue (
">Array2",
">>");
109 for (
auto item : _Array2)
111 ShowValue (
">>Array2Value", item.get<std::string> ());
115 ShowValue (
"Array1Value",
">>");
116 for (
auto item : Array1)
118 ShowValue (
">Array1Value", std::to_string (item.get<
double> ()));
122 ShowValue (
"Array2",
">>");
123 for (
auto item : Array2)
125 ShowValue (
">Array2Value", item.get<std::string> ());
131 Logger::WriteMessage (
"catched anything.\n");
132 Assert::Fail (_T (
"JSON分析中に例外が発生しました。"));
136 TEST_METHOD (FlowSettingsTest1)
139 ifs.open (
"FlowSettings.json");
142 std::cerr <<
"fail to read FlowSettings.json" << std::endl;
143 Assert::Fail (_T (
"FlowSettings.jsonのオープンに失敗しました。"));
146 const std::string json (
147 (std::istreambuf_iterator<char> (ifs)),
148 std::istreambuf_iterator<char> ());
155 std::cerr << error << std::endl;
156 Assert::Fail (_T (
"picojson::parse()に失敗しました。"));
163 for (
const auto& item : Root)
165 ShowValue (
"Key:", item.first);
168 auto id = Element[
"id"].get<std::string> ();
169 ShowValue (
" id",
id);
170 auto name = Element[
"name"].get<std::string> ();
171 ShowValue (
" name", name);
172 auto object = Element[
"object"].get<std::string> ();
173 ShowValue (
" object",
object);
174 auto product = Element[
"product"].get<std::string> ();
175 ShowValue (
" product", product);
177 if (Element[
"next"].is<picojson::array> ())
180 for (
const auto& next : nextElements)
182 ShowValue (
" >next", next.get<std::string> ());
187 auto next = Element[
"next"].get<std::string> ();
188 ShowValue (
" next", next);
195 std::cout <<
"catched anything." << std::endl;
196 Assert::Fail (_T (
"JSON分析中に例外が発生しました。"));
Open Source Software を集約したプロジェクトファイル
TEST_CLASS(OSSLibraryTest)
std::string parse(value &out, Iter &pos, const Iter &last)