Classes | Macros | Functions | Variables
glog/src/googletest.h File Reference
#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"
Include dependency graph for glog/src/googletest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  BenchmarkRegisterer
 
class  CapturedStream
 
struct  FlagSaver
 
class  Thread
 

Macros

#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)
 

Functions

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_ voidoperator new (size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC
 
voidoperator 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)
 

Variables

map< string, void(*)(int)> g_benchlist
 
_END_GOOGLE_NAMESPACE_ static _START_GOOGLE_NAMESPACE_ bool g_called_abort
 
static jmp_buf g_jmp_buf
 
_START_GOOGLE_NAMESPACE_ GLOG_EXPORT void(* g_logging_fail_func )()
 
void(* g_new_hook )() = NULL
 
vector< void(*)()> g_testlist
 
static const std::size_t kLoggingPrefixLength = 9
 
static const uint32_t PTR_TEST_VALUE = 0x12345678
 
static CapturedStreams_captured_streams [STDERR_FILENO+1]
 
static const char TEST_SRC_DIR [] = "."
 

Macro Definition Documentation

◆ ASSERT_DEATH

#define ASSERT_DEATH (   fn,
  msg 
)
Value:
do { \
g_called_abort = false; \
/* in logging.cc */ \
void (*original_logging_fail_func)() = g_logging_fail_func; \
g_logging_fail_func = &CalledAbort; \
if (!setjmp(g_jmp_buf)) fn; \
/* set back to their default */ \
g_logging_fail_func = original_logging_fail_func; \
if (!g_called_abort) { \
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)

Definition at line 250 of file glog/src/googletest.h.

◆ BENCHMARK

#define BENCHMARK (   n)    static BenchmarkRegisterer __benchmark_ ## n (#n, &n);

Definition at line 255 of file glog/src/googletest.h.

◆ 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)

Definition at line 155 of file glog/src/googletest.h.

◆ EXPECT_FALSE

#define EXPECT_FALSE (   cond)    EXPECT_TRUE(!(cond))

Definition at line 145 of file glog/src/googletest.h.

◆ EXPECT_GT

#define EXPECT_GT (   val1,
  val2 
)    EXPECT_OP(>, val1, val2)

Definition at line 157 of file glog/src/googletest.h.

◆ EXPECT_INF

