Flutter Engine
The Flutter Engine
Functions
assert_test.cc File Reference
#include "platform/assert.h"
#include "vm/unit_test.h"

Go to the source code of this file.

Functions

 VM_UNIT_TEST_CASE (Assert)
 
 VM_UNIT_TEST_CASE (Expect)
 
 VM_UNIT_TEST_CASE (Fail0)
 
 VM_UNIT_TEST_CASE (Fail1)
 
 VM_UNIT_TEST_CASE (Fail2)
 
 VM_UNIT_TEST_CASE_WITH_EXPECTATION (Fatal, "Crash")
 

Function Documentation

◆ VM_UNIT_TEST_CASE() [1/5]

VM_UNIT_TEST_CASE ( Assert  )

Definition at line 8 of file assert_test.cc.

8 {
9 ASSERT(true);
10 ASSERT(87 == 87);
11 ASSERT(42 != 87);
12}
#define ASSERT(E)

◆ VM_UNIT_TEST_CASE() [2/5]

VM_UNIT_TEST_CASE ( Expect  )

Definition at line 14 of file assert_test.cc.

14 {
15 EXPECT(true);
16 EXPECT(87 == 87);
17 EXPECT(42 != 87);
18
19 EXPECT_EQ(0, 0);
20 EXPECT_EQ(42, 42);
21 EXPECT_EQ(true, true);
22 void* pointer = reinterpret_cast<void*>(42);
23 EXPECT_EQ(pointer, pointer);
24
25 EXPECT_STREQ("Hello", "Hello");
26
27 EXPECT_LT(1, 2);
28 EXPECT_LT(1, 1.5);
29 EXPECT_LT(-1.8, 3.14);
30
31 EXPECT_LE(1, 1);
32 EXPECT_LE(1, 2);
33 EXPECT_LE(0.5, 1);
34
35 EXPECT_GT(4, 1);
36 EXPECT_GT(2.3, 2.2229);
37
38 EXPECT_GE(4, 4);
39 EXPECT_GE(15.3, 15.3);
40 EXPECT_GE(5, 3);
41
42 EXPECT_FLOAT_EQ(15.43, 15.44, 0.01);
43 EXPECT_FLOAT_EQ(1.43, 1.43, 0.00);
44}
#define EXPECT(type, expectedAlignment, expectedSize)

◆ VM_UNIT_TEST_CASE() [3/5]

VM_UNIT_TEST_CASE ( Fail0  )

Definition at line 46 of file assert_test.cc.

46 {
47 FAIL("This test fails");
48}
#define FAIL(name, result)

◆ VM_UNIT_TEST_CASE() [4/5]

VM_UNIT_TEST_CASE ( Fail1  )

Definition at line 50 of file assert_test.cc.

50 {
51 FAIL("This test fails with one argument: %d", 4);
52}

◆ VM_UNIT_TEST_CASE() [5/5]

VM_UNIT_TEST_CASE ( Fail2  )

Definition at line 54 of file assert_test.cc.

54 {
55 FAIL("This test fails with two arguments: %d, %d", -100, 42);
56}

◆ VM_UNIT_TEST_CASE_WITH_EXPECTATION()

VM_UNIT_TEST_CASE_WITH_EXPECTATION ( Fatal  ,
"Crash"   
)

Definition at line 58 of file assert_test.cc.

58 {
59 FATAL("This test fails and produces a backtrace");
60}
#define FATAL(error)