static void assertConstEmpty(const json_string & s){ assertEquals(s.length(), 0); assertTrue(s.empty()); assertCStringSame(s.c_str(), JSON_TEXT("")); assertEquals(s, s); assertEquals(s, JSON_TEXT("")); }
JsonString::JsonString( json_string& str ) : m_begin((json_char*)str.c_str()) , m_length(str.length()) , m_zeroTerminate(false) , m_rawEnd(J('\0')) { }
static void callback(const json_string & msg){ #ifdef JSON_STRING_HEADER echo("callback triggered, but can't display string"); #else #ifdef JSON_UNICODE const std::string res = std::string(msg.begin(), msg.end()); echo(res); #else echo(msg); #endif #endif }
static void assertSame(json_string & s, json_string & m){ assertEquals(s, m); assertCStringSame(s.c_str(), m.c_str()); assertEquals(s.length(), m.length()); s.swap(m); assertEquals(s, m); assertCStringSame(s.c_str(), m.c_str()); assertEquals(s.length(), m.length()); }
bool metashell::system_test::operator==(const type& type_, const json_string& s_) { rapidjson::Document d; d.Parse(s_.get().c_str()); return members_are({"type", "name"}, d) && matches(type_, d["name"]); }
bool metashell::system_test::operator==(const json_string& a_, const json_string& b_) { // Not testing point_of_event and source_location auto flags = boost::match_default | boost::format_all; boost::regex filter_poi(R"(,"point_of_event":"[^"]*")"); boost::regex filter_sl(R"(,"source_location":"[^"]*")"); auto filtered_a = boost::regex_replace(a_.get(), filter_poi, "", flags); auto filtered_b = boost::regex_replace(b_.get(), filter_poi, "", flags); filtered_a = boost::regex_replace(filtered_a, filter_sl, "", flags); filtered_b = boost::regex_replace(filtered_b, filter_sl, "", flags); return filtered_a == filtered_b; }
bool metashell::system_test::operator==(const frame& frame_, const json_string& s_) { rapidjson::Document d; d.Parse(s_.get().c_str()); return d.IsObject() && d.HasMember("type") && is_string("frame", d["type"]) && matches(frame_, d); }
//Something went wrong or an assert failed void JSONDebug::_JSON_FAIL(const json_string & msg){ #ifdef JSON_STDERROR //no callback, just use stderror #ifndef JSON_UNICODE std::cerr << msg << std::endl; #else std::cerr << std::string(msg.begin(), msg.end()) << std::endl; #endif #else if (ErrorCallback){ //only do anything if the callback is registered #ifdef JSON_LIBRARY ErrorCallback(msg.c_str()); #else ErrorCallback(msg); #endif } #endif }
frame::frame(const json_string& s_) : _name(boost::none), _source_location(boost::none), _point_of_event(boost::none), _kind(boost::none) { rapidjson::Document d; d.Parse(s_.get().c_str()); init(d, true); }
static void convert_string(const json_string& value, const string& path, datum& ret_datum) { ret_datum.string_values_.push_back(make_pair(path, value.get())); }
static void assertDifferent(json_string & s, json_string & m){ assertNotEquals(s, m); assertCStringNotSame(s.c_str(), m.c_str()); }