File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -201,4 +201,15 @@ namespace sjv
201201 return true ;
202202 };
203203
204+ std::string sjv::log2str ()
205+ {
206+ std::stringstream s;
207+
208+ for (log_item i: log)
209+ {
210+ s << i.first << " : " << i.second << std::endl;
211+ s << std::endl;
212+ }
213+ return s.str ();
214+ }
204215} // namespace sjv
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ namespace sjv
3636 // message list
3737 typedef std::pair<std::string,std::string> log_item;
3838 std::vector<log_item> log;
39+
40+ // log to string
41+ std::string log2str ();
3942 };
4043
4144} // namespace sjv
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ TEST_CASE("single_rule", "[validator]")
2929 sjv::sjv sjv;
3030
3131 REQUIRE (sjv.verify_json (input,rules));
32+
3233}
3334
3435TEST_CASE (" only_one_rule_can_be_valid" , " [validator]" )
@@ -189,3 +190,31 @@ TEST_CASE("type_object", "[validator]")
189190 REQUIRE (!sjv.verify_json (input,rules));
190191
191192}
193+
194+ TEST_CASE (" file1" , " [validator]" )
195+ {
196+ json input = R"(
197+ {
198+ "string1": "teststring"
199+ }
200+ )" _json;
201+
202+ json rules = R"(
203+ [
204+ {
205+ "pointer": "/",
206+ "type": "object",
207+ "required": ["string1"]
208+ }
209+ ]
210+ )" _json;
211+
212+ sjv::sjv sjv;
213+
214+ sjv.strict = true ;
215+
216+ bool r = sjv.verify_json (input,rules);
217+ std:: string s = sjv.log2str ();
218+ INFO (s);
219+ REQUIRE (r);
220+ }
You can’t perform that action at this time.
0 commit comments