#define EXPECT_INF (   arg)
Value:
do { \
if (!isinf(arg)) { \
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)

Definition at line 158 of file glog/src/googletest.h.

◆ EXPECT_NAN

#define EXPECT_NAN (   arg)
Value:
do { \
if (!isnan(arg)) { \
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)

Definition at line 156 of file glog/src/googletest.h.

◆ 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

#define GLOG_EXPORT

Definition at line 76 of file glog/src/googletest.h.

◆ GOOGLE_GLOG_THROW_BAD_ALLOC

#define GOOGLE_GLOG_THROW_BAD_ALLOC   throw (std::bad_alloc)

Definition at line 60 of file glog/src/googletest.h.

◆ GOOGLETEST_H__

#define GOOGLETEST_H__

Definition at line 36 of file glog/src/googletest.h.

◆ TEST

#define TEST (   a,
  b 
)
Value:
struct Test_##a##_##b { \
Test_##a##_##b() { g_testlist.push_back(&Run); } \
static void Run() { FlagSaver fs; RunTest(); } \
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.

Function Documentation

◆ CalledAbort()

static void CalledAbort ( )
inlinestatic

Definition at line 222 of file glog/src/googletest.h.

◆ CaptureTestOutput()

static void CaptureTestOutput ( int  fd,
const string filename 
)
inlinestatic

Definition at line 351 of file glog/src/googletest.h.

◆ CaptureTestStderr()

static void CaptureTestStderr ( )
inlinestatic

Definition at line 359 of file glog/src/googletest.h.

◆ CaptureTestStdout()

static void CaptureTestStdout ( )
inlinestatic

Definition at line 356 of file glog/src/googletest.h.

◆ 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

Definition at line 391 of file glog/src/googletest.h.

◆ GetCapturedTestStderr()

static string GetCapturedTestStderr ( )
inlinestatic

Definition at line 411 of file glog/src/googletest.h.

◆ GetFileSize()

static size_t GetFileSize ( FILE *  file)
inlinestatic

Definition at line 363 of file glog/src/googletest.h.

◆ GetTempDir()

static string GetTempDir ( )
inlinestatic

Definition at line 78 of file glog/src/googletest.h.

◆ InitGoogleTest()

void InitGoogleTest ( int *  ,
char **   
)

Definition at line 124 of file glog/src/googletest.h.

◆ IsLoggingPrefix()

static bool IsLoggingPrefix ( const string s)
inlinestatic

Definition at line 418 of file glog/src/googletest.h.

◆ Munge()

static string Munge ( const string filename)
inlinestatic

Definition at line 480 of file glog/src/googletest.h.

◆ MungeAndDiffTest()

static bool MungeAndDiffTest ( const string golden_filename,
CapturedStream cap 
)
inlinestatic

Definition at line 513 of file glog/src/googletest.h.

◆ MungeAndDiffTestStderr()

static bool MungeAndDiffTestStderr ( const string golden_filename)
inlinestatic

Definition at line 549 of file glog/src/googletest.h.

◆ MungeAndDiffTestStdout()

static bool MungeAndDiffTestStdout ( const string golden_filename)
inlinestatic

Definition at line 553 of file glog/src/googletest.h.

◆ MungeLine()

static string MungeLine ( const string line)
inlinestatic

Definition at line 434 of file glog/src/googletest.h.

◆ operator delete() [1/2]

void operator delete ( void p)
throw (
)

Definition at line 658 of file glog/src/googletest.h.

◆ operator delete() [2/2]

void operator delete ( void p,
size_t   
)
throw (
)

Definition at line 662 of file glog/src/googletest.h.

◆ operator delete[]() [1/2]

void operator delete[] ( void p)
throw (
)

Definition at line 666 of file glog/src/googletest.h.

◆ operator delete[]() [2/2]

void operator delete[] ( void p,
size_t   
)
throw (
)

Definition at line 670 of file glog/src/googletest.h.

◆ operator new()

_END_GOOGLE_NAMESPACE_ void* operator new ( size_t  size)

Definition at line 647 of file glog/src/googletest.h.

◆ operator new[]()

void* operator new[] ( size_t  size)

Definition at line 654 of file glog/src/googletest.h.

◆ ReadEntireFile()

static string ReadEntireFile ( FILE *  file)
inlinestatic

Definition at line 368 of file glog/src/googletest.h.

◆ RUN_ALL_TESTS()

static int RUN_ALL_TESTS ( )
inlinestatic

Definition at line 204 of file glog/src/googletest.h.

◆ RunSpecifiedBenchmarks()

static void RunSpecifiedBenchmarks ( )
inlinestatic

Definition at line 266 of file glog/src/googletest.h.

◆ SleepForMilliseconds()

static void SleepForMilliseconds ( unsigned  t)
inlinestatic

Definition at line 628 of file glog/src/googletest.h.

◆ StringReplace()

static void StringReplace ( string str,
const string oldsub,
const string newsub 
)
inlinestatic

Definition at line 471 of file glog/src/googletest.h.

◆ WriteToFile()

static void WriteToFile ( const string body,
const string file 
)
inlinestatic

Definition at line 507 of file glog/src/googletest.h.

Variable Documentation

◆ g_benchlist

map<string, void (*)(int)> g_benchlist

Definition at line 257 of file glog/src/googletest.h.

◆ g_called_abort

_END_GOOGLE_NAMESPACE_ static _START_GOOGLE_NAMESPACE_ bool g_called_abort
static

Definition at line 220 of file glog/src/googletest.h.

◆ g_jmp_buf

jmp_buf g_jmp_buf
static

Definition at line 221 of file glog/src/googletest.h.

◆ g_logging_fail_func

_START_GOOGLE_NAMESPACE_ GLOG_EXPORT void(* g_logging_fail_func) ()

Definition at line 1938 of file logging.cc.

◆ g_new_hook

void(* g_new_hook) () = NULL

Definition at line 643 of file glog/src/googletest.h.

◆ g_testlist

vector<void (*)()> g_testlist

Definition at line 192 of file glog/src/googletest.h.

◆ kLoggingPrefixLength

const std::size_t kLoggingPrefixLength = 9
static

Definition at line 415 of file glog/src/googletest.h.

◆ PTR_TEST_VALUE

const uint32_t PTR_TEST_VALUE = 0x12345678
static

Definition at line 100 of file glog/src/googletest.h.

◆ s_captured_streams

CapturedStream* s_captured_streams[STDERR_FILENO+1]
static

Definition at line 347 of file glog/src/googletest.h.

◆ TEST_SRC_DIR

const char TEST_SRC_DIR[] = "."
static

Definition at line 97 of file glog/src/googletest.h.

g_called_abort
_END_GOOGLE_NAMESPACE_ static _START_GOOGLE_NAMESPACE_ bool g_called_abort
Definition: glog/src/googletest.h:220
isinf
#define isinf(d)
Definition: cJSON.c:74
b
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:3228
g_jmp_buf
static jmp_buf g_jmp_buf
Definition: glog/src/googletest.h:221
CalledAbort
static void CalledAbort()
Definition: glog/src/googletest.h:222
gmock_output_test._
_
Definition: gmock_output_test.py:173
googletest-break-on-failure-unittest.Run
def Run(command)
Definition: googletest-break-on-failure-unittest.py:76
g_logging_fail_func
_START_GOOGLE_NAMESPACE_ GLOG_EXPORT void(* g_logging_fail_func)()
Definition: logging.cc:1938
g_testlist
vector< void(*)()> g_testlist
Definition: glog/src/googletest.h:192
FlagSaver
Definition: glog/src/googletest.h:559
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:3228
isnan
#define isnan(d)
Definition: cJSON.c:77


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:03