00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 // This file is part of FZIs ic_workspace. 00005 // 00006 // This program is free software licensed under the LGPL 00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3). 00008 // You can find a copy of this license in LICENSE folder in the top 00009 // directory of the source code. 00010 // 00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany 00012 // 00013 // -- END LICENSE BLOCK ------------------------------------------------ 00014 00015 //---------------------------------------------------------------------- 00022 //---------------------------------------------------------------------- 00023 #include <boost/test/unit_test.hpp> 00024 #include <icl_core_thread/Thread.h> 00025 00026 using icl_core::thread::Thread; 00027 00028 class TestThread : public Thread 00029 { 00030 public: 00031 TestThread() 00032 : Thread("Test Thread"), 00033 m_has_run(false) 00034 { } 00035 00036 virtual ~TestThread() 00037 { } 00038 00039 virtual void run() 00040 { 00041 m_has_run = true; 00042 } 00043 00044 bool hasRun() const { return m_has_run; } 00045 00046 private: 00047 bool m_has_run; 00048 }; 00049 00050 BOOST_AUTO_TEST_SUITE(ts_Thread) 00051 00052 BOOST_AUTO_TEST_CASE(RunThread) 00053 { 00054 TestThread test_thread; 00055 00056 BOOST_CHECK(!test_thread.hasRun()); 00057 00058 test_thread.start(); 00059 test_thread.stop(); 00060 test_thread.join(); 00061 00062 BOOST_CHECK(test_thread.hasRun()); 00063 } 00064 00065 BOOST_AUTO_TEST_SUITE_END()