Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: runtime/vm/atomic_test.cc

Issue 1658983004: Change signature of atomic increment/decrement functions to return void. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/atomic_macos.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "platform/utils.h" 6 #include "platform/utils.h"
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 UNIT_TEST_CASE(FetchAndIncrement) { 13 UNIT_TEST_CASE(FetchAndIncrement) {
14 uintptr_t v = 42; 14 uintptr_t v = 42;
15 EXPECT_EQ(static_cast<uintptr_t>(42), 15 EXPECT_EQ(static_cast<uintptr_t>(42),
16 AtomicOperations::FetchAndIncrement(&v)); 16 AtomicOperations::FetchAndIncrement(&v));
17 EXPECT_EQ(static_cast<uintptr_t>(43), v); 17 EXPECT_EQ(static_cast<uintptr_t>(43), v);
18 } 18 }
19 19
20 20
21 UNIT_TEST_CASE(FetchAndDecrement) { 21 UNIT_TEST_CASE(FetchAndDecrement) {
22 uintptr_t v = 42; 22 uintptr_t v = 42;
23 EXPECT_EQ(static_cast<uintptr_t>(42), 23 EXPECT_EQ(static_cast<uintptr_t>(42),
24 AtomicOperations::FetchAndDecrement(&v)); 24 AtomicOperations::FetchAndDecrement(&v));
25 EXPECT_EQ(static_cast<uintptr_t>(41), v); 25 EXPECT_EQ(static_cast<uintptr_t>(41), v);
26 } 26 }
27 27
28 28
29 UNIT_TEST_CASE(FetchAndIncrementBy) { 29 UNIT_TEST_CASE(IncrementBy) {
30 intptr_t v = 42; 30 intptr_t v = 42;
31 EXPECT_EQ(static_cast<uintptr_t>(42), 31 AtomicOperations::IncrementBy(&v, 100);
32 AtomicOperations::FetchAndIncrementBy(&v, 100));
33 EXPECT_EQ(static_cast<intptr_t>(142), v); 32 EXPECT_EQ(static_cast<intptr_t>(142), v);
34 } 33 }
35 34
36 35
37 UNIT_TEST_CASE(FetchAndDecrementBy) { 36 UNIT_TEST_CASE(DecrementBy) {
38 intptr_t v = 42; 37 intptr_t v = 42;
39 EXPECT_EQ(static_cast<uintptr_t>(42), 38 AtomicOperations::DecrementBy(&v, 41);
40 AtomicOperations::FetchAndDecrementBy(&v, 41));
41 EXPECT_EQ(static_cast<intptr_t>(1), v); 39 EXPECT_EQ(static_cast<intptr_t>(1), v);
42 } 40 }
43 41
44 42
45 UNIT_TEST_CASE(LoadRelaxed) { 43 UNIT_TEST_CASE(LoadRelaxed) {
46 uword v = 42; 44 uword v = 42;
47 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v)); 45 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v));
48 } 46 }
49 47
50 48
51 TEST_CASE(CompareAndSwapWord) { 49 TEST_CASE(CompareAndSwapWord) {
52 uword old_value = 42; 50 uword old_value = 42;
53 uword new_value = 100; 51 uword new_value = 100;
54 uword result = AtomicOperations::CompareAndSwapWord( 52 uword result = AtomicOperations::CompareAndSwapWord(
55 &old_value, old_value, new_value); 53 &old_value, old_value, new_value);
56 EXPECT_EQ(static_cast<uword>(42), result); 54 EXPECT_EQ(static_cast<uword>(42), result);
57 } 55 }
58 56
59 57
60 TEST_CASE(CompareAndSwapUint32) { 58 TEST_CASE(CompareAndSwapUint32) {
61 uint32_t old_value = 42; 59 uint32_t old_value = 42;
62 uint32_t new_value = 100; 60 uint32_t new_value = 100;
63 uint32_t result = AtomicOperations::CompareAndSwapUint32( 61 uint32_t result = AtomicOperations::CompareAndSwapUint32(
64 &old_value, old_value, new_value); 62 &old_value, old_value, new_value);
65 EXPECT_EQ(static_cast<uint32_t>(42), result); 63 EXPECT_EQ(static_cast<uint32_t>(42), result);
66 } 64 }
67 65
68 } // namespace dart 66 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/atomic_macos.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698