Flutter Engine
The Flutter Engine
assert_test.cc
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "platform/assert.h"
6#include "vm/unit_test.h"
7
9 ASSERT(true);
10 ASSERT(87 == 87);
11 ASSERT(42 != 87);
12}
13
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}
45
47 FAIL("This test fails");
48}
49
51 FAIL("This test fails with one argument: %d", 4);
52}
53
55 FAIL("This test fails with two arguments: %d, %d", -100, 42);
56}
57
59 FATAL("This test fails and produces a backtrace");
60}
#define EXPECT(type, expectedAlignment, expectedSize)
VM_UNIT_TEST_CASE_WITH_EXPECTATION(Fatal, "Crash")
Definition: assert_test.cc:58
VM_UNIT_TEST_CASE(Assert)
Definition: assert_test.cc:8
#define FAIL(name, result)
#define ASSERT(E)
#define FATAL(error)
void Fatal(char const *file, int line, char const *error)