From aef42fcdc6a569f254a8c1a1b1d4e18475538f56 Mon Sep 17 00:00:00 2001 From: maier Date: Sat, 7 Dec 2013 22:09:42 +0000 Subject: [PATCH] *sigh* git-svn-id: https://svn.dealii.org/trunk@31926 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/thread_local_storage_04.cc | 82 +++++++++++++++++++ tests/base/thread_local_storage_04.output | 2 - ...ad_local_storage_04.with_threads=on.output | 82 +------------------ 3 files changed, 83 insertions(+), 83 deletions(-) create mode 100644 tests/base/thread_local_storage_04.cc delete mode 100644 tests/base/thread_local_storage_04.output diff --git a/tests/base/thread_local_storage_04.cc b/tests/base/thread_local_storage_04.cc new file mode 100644 index 0000000000..84e3aea0c1 --- /dev/null +++ b/tests/base/thread_local_storage_04.cc @@ -0,0 +1,82 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2008 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// test ThreadLocalStorage::operator= (const T&) + +#include "../tests.h" +#include +#include + +#include +#include + +int counter = 10; + +struct X +{ + Threads::ThreadLocalStorage tls_data; + + X () + : + tls_data (42) + {} + + int f () + { + // use TLS::operator= + tls_data = counter++; + // access TLS data and have it + // converted to the right data type + // without the need to call + // tls_data.get() + return tls_data; + } +}; + + +void test () +{ + X x; + { + Threads::Thread t; + t = Threads::new_thread (&X::f, x); + AssertThrow (t.return_value() == 10, + ExcInternalError()); + } + { + Threads::Thread t; + t = Threads::new_thread (&X::f, x); + AssertThrow (t.return_value() == 11, + ExcInternalError()); + } + + AssertThrow (counter == 12, ExcInternalError()); +} + + + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + deallog << "OK" << std::endl; +} diff --git a/tests/base/thread_local_storage_04.output b/tests/base/thread_local_storage_04.output deleted file mode 100644 index 0fd8fc12f0..0000000000 --- a/tests/base/thread_local_storage_04.output +++ /dev/null @@ -1,2 +0,0 @@ - -DEAL::OK diff --git a/tests/base/thread_local_storage_04.with_threads=on.output b/tests/base/thread_local_storage_04.with_threads=on.output index 84e3aea0c1..0fd8fc12f0 100644 --- a/tests/base/thread_local_storage_04.with_threads=on.output +++ b/tests/base/thread_local_storage_04.with_threads=on.output @@ -1,82 +1,2 @@ -// --------------------------------------------------------------------- -// $Id$ -// -// Copyright (C) 2008 - 2013 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE at -// the top level of the deal.II distribution. -// -// --------------------------------------------------------------------- - -// test ThreadLocalStorage::operator= (const T&) - -#include "../tests.h" -#include -#include - -#include -#include - -int counter = 10; - -struct X -{ - Threads::ThreadLocalStorage tls_data; - - X () - : - tls_data (42) - {} - - int f () - { - // use TLS::operator= - tls_data = counter++; - // access TLS data and have it - // converted to the right data type - // without the need to call - // tls_data.get() - return tls_data; - } -}; - - -void test () -{ - X x; - { - Threads::Thread t; - t = Threads::new_thread (&X::f, x); - AssertThrow (t.return_value() == 10, - ExcInternalError()); - } - { - Threads::Thread t; - t = Threads::new_thread (&X::f, x); - AssertThrow (t.return_value() == 11, - ExcInternalError()); - } - - AssertThrow (counter == 12, ExcInternalError()); -} - - - - -int main() -{ - std::ofstream logfile("output"); - deallog.attach(logfile); - deallog.depth_console(0); - deallog.threshold_double(1.e-10); - - test (); - deallog << "OK" << std::endl; -} +DEAL::OK -- 2.39.5