MCPcopy Create free account
hub / github.com/chigraph/chigraph / string_format

Function string_format

test/JSONSerializer.cpp:19–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18template <typename... Args>
19std::string string_format(const std::string& format, Args... args) {
20 size_t size = snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
21 std::unique_ptr<char[]> buf(new char[size]);
22 snprintf(buf.get(), size, format.c_str(), args...);
23 return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
24}
25
26TEST_CASE("JsonSerializer", "[json]") {
27 GIVEN("A default constructed Context with a LangModule and GraphFunction named hello") {

Callers 1

JSONSerializer.cppFile · 0.85

Calls 2

c_strMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected