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

Unified Diff: test/unittests/base/atomic-utils-unittest.cc

Issue 2215693002: [base] Add Decrement and assignment operators to AtomicNumber (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/base/atomic-utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/base/atomic-utils-unittest.cc
diff --git a/test/unittests/base/atomic-utils-unittest.cc b/test/unittests/base/atomic-utils-unittest.cc
index 06079fe287148a8f87e4a87229da3b23a63e7126..8e90c423e2cd5526352471816078f5e9ac351975 100644
--- a/test/unittests/base/atomic-utils-unittest.cc
+++ b/test/unittests/base/atomic-utils-unittest.cc
@@ -58,6 +58,29 @@ TEST(AtomicNumber, Increment) {
EXPECT_EQ(std::numeric_limits<size_t>::max(), c.Value());
}
+TEST(AtomicNumber, Decrement) {
+ AtomicNumber<size_t> a(std::numeric_limits<size_t>::max());
+ a.Increment(1);
+ EXPECT_EQ(0, a.Value());
+ a.Decrement(1);
+ EXPECT_EQ(std::numeric_limits<size_t>::max(), a.Value());
+}
+
+TEST(AtomicNumber, OperatorAdditionAssignment) {
+ AtomicNumber<size_t> a(0u);
+ AtomicNumber<size_t> b(std::numeric_limits<size_t>::max());
+ a += b.Value();
+ EXPECT_EQ(a.Value(), b.Value());
+ EXPECT_EQ(b.Value(), std::numeric_limits<size_t>::max());
+}
+
+TEST(AtomicNumber, OperatorSubtractionAssignment) {
+ AtomicNumber<size_t> a(std::numeric_limits<size_t>::max());
+ AtomicNumber<size_t> b(std::numeric_limits<size_t>::max());
+ a -= b.Value();
+ EXPECT_EQ(a.Value(), 0u);
+ EXPECT_EQ(b.Value(), std::numeric_limits<size_t>::max());
+}
namespace {
« no previous file with comments | « src/base/atomic-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698