char* subst_env_in_string(const char* str, char** errmsg);
void set_cloexec_flag(int fd);
double time_seconds();
-
-// Convert a char* string `str` to an std::string, if `str` is NULL return "".
-std::string from_cstr(const char* str);
CHECK_STR_EQ("00010203", result);
}
-TEST(from_cstr)
-{
- char* cstr1 = x_strdup("foo");
- const char* cstr2 = "bar";
- const char* cstr3 = nullptr;
- const char* cstr4 = "";
-
- std::string str1 = from_cstr(cstr1);
- std::string str2 = from_cstr(cstr2);
- std::string str3 = from_cstr(cstr3);
- std::string str4 = from_cstr(cstr4);
-
- CHECK(str1 == "foo");
- CHECK(str2 == "bar");
- CHECK(str3 == "");
- CHECK(str4 == "");
-
- free(cstr1);
-}
-
TEST_SUITE_END