#include "utilities.h"
#include <cctype>
#include <csetjmp>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "base/commandlineflags.h"
Go to the source code of this file.
|
#define | ASSERT_DEATH(fn, msg) |
|
#define | ASSERT_DEBUG_DEATH(fn, msg) ASSERT_DEATH(fn, msg) |
|
#define | BENCHMARK(n) static BenchmarkRegisterer __benchmark_ ## n (#n, &n); |
|
#define | EXPECT_DOUBLE_EQ(val1, val2) |
|
#define | EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2) |
|
#define | EXPECT_FALSE(cond) EXPECT_TRUE(!(cond)) |
|
#define | EXPECT_GT(val1, val2) EXPECT_OP(>, val1, val2) |
|
#define | EXPECT_INF(arg) |
|
#define | EXPECT_LT(val1, val2) EXPECT_OP(<, val1, val2) |
|
#define | EXPECT_NAN(arg) |
|
#define | EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2) |
|
#define | EXPECT_NEAR(val1, val2, abs_error) |
|
#define | EXPECT_OP(op, val1, val2) |
|
#define | EXPECT_STREQ(val1, val2) |
|
#define | EXPECT_TRUE(cond) |
|
#define | GLOG_EXPORT |
|
#define | GOOGLE_GLOG_THROW_BAD_ALLOC throw (std::bad_alloc) |
|
#define | GOOGLETEST_H__ |
|
#define | TEST(a, b) |
|
|
static void | CalledAbort () |
|
static void | CaptureTestOutput (int fd, const string &filename) |
|
static void | CaptureTestStderr () |
|
static void | CaptureTestStdout () |
|
| DEFINE_bool (run_benchmark, false, "If true, run benchmarks") |
|
| DEFINE_int32 (benchmark_iters, 100000, "Number of iterations per benchmark") |
|
| DEFINE_string (test_srcdir, TEST_SRC_DIR, "Source-dir root, needed to find glog_unittest_flagfile") |
|
| DEFINE_string (test_tmpdir, GetTempDir(), "Dir we use for temp files") |
|
static string | GetCapturedTestOutput (int fd) |
|
static string | GetCapturedTestStderr () |
|
static size_t | GetFileSize (FILE *file) |
|
static string | GetTempDir () |
|
_START_GOOGLE_NAMESPACE_ void | InitGoogleTest (int *, char **) |
|
static bool | IsLoggingPrefix (const string &s) |
|
static string | Munge (const string &filename) |
|
static bool | MungeAndDiffTest (const string &golden_filename, CapturedStream *cap) |
|
static bool | MungeAndDiffTestStderr (const string &golden_filename) |
|
static bool | MungeAndDiffTestStdout (const string &golden_filename) |
|
static string | MungeLine (const string &line) |
|
void | operator delete (void *p) throw () |
|
void | operator delete (void *p, size_t) throw () |
|
void | operator delete[] (void *p) throw () |
|
void | operator delete[] (void *p, size_t) throw () |
|
_END_GOOGLE_NAMESPACE_ void * | operator new (size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC |
|
void * | operator new[] (size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC |
|
static string | ReadEntireFile (FILE *file) |
|
static int | RUN_ALL_TESTS () |
|
static void | RunSpecifiedBenchmarks () |
|
static void | SleepForMilliseconds (unsigned t) |
|
static void | StringReplace (string *str, const string &oldsub, const string &newsub) |
|
static void | WriteToFile (const string &body, const string &file) |
|
◆ ASSERT_DEATH
#define ASSERT_DEATH |
( |
|
fn, |
|
|
|
msg |
|
) |
| |
Value: do { \
g_called_abort = false; \
\
\
g_logging_fail_func = original_logging_fail_func; \
fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 231 of file glog/src/googletest.h.
◆ ASSERT_DEBUG_DEATH
#define ASSERT_DEBUG_DEATH |
( |
|
fn, |
|
|
|
msg |
|
) |
| ASSERT_DEATH(fn, msg) |
◆ BENCHMARK
◆ EXPECT_DOUBLE_EQ
#define EXPECT_DOUBLE_EQ |
( |
|
val1, |
|
|
|
val2 |
|
) |
| |
Value: do { \
if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \
fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 176 of file glog/src/googletest.h.
◆ EXPECT_EQ
#define EXPECT_EQ |
( |
|
val1, |
|
|
|
val2 |
|
) |
| EXPECT_OP(==, val1, val2) |
◆ EXPECT_FALSE
◆ EXPECT_GT
#define EXPECT_GT |
( |
|
val1, |
|
|
|
val2 |
|
) |
| EXPECT_OP(>, val1, val2) |
◆ EXPECT_INF
#define EXPECT_INF |
( |
|
arg | ) |
|
Value: do { \
fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 168 of file glog/src/googletest.h.
◆ EXPECT_LT
#define EXPECT_LT |
( |
|
val1, |
|
|
|
val2 |
|
) |
| EXPECT_OP(<, val1, val2) |
◆ EXPECT_NAN
#define EXPECT_NAN |
( |
|
arg | ) |
|
Value: do { \
fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 160 of file glog/src/googletest.h.
◆ EXPECT_NE
#define EXPECT_NE |
( |
|
val1, |
|
|
|
val2 |
|
) |
| EXPECT_OP(!=, val1, val2) |
◆ EXPECT_NEAR
#define EXPECT_NEAR |
( |
|
val1, |
|
|
|
val2, |
|
|
|
abs_error |
|
) |
| |
Value: do { \
if (abs(val1 - val2) > abs_error) { \
fprintf(stderr, "Check failed: %s within %s of %s\n", #val1, #abs_error, \
#val2); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 128 of file glog/src/googletest.h.
◆ EXPECT_OP
#define EXPECT_OP |
( |
|
op, |
|
|
|
val1, |
|
|
|
val2 |
|
) |
| |
Value: do { \
if (!((val1) op (val2))) { \
fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 147 of file glog/src/googletest.h.
◆ EXPECT_STREQ
#define EXPECT_STREQ |
( |
|
val1, |
|
|
|
val2 |
|
) |
| |
Value: do { \
if (strcmp((val1), (val2)) != 0) { \
fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 184 of file glog/src/googletest.h.
◆ EXPECT_TRUE
#define EXPECT_TRUE |
( |
|
cond | ) |
|
Value: do { \
if (!(cond)) { \
fprintf(stderr, "Check failed: %s\n", #cond); \
exit(EXIT_FAILURE); \
} \
} while (0)
Definition at line 137 of file glog/src/googletest.h.
◆ GLOG_EXPORT
◆ GOOGLE_GLOG_THROW_BAD_ALLOC
#define GOOGLE_GLOG_THROW_BAD_ALLOC throw (std::bad_alloc) |
◆ GOOGLETEST_H__
◆ TEST
Value: struct Test_##
a##
_##
b { \
static void RunTest(); \
}; \
static Test_##
a##
_##
b g_test_##
a##
_##
b; \
void Test_##
a##
_##b::RunTest()
Definition at line 194 of file glog/src/googletest.h.
◆ CalledAbort()
static void CalledAbort |
( |
| ) |
|
|
inlinestatic |
◆ CaptureTestOutput()
static void CaptureTestOutput |
( |
int |
fd, |
|
|
const string & |
filename |
|
) |
| |
|
inlinestatic |
◆ CaptureTestStderr()
static void CaptureTestStderr |
( |
| ) |
|
|
inlinestatic |
◆ CaptureTestStdout()
static void CaptureTestStdout |
( |
| ) |
|
|
inlinestatic |
◆ DEFINE_bool()
DEFINE_bool |
( |
run_benchmark |
, |
|
|
false |
, |
|
|
"If |
true, |
|
|
run benchmarks" |
|
|
) |
| |
◆ DEFINE_int32()
DEFINE_int32 |
( |
benchmark_iters |
, |
|
|
100000 |
, |
|
|
"Number of iterations per benchmark" |
|
|
) |
| |
◆ DEFINE_string() [1/2]
DEFINE_string |
( |
test_srcdir |
, |
|
|
TEST_SRC_DIR |
, |
|
|
"Source-dir |
root, |
|
|
needed to find glog_unittest_flagfile" |
|
|
) |
| |
◆ DEFINE_string() [2/2]
DEFINE_string |
( |
test_tmpdir |
, |
|
|
GetTempDir() |
, |
|
|
"Dir we use for temp files" |
|
|
) |
| |
◆ GetCapturedTestOutput()
static string GetCapturedTestOutput |
( |
int |
fd | ) |
|
|
inlinestatic |
◆ GetCapturedTestStderr()
static string GetCapturedTestStderr |
( |
| ) |
|
|
inlinestatic |
◆ GetFileSize()
static size_t GetFileSize |
( |
FILE * |
file | ) |
|
|
inlinestatic |
◆ GetTempDir()
◆ InitGoogleTest()
void InitGoogleTest |
( |
int * |
, |
|
|
char ** |
|
|
) |
| |
◆ IsLoggingPrefix()
static bool IsLoggingPrefix |
( |
const string & |
s | ) |
|
|
inlinestatic |
◆ Munge()
◆ MungeAndDiffTest()
◆ MungeAndDiffTestStderr()
static bool MungeAndDiffTestStderr |
( |
const string & |
golden_filename | ) |
|
|
inlinestatic |
◆ MungeAndDiffTestStdout()
static bool MungeAndDiffTestStdout |
( |
const string & |
golden_filename | ) |
|
|
inlinestatic |
◆ MungeLine()
◆ operator delete() [1/2]
void operator delete |
( |
void * |
p | ) |
|
throw | ( | |
| ) | | |
◆ operator delete() [2/2]
void operator delete |
( |
void * |
p, |
|
|
size_t |
|
|
) |
| |
throw | ( | |
| ) | | |
◆ operator delete[]() [1/2]
void operator delete[] |
( |
void * |
p | ) |
|
throw | ( | |
| ) | | |
◆ operator delete[]() [2/2]
void operator delete[] |
( |
void * |
p, |
|
|
size_t |
|
|
) |
| |
throw | ( | |
| ) | | |
◆ operator new()
_END_GOOGLE_NAMESPACE_ void* operator new |
( |
size_t |
size | ) |
|
◆ operator new[]()
void* operator new[] |
( |
size_t |
size | ) |
|
◆ ReadEntireFile()
static string ReadEntireFile |
( |
FILE * |
file | ) |
|
|
inlinestatic |
◆ RUN_ALL_TESTS()
static int RUN_ALL_TESTS |
( |
| ) |
|
|
inlinestatic |
◆ RunSpecifiedBenchmarks()
static void RunSpecifiedBenchmarks |
( |
| ) |
|
|
inlinestatic |
◆ SleepForMilliseconds()
static void SleepForMilliseconds |
( |
unsigned |
t | ) |
|
|
inlinestatic |
◆ StringReplace()
◆ WriteToFile()
◆ g_benchlist
◆ g_called_abort
_END_GOOGLE_NAMESPACE_ static _START_GOOGLE_NAMESPACE_ bool g_called_abort |
|
static |
◆ g_jmp_buf
◆ g_logging_fail_func
◆ g_new_hook
◆ g_testlist
vector<void (*)()> g_testlist |
◆ kLoggingPrefixLength
const std::size_t kLoggingPrefixLength = 9 |
|
static |
◆ PTR_TEST_VALUE
const uint32_t PTR_TEST_VALUE = 0x12345678 |
|
static |
◆ s_captured_streams
◆ TEST_SRC_DIR
const char TEST_SRC_DIR[] = "." |
|
static |