| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, 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 "platform/utils.h" |
| 7 #include "vm/atomic.h" |
| 8 #include "vm/globals.h" |
| 9 #include "vm/unit_test.h" |
| 10 |
| 11 namespace dart { |
| 12 |
| 13 UNIT_TEST_CASE(FetchAndIncrement) { |
| 14 uintptr_t v = 42; |
| 15 EXPECT_EQ(42, AtomicOperations::FetchAndIncrement(&v)); |
| 16 EXPECT_EQ(43, v); |
| 17 } |
| 18 |
| 19 |
| 20 UNIT_TEST_CASE(FetchAndAdd) { |
| 21 intptr_t v = 42; |
| 22 EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 0)); |
| 23 EXPECT_EQ(42, v); |
| 24 EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 2)); |
| 25 EXPECT_EQ(44, v); |
| 26 EXPECT_EQ(44, AtomicOperations::FetchAndAdd(&v, -2)); |
| 27 EXPECT_EQ(42, v); |
| 28 } |
| 29 |
| 30 |
| 31 UNIT_TEST_CASE(LoadRelaxed) { |
| 32 uword v = 42; |
| 33 EXPECT_EQ(42, AtomicOperations::LoadRelaxed(&v)); |
| 34 } |
| 35 |
| 36 } // namespace dart |
| OLD | NEW |