@@ -68,16 +68,6 @@ do { \
68
68
} \
69
69
} while (false )
70
70
71
-
72
- #define JSON_TEST_HELPER (jsonData ) \
73
- { \
74
- std::error_code err; \
75
- auto parsedObject = web::json::value::parse (jsonData, err); \
76
- \
77
- VERIFY_IS_TRUE (err.value () == 0 ); \
78
- VERIFY_IS_TRUE (!parsedObject.is_null ()); \
79
- }
80
-
81
71
SUITE (parsing_tests)
82
72
{
83
73
@@ -623,16 +613,25 @@ TEST(non_default_locale)
623
613
}
624
614
}
625
615
616
+ template <typename T>
617
+ void error_code_helper (T &jsonData)
618
+ {
619
+ std::error_code err;
620
+ auto parsedObject = web::json::value::parse (jsonData, err);
621
+ VERIFY_IS_TRUE (err.value () == 0 );
622
+ VERIFY_IS_TRUE (!parsedObject.is_null ());
623
+ }
624
+
626
625
TEST (parse_overload_success)
627
626
{
628
627
std::error_code err;
629
628
utility::string_t valueStr (U (" \" JSONString\" " ));
630
629
utility::string_t arrStr (U (" [true,false,-1.55,5,null,{\" abc\" :5555}]" ));
631
630
utility::string_t objStr (U (" {\" k\" :3, \" j\" :2, \" i\" :1}" ));
632
631
633
- JSON_TEST_HELPER (valueStr);
634
- JSON_TEST_HELPER (arrStr);
635
- JSON_TEST_HELPER (objStr);
632
+ error_code_helper (valueStr);
633
+ error_code_helper (arrStr);
634
+ error_code_helper (objStr);
636
635
637
636
utility::stringstream_t valueStringStream;
638
637
utility::stringstream_t arrayStringStream;
@@ -642,24 +641,24 @@ TEST(parse_overload_success)
642
641
arrayStringStream << arrStr;
643
642
objStringStream << objStr;
644
643
645
- JSON_TEST_HELPER (valueStringStream. str () );
646
- JSON_TEST_HELPER (arrayStringStream. str () );
647
- JSON_TEST_HELPER (objStringStream. str () );
644
+ error_code_helper (valueStringStream);
645
+ error_code_helper (arrayStringStream);
646
+ error_code_helper (objStringStream);
648
647
649
648
#ifdef _MS_WINDOWS
650
649
std::wstringbuf buf;
651
650
652
651
buf.sputn (valueStr.c_str (), valueStr.size ());
653
652
std::wistream valStream (&buf);
654
- JSON_TEST_HELPER (valStream);
653
+ error_code_helper (valStream);
655
654
656
655
buf.sputn (arrStr.c_str (), arrStr.size ());
657
656
std::wistream arrStream (&buf);
658
- JSON_TEST_HELPER (arrStream);
657
+ error_code_helper (arrStream);
659
658
660
659
buf.sputn (objStr.c_str (), objStr.size ());
661
660
std::wistream objStream (&buf);
662
- JSON_TEST_HELPER (objStream);
661
+ error_code_helper (objStream);
663
662
#endif
664
663
}
665
664
0 commit comments