| 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 | FAIL1("This test fails with one argument: %d" , 4); |
| 52 | } |
| 53 | |
| 54 | VM_UNIT_TEST_CASE(Fail2) { |
| 55 | FAIL2("This test fails with two arguments: %d, %d" , -100, 42); |
| 56 | } |
| 57 | |