diff options
author | David Robillard <d@drobilla.net> | 2013-01-11 03:35:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-11 03:35:17 +0000 |
commit | f8aa3ee7621758b35ba52a5b17972fa4144710ae (patch) | |
tree | 2bf934c558b5c97f858be03101fa1544ecf6835d /test/atomic_test.cpp | |
parent | 77d36f84343baa0864e742834be15c0296dc4389 (diff) | |
download | raul-f8aa3ee7621758b35ba52a5b17972fa4144710ae.tar.gz raul-f8aa3ee7621758b35ba52a5b17972fa4144710ae.tar.bz2 raul-f8aa3ee7621758b35ba52a5b17972fa4144710ae.zip |
Use C++11 atomics.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4916 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/atomic_test.cpp')
-rw-r--r-- | test/atomic_test.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/test/atomic_test.cpp b/test/atomic_test.cpp deleted file mode 100644 index 5b6260c..0000000 --- a/test/atomic_test.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - This file is part of Raul. - Copyright 2007-2012 David Robillard <http://drobilla.net> - - Raul is free software: you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation, either version 3 of the License, or any later version. - - Raul is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Raul. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "raul/AtomicInt.hpp" -#include "raul/AtomicPtr.hpp" - -using namespace std; -using namespace Raul; - -#define TEST(cond) { if (!(cond)) return 1; } - -int -main() -{ - /* TODO: Actually test functionality... */ - AtomicInt i(0); - TEST(i == 0); - - AtomicInt j(i); - TEST(i == j); - - ++i; - TEST(i == 1); - - --i; - TEST(i == 0); - - TEST(i + 1 == 1); - TEST(i - 1 == -1); - - i += 2; - TEST(i == 2); - - i -= 4; - TEST(i == -2); - - TEST(i.compare_and_exchange(-2, 0)); - TEST(i == 0); - - TEST(i.exchange_and_add(5) == 0); - TEST(i == 5); - - i = 1; - TEST(i == 1); - TEST(i.decrement_and_test()); - - int five = 5; - int seven = 7; - AtomicPtr<int> p; - TEST(p.get() == NULL); - - AtomicPtr<int> q(p); - TEST(p == q); - - p = &five; - TEST(p.get() == &five); - TEST(*p.get() == 5); - TEST(p.compare_and_exchange(&five, &seven)); - TEST(p.get() == &seven); - TEST(*p.get() = 7); - - return 0; -} |