Ninja
Classes | Namespaces | Macros | Functions | Variables
test.h File Reference
#include "disk_interface.h"
#include "state.h"
#include "util.h"
Include dependency graph for test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  VirtualFileSystem::Entry
 An entry for a single in-memory file. More...
 
struct  ScopedTempDir
 
struct  StateTestWithBuiltinRules
 A base test fixture that includes a State object with a builtin "cat" rule. More...
 
class  testing::Test
 
struct  VirtualFileSystem
 An implementation of DiskInterface that uses an in-memory representation of disk state. More...
 

Namespaces

 testing
 

Macros

#define ASSERT_EQ(a, b)   if (!EXPECT_EQ(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_FALSE(a)   if (!EXPECT_FALSE(a)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_GE(a, b)   if (!EXPECT_GE(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_GT(a, b)   if (!EXPECT_GT(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_LE(a, b)   if (!EXPECT_LE(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_LT(a, b)   if (!EXPECT_LT(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_NE(a, b)   if (!EXPECT_NE(a, b)) { g_current_test->AddAssertionFailure(); return; }
 
#define ASSERT_NO_FATAL_FAILURE(a)
 
#define ASSERT_TRUE(a)   if (!EXPECT_TRUE(a)) { g_current_test->AddAssertionFailure(); return; }
 
#define EXPECT_EQ(a, b)   g_current_test->Check(a == b, __FILE__, __LINE__, #a " == " #b)
 
#define EXPECT_FALSE(a)   g_current_test->Check(!static_cast<bool>(a), __FILE__, __LINE__, #a)
 
#define EXPECT_GE(a, b)   g_current_test->Check(a >= b, __FILE__, __LINE__, #a " >= " #b)
 
#define EXPECT_GT(a, b)   g_current_test->Check(a > b, __FILE__, __LINE__, #a " > " #b)
 
#define EXPECT_LE(a, b)   g_current_test->Check(a <= b, __FILE__, __LINE__, #a " <= " #b)
 
#define EXPECT_LT(a, b)   g_current_test->Check(a < b, __FILE__, __LINE__, #a " < " #b)
 
#define EXPECT_NE(a, b)   g_current_test->Check(a != b, __FILE__, __LINE__, #a " != " #b)
 
#define EXPECT_TRUE(a)   g_current_test->Check(static_cast<bool>(a), __FILE__, __LINE__, #a)
 
#define TEST(x, y)   TEST_F_(testing::Test, x##y, #x "." #y)
 
#define TEST_F(x, y)   TEST_F_(x, x##y, #x "." #y)
 
#define TEST_F_(x, y, name)
 

Functions

void AssertHash (const char *expected, uint64_t actual)
 
void AssertParse (State *state, const char *input)
 
void RegisterTest (testing::Test *(*)(), const char *)
 

Variables

testing::Testg_current_test
 

Macro Definition Documentation

#define ASSERT_EQ (   a,
 
)    if (!EXPECT_EQ(a, b)) { g_current_test->AddAssertionFailure(); return; }
#define ASSERT_FALSE (   a)    if (!EXPECT_FALSE(a)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 94 of file test.h.

Referenced by PlanTest::FindWorkSorted(), TEST(), TEST_F(), and PlanTest::TestPoolWithDepthOne().

#define ASSERT_GE (   a,
 
)    if (!EXPECT_GE(a, b)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 88 of file test.h.

#define ASSERT_GT (   a,
 
)    if (!EXPECT_GT(a, b)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 84 of file test.h.

Referenced by TEST_F().

#define ASSERT_LE (   a,
 
)    if (!EXPECT_LE(a, b)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 90 of file test.h.

#define ASSERT_LT (   a,
 
)    if (!EXPECT_LT(a, b)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 86 of file test.h.

#define ASSERT_NE (   a,
 
)    if (!EXPECT_NE(a, b)) { g_current_test->AddAssertionFailure(); return; }

Definition at line 82 of file test.h.

Referenced by TEST_F().

#define ASSERT_NO_FATAL_FAILURE (   a)
Value:
{ \
a; \
return; \
} \
}
testing::Test * g_current_test
Definition: ninja_test.cc:37
void AddAssertionFailure()
Definition: test.h:41
int AssertionFailures() const
Definition: test.h:40

Definition at line 96 of file test.h.

Referenced by BuildTest::RebuildTarget(), TEST_F(), and PlanTest::TestPoolWithDepthOne().

#define ASSERT_TRUE (   a)    if (!EXPECT_TRUE(a)) { g_current_test->AddAssertionFailure(); return; }
#define EXPECT_EQ (   a,
 
)    g_current_test->Check(a == b, __FILE__, __LINE__, #a " == " #b)

Definition at line 63 of file test.h.

Referenced by TEST(), and TEST_F().

#define EXPECT_FALSE (   a)    g_current_test->Check(!static_cast<bool>(a), __FILE__, __LINE__, #a)

Definition at line 77 of file test.h.

Referenced by StateTestWithBuiltinRules::GetNode(), TEST(), and TEST_F().

#define EXPECT_GE (   a,
 
)    g_current_test->Check(a >= b, __FILE__, __LINE__, #a " >= " #b)

Definition at line 71 of file test.h.

#define EXPECT_GT (   a,
 
)    g_current_test->Check(a > b, __FILE__, __LINE__, #a " > " #b)

Definition at line 67 of file test.h.

Referenced by TEST_F().

#define EXPECT_LE (   a,
 
)    g_current_test->Check(a <= b, __FILE__, __LINE__, #a " <= " #b)

Definition at line 73 of file test.h.

#define EXPECT_LT (   a,
 
)    g_current_test->Check(a < b, __FILE__, __LINE__, #a " < " #b)

Definition at line 69 of file test.h.

#define EXPECT_NE (   a,
 
)    g_current_test->Check(a != b, __FILE__, __LINE__, #a " != " #b)

Definition at line 65 of file test.h.

Referenced by TEST_F().

#define EXPECT_TRUE (   a)    g_current_test->Check(static_cast<bool>(a), __FILE__, __LINE__, #a)
#define TEST (   x,
 
)    TEST_F_(testing::Test, x##y, #x "." #y)

Definition at line 61 of file test.h.

#define TEST_F (   x,
 
)    TEST_F_(x, x##y, #x "." #y)

Definition at line 60 of file test.h.

#define TEST_F_ (   x,
  y,
  name 
)
Value:
struct y : public x { \
static testing::Test* Create() { return g_current_test = new y; } \
virtual void Run(); \
}; \
struct Register##y { \
Register##y() { RegisterTest(y::Create, name); } \
}; \
Register##y g_register_##y; \
void y::Run()
testing::Test * g_current_test
Definition: ninja_test.cc:37
void RegisterTest(testing::Test *(*)(), const char *)

Definition at line 49 of file test.h.

Function Documentation

void AssertHash ( const char *  expected,
uint64_t  actual 
)

Definition at line 103 of file test.cc.

References ASSERT_EQ, and BuildLog::LogEntry::HashCommand().

Referenced by TEST_F().

void AssertParse ( State state,
const char *  input 
)
void RegisterTest ( testing::Test *)(,
const char *   
)

Variable Documentation

testing::Test* g_current_test

Definition at line 37 of file ninja_test.cc.