⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orthodox.h

📁 This software aims to create an applet and panel tools to manage a wireless interface card, such as
💻 H
字号:
//
// Orthodox.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/Orthodox.h#5 $
//


#ifndef CppUnit_Orthodox_INCLUDED
#define CppUnit_Orthodox_INCLUDED


#ifndef CppUnit_CppUnit_INCLUDED
#include "CppUnit/CppUnit.h"
#endif
#ifndef CppUnit_TestCase_INCLUDED
#include "CppUnit/TestCase.h"
#endif


CppUnit_BEGIN


/*
 * Orthodox performs a simple set of tests on an arbitary
 * class to make sure that it supports at least the
 * following operations:
 *
 *      default construction    - constructor
 *      equality/inequality     - operator== && operator!=
 *      assignment              - operator=
 *      negation                - operator!
 *      safe passage            - copy construction
 *
 * If operations for each of these are not declared
 * the template will not instantiate.  If it does
 * instantiate, tests are performed to make sure
 * that the operations have correct semantics.
 *
 * Adding an orthodox test to a suite is very
 * easy:
 *
 * public: Test *suite ()  {
 *     TestSuite *suiteOfTests = new TestSuite;
 *     suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
 *     suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
 *     return suiteOfTests;
 *  }
 *
 * Templated test cases be very useful when you are want to
 * make sure that a group of classes have the same form.
 *
 * see TestSuite
 */
template <class ClassUnderTest> 
class Orthodox: public TestCase
{
public:
	Orthodox(): TestCase("Orthodox") 
	{
	}

protected:
    ClassUnderTest call(ClassUnderTest object);
    void runTest ();
};


// Run an orthodoxy test
template <class ClassUnderTest> 
void Orthodox<ClassUnderTest>::runTest()
{
    // make sure we have a default constructor
    ClassUnderTest   a, b, c;

    // make sure we have an equality operator
    assert (a == b);

    // check the inverse
    b.operator= (a.operator! ());
    assert (a != b);

    // double inversion
    b = !!a;
    assert (a == b);

    // invert again
    b = !a;

    // check calls
    c = a;
    assert (c == call (a));

    c = b;
    assert (c == call (b));
}


// Exercise a call
template <class ClassUnderTest> 
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
{
    return object;
}


CppUnit_END


#endif // CppUnit_Orthodox_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -