Ninja
Classes | Namespaces | Macros | Functions | Variables
test.h File Reference
#include "disk_interface.h"
#include "manifest_parser.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, ManifestParserOptions=ManifestParserOptions())
 
void RegisterTest (testing::Test *(*)(), const char *)
 
void VerifyGraph (const State &state)
 

Variables

testing::Testg_current_test
 

Macro Definition Documentation

◆ ASSERT_EQ

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

◆ ASSERT_FALSE

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

Definition at line 95 of file test.h.

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

◆ ASSERT_GE

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

Definition at line 89 of file test.h.

◆ ASSERT_GT

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

Definition at line 85 of file test.h.

Referenced by TEST_F().

◆ ASSERT_LE

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

Definition at line 91 of file test.h.

Referenced by TEST().

◆ ASSERT_LT

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

Definition at line 87 of file test.h.

◆ ASSERT_NE

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

Definition at line 83 of file test.h.

Referenced by TEST(), and TEST_F().

◆ ASSERT_NO_FATAL_FAILURE

#define ASSERT_NO_FATAL_FAILURE (   a)
Value:
{ \
int fail_count = g_current_test->AssertionFailures(); \
a; \
if (fail_count != g_current_test->AssertionFailures()) { \
g_current_test->AddAssertionFailure(); \
return; \
} \
}
testing::Test * g_current_test
Definition: ninja_test.cc:43
int AssertionFailures() const
Definition: test.h:41

Definition at line 97 of file test.h.

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

◆ ASSERT_TRUE

#define ASSERT_TRUE (   a)    if (!EXPECT_TRUE(a)) { g_current_test->AddAssertionFailure(); return; }

◆ EXPECT_EQ

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

Definition at line 64 of file test.h.

Referenced by TEST(), TEST_F(), and VerifyGraph().

◆ EXPECT_FALSE

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

Definition at line 78 of file test.h.

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

◆ EXPECT_GE

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

Definition at line 72 of file test.h.

Referenced by TEST_F().

◆ EXPECT_GT

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

Definition at line 68 of file test.h.

Referenced by TEST_F().

◆ EXPECT_LE

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

Definition at line 74 of file test.h.

◆ EXPECT_LT

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

Definition at line 70 of file test.h.

◆ EXPECT_NE

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

Definition at line 66 of file test.h.

Referenced by TEST_F(), and VerifyGraph().

◆ EXPECT_TRUE

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

◆ TEST

#define TEST (   x,
 
)    TEST_F_(testing::Test, x##y, #x "." #y)

Definition at line 62 of file test.h.

◆ TEST_F

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

Definition at line 61 of file test.h.

◆ TEST_F_

#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:43
void RegisterTest(testing::Test *(*)(), const char *)

Definition at line 50 of file test.h.

Function Documentation

◆ AssertHash()

void AssertHash ( const char *  expected,
uint64_t  actual 
)

Definition at line 109 of file test.cc.

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

Referenced by TEST_F().

◆ AssertParse()

void AssertParse ( State state,
const char *  input,
ManifestParserOptions  = ManifestParserOptions() 
)

◆ RegisterTest()

void RegisterTest ( testing::Test *)(,
const char *   
)

◆ VerifyGraph()

void VerifyGraph ( const State state)

Variable Documentation

◆ g_current_test

testing::Test* g_current_test

Definition at line 43 of file ninja_test.cc.