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

Side by Side Diff: test/unittests/atomic-utils-unittest.cc

Issue 1343883004: Add barriers to atomic utils. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test expectations Created 5 years, 3 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 | « src/atomic-utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 6
7 #include "src/atomic-utils.h" 7 #include "src/atomic-utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 TEST(AtomicValue, TrySetValue) { 79 TEST(AtomicValue, TrySetValue) {
80 AtomicValue<TestFlag> a(kA); 80 AtomicValue<TestFlag> a(kA);
81 EXPECT_FALSE(a.TrySetValue(kB, kC)); 81 EXPECT_FALSE(a.TrySetValue(kB, kC));
82 EXPECT_TRUE(a.TrySetValue(kA, kC)); 82 EXPECT_TRUE(a.TrySetValue(kA, kC));
83 EXPECT_EQ(TestFlag::kC, a.Value()); 83 EXPECT_EQ(TestFlag::kC, a.Value());
84 } 84 }
85 85
86 86
87 TEST(AtomicValue, SetValue) { 87 TEST(AtomicValue, SetValue) {
88 AtomicValue<TestFlag> a(kB); 88 AtomicValue<TestFlag> a(kB);
89 EXPECT_EQ(kB, a.SetValue(kC)); 89 a.SetValue(kC);
90 EXPECT_EQ(TestFlag::kC, a.Value()); 90 EXPECT_EQ(TestFlag::kC, a.Value());
91 } 91 }
92 92
93 93
94 TEST(AtomicValue, WithVoidStar) { 94 TEST(AtomicValue, WithVoidStar) {
95 AtomicValue<void*> a(nullptr); 95 AtomicValue<void*> a(nullptr);
96 AtomicValue<void*> dummy(nullptr); 96 AtomicValue<void*> dummy(nullptr);
97 EXPECT_EQ(nullptr, a.Value()); 97 EXPECT_EQ(nullptr, a.Value());
98 EXPECT_EQ(nullptr, a.SetValue(&a)); 98 a.SetValue(&a);
99 EXPECT_EQ(&a, a.Value()); 99 EXPECT_EQ(&a, a.Value());
100 EXPECT_FALSE(a.TrySetValue(nullptr, &dummy)); 100 EXPECT_FALSE(a.TrySetValue(nullptr, &dummy));
101 EXPECT_TRUE(a.TrySetValue(&a, &dummy)); 101 EXPECT_TRUE(a.TrySetValue(&a, &dummy));
102 EXPECT_EQ(&dummy, a.Value()); 102 EXPECT_EQ(&dummy, a.Value());
103 } 103 }
104 104
105 105
106 namespace { 106 namespace {
107 107
108 enum TestSetValue { kAA, kBB, kCC, kLastValue = kCC }; 108 enum TestSetValue { kAA, kBB, kCC, kLastValue = kCC };
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 a.Add(kAA); 208 a.Add(kAA);
209 EXPECT_FALSE(a == b); 209 EXPECT_FALSE(a == b);
210 EXPECT_TRUE(a != b); 210 EXPECT_TRUE(a != b);
211 b.Add(kAA); 211 b.Add(kAA);
212 EXPECT_TRUE(a == b); 212 EXPECT_TRUE(a == b);
213 EXPECT_FALSE(a != b); 213 EXPECT_FALSE(a != b);
214 } 214 }
215 215
216 } // namespace internal 216 } // namespace internal
217 } // namespace v8 217 } // namespace v8
OLDNEW
« no previous file with comments | « src/atomic-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698