13#ifndef TESSERACT_UNITTEST_INCLUDE_GUNIT_H_
14#define TESSERACT_UNITTEST_INCLUDE_GUNIT_H_
21static const char *FLAGS_test_tmpdir =
"./tmp";
25static inline void trim(std::string &s) {
26 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
unsigned char ch) {
27 return !std::isspace(ch);
29 s.erase(std::find_if(s.rbegin(), s.rend(), [](
unsigned char ch) {
30 return !std::isspace(ch);
40 _mkdir(FLAGS_test_tmpdir);
42 mkdir(FLAGS_test_tmpdir, S_IRWXU | S_IRWXG);
48 File::WriteStringToFileOrDie(contents, filename);
52 static bool GetContents(
const std::string &filename, std::string *out,
int) {
53 return File::ReadFileToString(filename, out);
56 static bool SetContents(
const std::string &name,
const std::string &contents,
65 static std::string
JoinPath(
const std::string &s1,
const std::string &s2) {
69 static std::string
JoinPath(
const std::string &s1,
const std::string &s2,
const std::string &s3) {
76# define CHECK(condition) \
78 LOG(FATAL) << "Check failed: " #condition " "
79# define CHECK_EQ(test, value) CHECK((test) == (value))
80# define CHECK_GE(test, value) CHECK((test) >= (value))
81# define CHECK_GT(test, value) CHECK((test) > (value))
82# define CHECK_LT(test, value) CHECK((test) < (value))
83# define CHECK_LE(test, value) CHECK((test) <= (value))
84# define CHECK_OK(test) CHECK(test)
static std::string JoinPath(const std::string &prefix, const std::string &suffix)
static std::string JoinPath(const std::string &s1, const std::string &s2, const std::string &s3)
static std::string JoinPath(const std::string &s1, const std::string &s2)
static bool SetContents(const std::string &name, const std::string &contents, bool)
static bool GetContents(const std::string &filename, std::string *out, int)
static bool WriteStringToFile(const std::string &contents, const std::string &filename)