bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, const pugi::char_t* expected) { pugi::xpath_query q(query, variables); if(!q) return false; const size_t capacity = 64; pugi::char_t result[capacity]; size_t size = q.evaluate_string(result, capacity, node); if(size <= capacity) return test_string_equal(result, expected); std::basic_string<pugi::char_t> buffer(size, ' '); return q.evaluate_string(&buffer[0], size, node) == size && test_string_equal(buffer.c_str(), expected); }
void test_path(int nr , const char * root , const char * path , const char * true_path) { char * rel_path = util_alloc_rel_path( root , path); if (!test_string_equal( rel_path , true_path)) test_error_exit("Case:%d rel_path(%s,%s) -> %s failed - expected: %s\n" , nr , root , path , rel_path , true_path); else printf("Case:%d OK \n",nr); util_safe_free( rel_path ); }
template <typename Node> inline bool test_node_name_value(const Node& node, const pugi::char_t* name, const pugi::char_t* value) { return test_string_equal(node.name(), name) && test_string_equal(node.value(), value); }