Flutter Engine
The Flutter Engine
third_party
dart-lang
sdk
runtime
vm
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
8
VM_UNIT_TEST_CASE
(Assert) {
9
ASSERT
(
true
);
10
ASSERT
(87 == 87);
11
ASSERT
(42 != 87);
12
}
13
14
VM_UNIT_TEST_CASE
(Expect) {
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
46
VM_UNIT_TEST_CASE
(Fail0) {
47
FAIL
(
"This test fails"
);
48
}
49
50
VM_UNIT_TEST_CASE
(Fail1) {
51
FAIL
(
"This test fails with one argument: %d"
, 4);
52
}
53
54
VM_UNIT_TEST_CASE
(Fail2) {
55
FAIL
(
"This test fails with two arguments: %d, %d"
, -100, 42);
56
}
57
58
VM_UNIT_TEST_CASE_WITH_EXPECTATION
(
Fatal
,
"Crash"
) {
59
FATAL
(
"This test fails and produces a backtrace"
);
60
}
EXPECT
#define EXPECT(type, expectedAlignment, expectedSize)
Definition:
UniformOffsetCalculatorTest.cpp:33
assert.h
VM_UNIT_TEST_CASE_WITH_EXPECTATION
VM_UNIT_TEST_CASE_WITH_EXPECTATION(Fatal, "Crash")
Definition:
assert_test.cc:58
VM_UNIT_TEST_CASE
VM_UNIT_TEST_CASE(Assert)
Definition:
assert_test.cc:8
FAIL
#define FAIL(name, result)
Definition:
entrypoints_verification_test.cc:36
ASSERT
#define ASSERT(E)
Definition:
entrypoints_verification_test.cc:25
FATAL
#define FATAL(error)
Definition:
ffi_test_functions_vmspecific.cc:435
dart::Fatal
void Fatal(char const *file, int line, char const *error)
Definition:
ffi_test_functions_vmspecific.cc:427
unit_test.h
Generated on Sun Jun 23 2024 21:55:26 for Flutter Engine by
1.9.4