diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-06-12 10:33:37 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-06-12 10:43:06 +0100 |
commit | e784f98027dbd5cdc46712751dcfba8278eb7fa9 (patch) | |
tree | 5124843e810d60e637489c98ed22ba12998f2d4d /libstdc++-v3 | |
parent | 17412a74c531a21595311df5428f26552e82dfa8 (diff) | |
download | gcc-e784f98027dbd5cdc46712751dcfba8278eb7fa9.zip gcc-e784f98027dbd5cdc46712751dcfba8278eb7fa9.tar.gz gcc-e784f98027dbd5cdc46712751dcfba8278eb7fa9.tar.bz2 |
libstdc++: Improve tests for std::atomic_flag
The tests for clear() and test_and_set() didn't cover all cases.
* testsuite/29_atomics/atomic_flag/clear/1.cc: Also test clear()
when the value is currently set.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc:
Actually check the return value.
* testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc:
Likewise.
Diffstat (limited to 'libstdc++-v3')
3 files changed, 10 insertions, 12 deletions
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc index 30d9075..ed5d11a 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc @@ -25,9 +25,9 @@ int main() { std::atomic_flag f = ATOMIC_FLAG_INIT; - f.clear(); // set to false + f.clear(); // set to false + VERIFY( false == f.test_and_set() ); // return true + VERIFY( true == f.test_and_set() ); // return true + f.clear(); // set to false VERIFY( false == f.test_and_set() ); // return previous false, set to true - VERIFY( true == f.test_and_set() ); // return true - - return 0; } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc index 5d6dbcc..1934854 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc @@ -19,14 +19,13 @@ // <http://www.gnu.org/licenses/>. #include <atomic> +#include <testsuite_hooks.h> int main() { using namespace std; atomic_flag af = ATOMIC_FLAG_INIT; - if (!af.test_and_set(memory_order_acquire)) - af.clear(memory_order_release); - - return 0; + VERIFY( ! af.test_and_set(memory_order_acquire) ); + VERIFY( af.test_and_set(memory_order_acquire) ); } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc index 8e1284c..1934854 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc @@ -19,14 +19,13 @@ // <http://www.gnu.org/licenses/>. #include <atomic> +#include <testsuite_hooks.h> int main() { using namespace std; atomic_flag af = ATOMIC_FLAG_INIT; - if (!af.test_and_set()) - af.clear(); - - return 0; + VERIFY( ! af.test_and_set(memory_order_acquire) ); + VERIFY( af.test_and_set(memory_order_acquire) ); } |