20#ifndef IPFS_TEST_UTILS_H
21#define IPFS_TEST_UTILS_H
23#include <ipfs/client.h>
37inline void check_if_properties_exist(
39 const std::string& label,
43 const std::vector<const char*>& properties) {
44 for (
const char* property : properties) {
45 if (j.find(property) == j.end()) {
46 throw std::runtime_error(label +
": the property \"" + property +
47 "\" was not found in the response:\n" +
55inline void check_if_string_contains(
57 const std::string& label,
59 const std::string& big,
61 const std::string& needle) {
62 if (big.find(needle) == big.npos) {
63 throw std::runtime_error(label +
": \"" + needle +
64 "\" was not found in the response:\n" + big);
69inline std::string string_to_hex(
71 const std::string& input) {
74 for (
size_t i = 0; i < input.length(); ++i) {
75 ss << std::setw(2) << std::setfill('0') << static_cast<int>(input[i]);
83 const std::string& label,
85 std::function<
void()> f) {
91 }
catch (
const std::exception& e) {
92 std::cout << label +
" failed as expected with error message: " << e.what()
98 throw std::runtime_error(label +
" succeeded but should have failed.");
IPFS namespace.
Definition client.h:33
nlohmann::json Json
Type of the output of some methods, aliased for convenience.
Definition client.h:37