Remove and replace type traits unit test (bug 675)

This commit is contained in:
Craig Dowell
2009-09-24 23:48:35 -07:00
parent c1d415cbee
commit 02c9beac45
3 changed files with 67 additions and 41 deletions

View File

@@ -0,0 +1,66 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "type-traits.h"
#include "test.h"
namespace ns3 {
class TypeTraitsTestCase : public TestCase
{
public:
TypeTraitsTestCase ();
virtual ~TypeTraitsTestCase () {}
private:
virtual bool DoRun (void);
};
TypeTraitsTestCase::TypeTraitsTestCase (void)
: TestCase ("Check type traits")
{
}
bool
TypeTraitsTestCase::DoRun (void)
{
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (void)>::IsPointerToMember, 1, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (void) const>::IsPointerToMember, 1, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (int)>::IsPointerToMember, 1, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (int) const>::IsPointerToMember, 1, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (void) const>::PointerToMemberTraits::nArgs, 0, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (int) const>::PointerToMemberTraits::nArgs, 1, "Check");
return GetErrorStatus ();
}
class TypeTraitsTestSuite : public TestSuite
{
public:
TypeTraitsTestSuite ();
};
TypeTraitsTestSuite::TypeTraitsTestSuite ()
: TestSuite ("type-traits", UNIT)
{
AddTestCase (new TypeTraitsTestCase);
}
TypeTraitsTestSuite typeTraitsTestSuite;
} // namespace ns3

View File

@@ -1,40 +0,0 @@
#include "type-traits.h"
#include "test.h"
#ifdef RUN_SELF_TESTS
namespace ns3 {
class TypeTraitsTest : public Test
{
public:
TypeTraitsTest ();
virtual bool RunTests (void);
};
TypeTraitsTest::TypeTraitsTest ()
: Test ("TypeTraits")
{}
bool
TypeTraitsTest::RunTests (void)
{
bool result = true;
//TypeTraits<int &>::ReferencedType ir;
//TypeTraits<const int>::NonConstType uci;
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (void)>::IsPointerToMember, 1);
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (void) const>::IsPointerToMember, 1);
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (int)>::IsPointerToMember, 1);
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (int) const>::IsPointerToMember, 1);
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (void) const>::PointerToMemberTraits::nArgs, 0);
NS_TEST_ASSERT_EQUAL (TypeTraits<void (TypeTraitsTest::*) (int) const>::PointerToMemberTraits::nArgs, 1);
return result;
}
static TypeTraitsTest g_typeTraitsTest;
} // namespace ns3
#endif /* RUN_SELF_TESTS */

View File

@@ -60,7 +60,6 @@ def build(bld):
'rng-stream.cc',
'command-line.cc',
'type-name.cc',
'type-traits-test.cc',
'attribute.cc',
'boolean.cc',
'integer.cc',
@@ -80,6 +79,7 @@ def build(bld):
'vector.cc',
'names-test-suite.cc',
'attribute-test-suite.cc',
'type-traits-test-suite.cc',
]
headers = bld.new_task_gen('ns3header')