[openrtm-commit:00658] r2303 - trunk/OpenRTM-aist/src/lib/coil/tests/Task
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 2月 5日 (日) 10:17:13 JST
Author: n-ando
Date: 2012-02-05 10:17:12 +0900 (Sun, 05 Feb 2012)
New Revision: 2303
Modified:
trunk/OpenRTM-aist/src/lib/coil/tests/Task/TaskTests.cpp
Log:
[test] Indentation and comments have been modified.
Modified: trunk/OpenRTM-aist/src/lib/coil/tests/Task/TaskTests.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/tests/Task/TaskTests.cpp 2012-02-03 18:57:44 UTC (rev 2302)
+++ trunk/OpenRTM-aist/src/lib/coil/tests/Task/TaskTests.cpp 2012-02-05 01:17:12 UTC (rev 2303)
@@ -39,11 +39,11 @@
namespace Task
{
class TaskTests
- : public CppUnit::TestFixture ,
- public coil::Task
+ : public CppUnit::TestFixture ,
+ public coil::Task
{
CPPUNIT_TEST_SUITE(TaskTests);
-// CPPUNIT_TEST(test_case0);
+ // CPPUNIT_TEST(test_case0);
CPPUNIT_TEST(test_open_close);
CPPUNIT_TEST(test_activate);
CPPUNIT_TEST(test_activate2);
@@ -51,7 +51,7 @@
CPPUNIT_TEST(test_suspend);
CPPUNIT_TEST(test_resume);
CPPUNIT_TEST_SUITE_END();
-
+
private:
bool m_statflag;
short m_tasknumber;
@@ -64,14 +64,14 @@
*/
TaskTests()
{
- short ic;
- for (ic=0; ic<256; ic++)
+ short ic;
+ for (ic=0; ic<256; ic++)
{
- m_threadcnt[ic] = 0;
+ m_threadcnt[ic] = 0;
}
- m_statflag = false;
- m_tasknumber =0;
- m_threadcmd = 0;
+ m_statflag = false;
+ m_tasknumber =0;
+ m_threadcmd = 0;
}
/*!
@@ -80,7 +80,7 @@
~TaskTests()
{
}
-
+
/*!
* @brief Test initialization
*/
@@ -94,102 +94,98 @@
virtual void tearDown()
{
}
-
- /*
- ---------------------------------------------------------------------------
- ---------------------------------------------------------------------------
- */
+
+ //------------------------------------------------------------
int svc(void)
{
- short ic;
- m_statflag = true;
- switch(m_threadcmd)
+ short ic;
+ m_statflag = true;
+ switch(m_threadcmd)
{
- case 0:
- std::cout<<"/"<<std::endl;
- m_tasknumber ++;
- for(;;)
- {
- if(m_statflag != true)
- {
- break;
- }
- m_threadcnt[m_tasknumber-1]++;
+ case 0:
+ std::cout<<"/"<<std::endl;
+ m_tasknumber ++;
+ for(;;)
+ {
+ if(m_statflag != true)
+ {
+ break;
}
- break;
- case 1:
- std::cout<<"/"<<std::endl;
- for(ic=0;ic<10;ic++){
- ;;
- }
- break;
- default:
- break;
+ m_threadcnt[m_tasknumber-1]++;
+ }
+ break;
+ case 1:
+ std::cout<<"/"<<std::endl;
+ for(ic=0;ic<10;ic++){
+ ;;
+ }
+ break;
+ default:
+ break;
}
- return 0;
+ return 0;
}
/* test case */
void test_case0()
{
}
- /*
- ---------------------------------------------------------------------------
- This function tests the Task::open function and the Task::close function.
- Check that the open function and the close function return 0.
- ---------------------------------------------------------------------------
+ //============================================================
+ // This function tests the Task::open function and the Task::close
+ // function. Check that the open function and the close function
+ // return 0.
+ //============================================================
*/
void test_open_close()
{
- int iret;
- iret = 1;
- iret = open(0);
- CPPUNIT_ASSERT_MESSAGE("open", (iret == 0) );
-
- iret = 1;
- iret = close(0);
- CPPUNIT_ASSERT_MESSAGE("close", (iret == 0) );
-
+ int iret;
+ iret = 1;
+ iret = open(0);
+ CPPUNIT_ASSERT_MESSAGE("open", (iret == 0) );
+
+ iret = 1;
+ iret = close(0);
+ CPPUNIT_ASSERT_MESSAGE("close", (iret == 0) );
+
}
- /*
- ---------------------------------------------------------------------------
- This function tests the Task::activate function.
- Check that the thread makes only one even if the activate function is
- called two or more times.
- ---------------------------------------------------------------------------
+ //============================================================
+ // This function tests the Task::activate function. Check that
+ // the thread makes only one even if the activate function is
+ // called two or more times.
+ //============================================================
*/
void test_activate()
{
-
- time_t tmstart, tmend;
- char cstr[256];
- short ic;
- if ( m_statflag == true )
+
+ time_t tmstart, tmend;
+ char cstr[256];
+ short ic;
+ if ( m_statflag == true )
{
- m_statflag = false;
+ m_statflag = false;
}
- m_threadcmd = 0;
- m_tasknumber = 0;
- //Start 10 threads. & Check that only 1 thread start.
- for (ic=0; ic<10; ic++)
+ m_threadcmd = 0;
+ m_tasknumber = 0;
+ //Start 10 threads. & Check that only 1 thread start.
+ for (ic=0; ic<10; ic++)
{
- //Start a thread.
- activate();
- time(&tmstart);
- for(;;)
+ //Start a thread.
+ activate();
+ time(&tmstart);
+ for(;;)
{
time(&tmend);
if(difftime(tmend,tmstart)>=1.0)
- {
- break;
- }
- }
- sprintf(cstr, "counter:%d ", m_tasknumber);
- //Check that a thread start.
- CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == 1) );
+ {
+ break;
+ }
+ }
+ sprintf(cstr, "counter:%d ", m_tasknumber);
+ //Check that a thread start.
+ CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == 1) );
}
- m_statflag = false;
- wait();
-
+ m_statflag = false;
+ wait();
+
}
/*!
* @brief activate()
@@ -198,74 +194,69 @@
*/
void test_activate2()
{
-
- time_t tmstart, tmend;
- char cstr[256];
- short ic;
- if ( m_statflag == true )
+
+ time_t tmstart, tmend;
+ char cstr[256];
+ short ic;
+ if ( m_statflag == true )
{
- m_statflag = false;
+ m_statflag = false;
}
- m_threadcmd = 0;
- m_tasknumber = 0;
- //Start 10 threads. & Check that 10 thread start.
- for (ic=0; ic<10; ic++)
+ m_threadcmd = 0;
+ m_tasknumber = 0;
+ //Start 10 threads. & Check that 10 thread start.
+ for (ic=0; ic<10; ic++)
{
- //Start a thread.
- activate();
- time(&tmstart);
- for(;;)
+ //Start a thread.
+ activate();
+ time(&tmstart);
+ for(;;)
{
time(&tmend);
if(difftime(tmend,tmstart)>=1.0)
- {
- break;
- }
- }
- sprintf(cstr, "m_tasknumber:%d (ic+1):%d", m_tasknumber,ic+1);
- //Check that a thread start.
- CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == ic+1) );
- m_statflag = false;
- wait();
+ {
+ break;
+ }
+ }
+ sprintf(cstr, "m_tasknumber:%d (ic+1):%d", m_tasknumber,ic+1);
+ //Check that a thread start.
+ CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == ic+1) );
+ m_statflag = false;
+ wait();
}
-
+
}
- /*
- ---------------------------------------------------------------------------
- ---------------------------------------------------------------------------
- */
+ //============================================================
void test_wait()
{
- wait(); //If Segmentation fault is not caused, it is OK.
- m_threadcmd = 1;
- activate();
- wait();
+ wait(); //If Segmentation fault is not caused, it is OK.
+ m_threadcmd = 1;
+ activate();
+ wait();
}
- /*
- ---------------------------------------------------------------------------
- This function tests the Task::suspend function.
- Check that the suspend function returns 0.
- ---------------------------------------------------------------------------
- */
+ //============================================================
+ // This function tests the Task::suspend function.
+ // Check that the suspend function returns 0.
+ //============================================================
void test_suspend()
{
- int iret;
- iret = 1;
- iret = suspend();
- CPPUNIT_ASSERT_MESSAGE("suspend", (iret == 0) );
+ int iret;
+ iret = 1;
+ iret = suspend();
+ CPPUNIT_ASSERT_MESSAGE("suspend", (iret == 0) );
}
- /*
- ---------------------------------------------------------------------------
- This function tests the Task::resume function.
- Check that the resume function returns 0.
- ---------------------------------------------------------------------------
+
+ //============================================================
+ // This function tests the Task::resume function.
+ // Check that the resume function returns 0.
+ //============================================================
*/
void test_resume()
{
- int iret;
- iret = 1;
- iret = resume();
- CPPUNIT_ASSERT_MESSAGE("resume", (iret == 0) );
+ int iret;
+ iret = 1;
+ iret = resume();
+ CPPUNIT_ASSERT_MESSAGE("resume", (iret == 0) );
}
};
}; // namespace Task
@@ -278,13 +269,13 @@
#ifdef LOCAL_MAIN
int main(int argc, char* argv[])
{
- CppUnit::TextUi::TestRunner runner;
- runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
- CppUnit::Outputter* outputter =
- new CppUnit::TextOutputter(&runner.result(), std::cout);
- runner.setOutputter(outputter);
- bool retcode = runner.run();
- return !retcode;
+ CppUnit::TextUi::TestRunner runner;
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ CppUnit::Outputter* outputter =
+ new CppUnit::TextOutputter(&runner.result(), std::cout);
+ runner.setOutputter(outputter);
+ bool retcode = runner.run();
+ return !retcode;
}
#endif // MAIN
#endif // Task_cpp
openrtm-commit メーリングリストの案内