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

Unified Diff: tests/AtomicTest.cpp

Issue 2183473005: Clean up some unused atomic routines. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « include/private/SkAtomics.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/AtomicTest.cpp
diff --git a/tests/AtomicTest.cpp b/tests/AtomicTest.cpp
deleted file mode 100644
index 530fba79d55129d6f599b67156b9bf59549a100c..0000000000000000000000000000000000000000
--- a/tests/AtomicTest.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkAtomics.h"
-#include "SkThreadUtils.h"
-#include "SkTypes.h"
-#include "Test.h"
-
-struct AddInfo {
- int32_t valueToAdd;
- int timesToAdd;
-};
-
-static int32_t base = 0;
-
-static AddInfo gAdds[] = {
- { 3, 100 },
- { 2, 200 },
- { 7, 150 },
-};
-
-static void addABunchOfTimes(void* data) {
- AddInfo* addInfo = static_cast<AddInfo*>(data);
- for (int i = 0; i < addInfo->timesToAdd; i++) {
- sk_atomic_add(&base, addInfo->valueToAdd);
- }
-}
-
-DEF_TEST(Atomic, reporter) {
- int32_t total = base;
- SkThread* threads[SK_ARRAY_COUNT(gAdds)];
- for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
- total += gAdds[i].valueToAdd * gAdds[i].timesToAdd;
- }
- // Start the threads
- for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
- threads[i] = new SkThread(addABunchOfTimes, &gAdds[i]);
- threads[i]->start();
- }
-
- // Now end the threads
- for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
- threads[i]->join();
- delete threads[i];
- }
- REPORTER_ASSERT(reporter, total == base);
- // Ensure that the returned value from sk_atomic_add is correct.
- int32_t valueToModify = 3;
- const int32_t originalValue = valueToModify;
- REPORTER_ASSERT(reporter, originalValue == sk_atomic_add(&valueToModify, 7));
-
- {
- SkAtomic<int> v {0};
- REPORTER_ASSERT(reporter, 0 == v.load());
- v = 10;
- REPORTER_ASSERT(reporter, 10 == v.load());
- int q = v;
- REPORTER_ASSERT(reporter, 10 == q);
- }
-}
« no previous file with comments | « include/private/SkAtomics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698