当前位置: 首页>>代码示例>>C++>>正文


C++ CPPUNIT_ASSERT_EQUAL函数代码示例

本文整理汇总了C++中CPPUNIT_ASSERT_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CPPUNIT_ASSERT_EQUAL函数的具体用法?C++ CPPUNIT_ASSERT_EQUAL怎么用?C++ CPPUNIT_ASSERT_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CPPUNIT_ASSERT_EQUAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CPPUNIT_ASSERT_EQUAL

void TestHistogram::test_serialize()
{
  (*testhisto_int).save_serialize("serialize_test.dat");
  
  Histogram<int, int, BinningNumber<int> > testhisto_load;
  testhisto_load.load_serialize("serialize_test.dat");

  CPPUNIT_ASSERT_EQUAL((*testhisto_int)[1], testhisto_load[1]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_int)[2], testhisto_load[2]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_int)[3], testhisto_load[3]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_int)[4], testhisto_load[4]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_int)[5], testhisto_load[5]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_int).get_binning().get_binning_width(), testhisto_load.get_binning().get_binning_width());
  CPPUNIT_ASSERT_EQUAL((*testhisto_int).get_binning().get_binning_reference(), testhisto_load.get_binning().get_binning_reference());

  (*testhisto_double).save_serialize("serialize_test.dat");
  
  Histogram<double, double, BinningNumber<double> > testhisto_load_double;
  testhisto_load_double.load_serialize("serialize_test.dat");

  CPPUNIT_ASSERT_EQUAL((*testhisto_double)[1.0], testhisto_load_double[1.0]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_double)[2.0], testhisto_load_double[2.0]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_double)[3.0], testhisto_load_double[3.0]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_double)[4.0], testhisto_load_double[4.0]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_double)[5.0], testhisto_load_double[5.0]);
  CPPUNIT_ASSERT_EQUAL((*testhisto_double).get_binning().get_binning_width(), testhisto_load_double.get_binning().get_binning_width());
  CPPUNIT_ASSERT_EQUAL((*testhisto_double).get_binning().get_binning_reference(), testhisto_load_double.get_binning().get_binning_reference());
}
开发者ID:SpeckFleck,项目名称:mocasinns,代码行数:28,代码来源:test_histogram.cpp

示例2: CPPUNIT_ASSERT_EQUAL

void ComponentTest::thre_slots_and_two_signals_result_in_3_max_port_count()
{
  Component     *comp = ComponentFactory::produce("", {"", "", ""}, {"", ""});
  CPPUNIT_ASSERT_EQUAL(size_t(3), comp->maxPortCount());
  ComponentFactory::dispose(comp);
}
开发者ID:ursfassler,项目名称:evdraw,代码行数:6,代码来源:ComponentTest.cpp

示例3: CPPUNIT_ASSERT_EQUAL

void SpinCtrlDoubleTestCase::Digits()
{
    m_spin->SetDigits(5);

    CPPUNIT_ASSERT_EQUAL(5, m_spin->GetDigits());
}
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:6,代码来源:spinctrldbltest.cpp

示例4: DefaultPacketFactory

void DEFAULTPACKETSTREAMERTF::testProcessData() {
    DefaultPacketFactory *factory =  new DefaultPacketFactory();
    DefaultPacketStreamer *streamer = new DefaultPacketStreamer(factory);
    DataBuffer *buffer = new DataBuffer;
    StreamingContext *context = streamer->createContext();
    CPPUNIT_ASSERT(context);

    DefaultPacket *packet = new DefaultPacket;
    DefaultPacket *result = NULL;
    size_t bodyLength;
    CPPUNIT_ASSERT(streamer->processData(buffer, context));
    CPPUNIT_ASSERT(!context->isBroken());
    CPPUNIT_ASSERT(!context->isCompleted());

    packet->setBody("",0);
    CPPUNIT_ASSERT(streamer->encode(packet, buffer));
    CPPUNIT_ASSERT(streamer->processData(buffer, context));
    CPPUNIT_ASSERT(!context->isBroken());
    CPPUNIT_ASSERT(context->isCompleted());
    result = dynamic_cast<DefaultPacket*>(context->getPacket());
    CPPUNIT_ASSERT(result);
    CPPUNIT_ASSERT(!result->getBody(bodyLength));
    CPPUNIT_ASSERT_EQUAL((size_t)0, bodyLength);
    context->reset();

    packet->setBody("a",1);
    CPPUNIT_ASSERT(streamer->encode(packet, buffer));
    CPPUNIT_ASSERT(streamer->processData(buffer, context));
    CPPUNIT_ASSERT(!context->isBroken());
    CPPUNIT_ASSERT(context->isCompleted());
    result = dynamic_cast<DefaultPacket*>(context->getPacket());
    CPPUNIT_ASSERT(result);
    CPPUNIT_ASSERT(result->getBody(bodyLength));
    CPPUNIT_ASSERT_EQUAL('a', *(result->getBody(bodyLength)));
    CPPUNIT_ASSERT_EQUAL((size_t)1, bodyLength);
    context->reset();

    packet->setBody("ab",2);
    CPPUNIT_ASSERT(streamer->encode(packet, buffer));
    packet->setBody("a",1);
    CPPUNIT_ASSERT(streamer->encode(packet, buffer));
    CPPUNIT_ASSERT(streamer->processData(buffer, context));
    CPPUNIT_ASSERT(!context->isBroken());
    CPPUNIT_ASSERT(context->isCompleted());
    result = dynamic_cast<DefaultPacket*>(context->getPacket());
    CPPUNIT_ASSERT(result);
    CPPUNIT_ASSERT(result->getBody(bodyLength));
    CPPUNIT_ASSERT_EQUAL('a', *(result->getBody(bodyLength)));
    CPPUNIT_ASSERT_EQUAL('b', *(result->getBody(bodyLength) + 1));
    CPPUNIT_ASSERT_EQUAL((size_t)2, bodyLength);
    context->reset();
    CPPUNIT_ASSERT(streamer->processData(buffer, context));
    CPPUNIT_ASSERT(!context->isBroken());
    CPPUNIT_ASSERT(context->isCompleted());
    result = dynamic_cast<DefaultPacket*>(context->getPacket());
    CPPUNIT_ASSERT(result);
    CPPUNIT_ASSERT(result->getBody(bodyLength));
    CPPUNIT_ASSERT_EQUAL('a', *(result->getBody(bodyLength)));
    CPPUNIT_ASSERT_EQUAL((size_t)1, bodyLength);
    context->reset();


    delete streamer;
    delete factory;
    delete buffer;
    delete packet;
    delete context;
}
开发者ID:AllanXiang,项目名称:Source,代码行数:68,代码来源:defaultpacketstreamertf.cpp

示例5: i32

/*==============================================================================
 * FUNCTION:		DfaTest::testMeetInt
 * OVERVIEW:		Test meeting IntegerTypes with various other types
 *============================================================================*/
void DfaTest::testMeetInt () {
	IntegerType i32(32, 1);
	IntegerType j32(32, 0);
	IntegerType u32(32, -1);
	IntegerType xint(0);
	IntegerType j16(16, 0);
	SizeType s32(32);
	SizeType s64(64);
	FloatType flt(32);
	PointerType pt(&flt);
	VoidType v;
	
	bool ch = false;
	i32.meetWith(&i32, ch, false);
	CPPUNIT_ASSERT(ch == false);
	std::ostringstream ost1;
	ost1<< &i32;
	std::string actual(ost1.str());
	std::string expected("i32");
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	i32.meetWith(&j32, ch, false);
	CPPUNIT_ASSERT(ch == false);
	j32.meetWith(&i32, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost2;
	ost2<< &i32;
	actual = ost2.str();
	expected = "i32";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	j32.setSigned(0);
	j32.meetWith(&v, ch, false);
	CPPUNIT_ASSERT(ch == false);
	std::ostringstream ost2a;
	ost2a<< &j32;
	actual = ost2a.str();
	expected = "j32";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	j32.meetWith(&u32, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost3;
	ost3<< &j32;
	actual = ost3.str();
	expected = "u32";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	u32.meetWith(&s32, ch, false);
	CPPUNIT_ASSERT(ch == false);
	std::ostringstream ost4;
	ost4<< &u32;
	actual = ost4.str();
	expected = "u32";
	CPPUNIT_ASSERT_EQUAL(expected, actual);
	
	u32.meetWith(&s64, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost5;
	ost5<< &u32;
	actual = ost5.str();
	expected = "u64";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	Type* res = i32.meetWith(&flt, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost6;
	ost6<< res;
	actual = ost6.str();
	expected = "union";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	res = i32.meetWith(&pt, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost7;
	ost7<< res;
	actual = ost7.str();
	expected = "union";
	CPPUNIT_ASSERT_EQUAL(expected, actual);
}
开发者ID:PhuongLam94,项目名称:Boomerang-Production,代码行数:89,代码来源:DfaTest.cpp

示例6: CPPUNIT_ASSERT_EQUAL

void ConfigTest::testSetCommentMark(void)
{
  Config config;
  config.setCommentMark('\\');
  CPPUNIT_ASSERT_EQUAL('\\', config.getCommentMark());
}
开发者ID:rhorii,项目名称:cslcsv,代码行数:6,代码来源:ConfigTest.cpp

示例7: CPPUNIT_ASSERT

/*==============================================================================
 * FUNCTION:        LoaderTest::testWinLoad
 * OVERVIEW:        Test loading Windows programs
 *============================================================================*/
void LoaderTest::testWinLoad ()
{
    std::ostringstream ost;

#if 0 /* FIXME: these tests should use non-proprietary programs */
    // Load Windows program calc.exe
    BinaryFileFactory bff;
    BinaryFile* pBF = bff.Load(CALC_WINDOWS);
    CPPUNIT_ASSERT(pBF != NULL);
    int n;
    SectionInfo* si;
    n = pBF->GetNumSections();
    ost << "Number of sections = " << std::dec << n << "\r\n";
    for (int i=0; i < n; i++)
        {
            si = pBF->GetSectionInfo(i);
            ost << si->pSectionName << "\t";
        }

    // Note: the string below needs to have embedded tabs. Edit with caution!
    std::string expected("Number of sections = 5\r\n"
                         ".text	.rdata	.data	.rsrc	.reloc	");
    std::string actual(ost.str());
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ADDRESS addr = pBF->GetMainEntryPoint();
    CPPUNIT_ASSERT(addr != NO_ADDRESS);

    // Test symbol table (imports)
    const char* s = pBF->SymbolByAddress(0x1292060U);
    if (s == 0)
        actual = "<not found>";
    else
        actual = std::string(s);
    expected = std::string("SetEvent");
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ADDRESS a = pBF->GetAddressByName("SetEvent");
    ADDRESS expectedAddr = 0x1292060;
    CPPUNIT_ASSERT_EQUAL(expectedAddr, a);
    pBF->UnLoad();
    bff.UnLoad();

    // Test loading the "new style" exes, as found in winXP etc
    pBF = bff.Load(CALC_WINXP);
    CPPUNIT_ASSERT(pBF != NULL);
    addr = pBF->GetMainEntryPoint();
    std::ostringstream ost1;
    ost1 << std::hex << addr;
    actual = ost1.str();
    expected = "1001f51";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
    pBF->UnLoad();
    bff.UnLoad();

    // Test loading the calc.exe found in Windows 2000 (more NT based)
    pBF = bff.Load(CALC_WIN2000);
    CPPUNIT_ASSERT(pBF != NULL);
    expected = "1001680";
    addr = pBF->GetMainEntryPoint();
    std::ostringstream ost2;
    ost2 << std::hex << addr;
    actual = ost2.str();
    CPPUNIT_ASSERT_EQUAL(expected, actual);
    pBF->UnLoad();
    bff.UnLoad();

    // Test loading the lpq.exe program - console mode PE file
    pBF = bff.Load(LPQ_WINDOWS);
    CPPUNIT_ASSERT(pBF != NULL);
    addr = pBF->GetMainEntryPoint();
    std::ostringstream ost3;
    ost3 << std::hex << addr;
    actual = ost3.str();
    expected = "18c1000";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
    pBF->UnLoad();
    bff.UnLoad();
#endif

    // Borland
    BinaryFileFactory bff;
    BinaryFile* pBF = bff.Load(SWITCH_BORLAND);
    CPPUNIT_ASSERT(pBF != NULL);
    ADDRESS addr = pBF->GetMainEntryPoint();
    std::ostringstream ost4;
    ost4 << std::hex << addr;
    std::string actual(ost4.str());
    std::string expected("401150");
    CPPUNIT_ASSERT_EQUAL(expected, actual);
    pBF->UnLoad();
    bff.UnLoad();
}
开发者ID:JFreaker,项目名称:boomerang,代码行数:97,代码来源:LoaderTest.cpp

示例8: CPPUNIT_ASSERT_EQUAL

void TestPluginManager::setCurrentPluginNeg() {
	Plugin *before = testPluginManager->getCurrentPlugin();
	testPluginManager->setCurrentPlugin(-1);
	CPPUNIT_ASSERT_EQUAL(before,testPluginManager->getCurrentPlugin());
}
开发者ID:masters-info-nantes,项目名称:madjan,代码行数:5,代码来源:TestPluginManager.cpp

示例9: _T

void FontMapperTestCase::NamesAndDesc()
{
    static const wxChar *charsets[] =
    {
        // some valid charsets
        _T("us-ascii"    ),
        _T("iso8859-1"   ),
        _T("iso-8859-12" ),
        _T("koi8-r"      ),
        _T("utf-7"       ),
        _T("cp1250"      ),
        _T("windows-1252"),

        // and now some bogus ones
        _T(""            ),
        _T("cp1249"      ),
        _T("iso--8859-1" ),
        _T("iso-8859-19" ),
    };

    static const wxChar *names[] =
    {
        // some valid charsets
        _T("default"     ),
        _T("iso-8859-1"  ),
        _T("iso-8859-12" ),
        _T("koi8-r"      ),
        _T("utf-7"       ),
        _T("windows-1250"),
        _T("windows-1252"),

        // and now some bogus ones
        _T("default"     ),
        _T("unknown--1"  ),
        _T("unknown--1"  ),
        _T("unknown--1"  ),
    };

    static const wxChar *descriptions[] =
    {
        // some valid charsets
        _T("Default encoding"                  ),
        _T("Western European (ISO-8859-1)"     ),
        _T("Indian (ISO-8859-12)"              ),
        _T("KOI8-R"                            ),
        _T("Unicode 7 bit (UTF-7)"             ),
        _T("Windows Central European (CP 1250)"),
        _T("Windows Western European (CP 1252)"),

        // and now some bogus ones
        _T("Default encoding"                  ),
        _T("Unknown encoding (-1)"             ),
        _T("Unknown encoding (-1)"             ),
        _T("Unknown encoding (-1)"             ),
    };

    wxFontMapperBase& fmap = *wxFontMapperBase::Get();
    for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
    {
        wxFontEncoding enc = fmap.CharsetToEncoding(charsets[n]);
        CPPUNIT_ASSERT_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
        CPPUNIT_ASSERT_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
    }
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:64,代码来源:fontmaptest.cpp

示例10: CPPUNIT_ASSERT_EQUAL

void VectorsTestCase::Resize()
{
    wxVector<CountedObject> v;
    v.resize(3);

    CPPUNIT_ASSERT_EQUAL( 3, v.size() );
    CPPUNIT_ASSERT_EQUAL( 3, CountedObject::GetCount() );
    CPPUNIT_ASSERT_EQUAL( 0, v[0].GetValue() );
    CPPUNIT_ASSERT_EQUAL( 0, v[1].GetValue() );
    CPPUNIT_ASSERT_EQUAL( 0, v[2].GetValue() );

    v.resize(1);
    CPPUNIT_ASSERT_EQUAL( 1, v.size() );
    CPPUNIT_ASSERT_EQUAL( 1, CountedObject::GetCount() );

    v.resize(4, CountedObject(17));
    CPPUNIT_ASSERT_EQUAL( 4, v.size() );
    CPPUNIT_ASSERT_EQUAL( 4, CountedObject::GetCount() );
    CPPUNIT_ASSERT_EQUAL( 0, v[0].GetValue() );
    CPPUNIT_ASSERT_EQUAL( 17, v[1].GetValue() );
    CPPUNIT_ASSERT_EQUAL( 17, v[2].GetValue() );
    CPPUNIT_ASSERT_EQUAL( 17, v[3].GetValue() );
}
开发者ID:CustomCardsOnline,项目名称:wxWidgets,代码行数:23,代码来源:vectors.cpp

示例11: _T

void CMCUCommonTest::TestParsePath()
{
	LPCTSTR strPath = _T( "\\12345/abcd\\thinkingl.keda.com" );
	TFileNameInfo tInfo = ParsePath( strPath );

	TFileNameInfo tInfo2;
	CPPUNIT_ASSERT( ParsePath( strPath, tInfo2 ) );

	// 两种方式的结果必须一样.
	CPPUNIT_ASSERT_EQUAL( tInfo, tInfo2 );

	CPPUNIT_ASSERT_EQUAL( tInfo.m_strBaseName, tstring(_T( "thinkingl.keda" )) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strDirectory, tstring( _T( "\\12345\\abcd\\" ) ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strExtName, tstring( _T( "com" ) ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strFileName, tstring( _T( "thinkingl.keda.com" ) ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strFilePath, tstring( strPath ) );

	LPCTSTR strPath2 = _T( "abc" );
	CPPUNIT_ASSERT( ParsePath( strPath2, tInfo ) );

	tInfo2 = ParsePath( strPath2 );
	CPPUNIT_ASSERT_EQUAL( tInfo2, tInfo );

	CPPUNIT_ASSERT_EQUAL( tInfo.m_strBaseName, tstring( strPath2 ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strDirectory, tstring( _T( "" ) ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strExtName, tstring( _T( "" ) ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strFileName, tstring( strPath2 ) );
	CPPUNIT_ASSERT_EQUAL( tInfo.m_strFilePath, tstring( strPath2 ) );
}
开发者ID:dalinhuang,项目名称:ffmpeg-port,代码行数:29,代码来源:mcucommontest.cpp

示例12: tripleBuffer

void osaTripleBufferTest::TestLogic(void)
{
    int value1 = 0;
    int value2 = 0;
    int value3 = 0;
    int * slot1 = &value1;
    int * slot2 = &value2;
    int * slot3 = &value3;
    osaTripleBuffer<int> tripleBuffer(slot1, slot2, slot3);

    // test initial configuration
    CPPUNIT_ASSERT_EQUAL(tripleBuffer.LastWriteNode->Pointer, slot1);
    CPPUNIT_ASSERT_EQUAL(tripleBuffer.LastWriteNode->Next->Pointer, slot2);
    CPPUNIT_ASSERT_EQUAL(tripleBuffer.LastWriteNode->Next->Next->Pointer, slot3);


    // write while nobody's reading
    tripleBuffer.BeginWrite(); {
        *(tripleBuffer.GetWritePointer()) = 1;
    } tripleBuffer.EndWrite();
    
    // read to make sure, no ongoing write
    tripleBuffer.BeginRead(); {
        CPPUNIT_ASSERT_EQUAL(1, *(tripleBuffer.GetReadPointer()));
    } tripleBuffer.EndRead();


    // very long write, read a couple of times in between to make sure value doesn't change
    tripleBuffer.BeginWrite(); {
        // read before change
        tripleBuffer.BeginRead(); {
            CPPUNIT_ASSERT_EQUAL(1, *(tripleBuffer.GetReadPointer()));
        } tripleBuffer.EndRead();
        // change
        *(tripleBuffer.GetWritePointer()) = 2;
        // read after change but before release
        tripleBuffer.BeginRead(); {
            CPPUNIT_ASSERT_EQUAL(1, *(tripleBuffer.GetReadPointer()));
        } tripleBuffer.EndRead();
    } tripleBuffer.EndWrite();
    // read after release
    tripleBuffer.BeginRead(); {
        CPPUNIT_ASSERT_EQUAL(2, *(tripleBuffer.GetReadPointer()));
    } tripleBuffer.EndRead();

    // very long read
    tripleBuffer.BeginRead(); {
        // read before change
        CPPUNIT_ASSERT_EQUAL(2, *(tripleBuffer.GetReadPointer()));
        // lock to write
        tripleBuffer.BeginWrite(); {
            *(tripleBuffer.GetWritePointer()) = 3;
        } tripleBuffer.EndWrite();
        // read again
        CPPUNIT_ASSERT_EQUAL(2, *(tripleBuffer.GetReadPointer()));
        // lock to write again
        tripleBuffer.BeginWrite(); {
            *(tripleBuffer.GetWritePointer()) = 4;
        } tripleBuffer.EndWrite();
        // read onceagain
        CPPUNIT_ASSERT_EQUAL(2, *(tripleBuffer.GetReadPointer()));
    } tripleBuffer.EndRead();
    // final read
    tripleBuffer.BeginRead(); {
        CPPUNIT_ASSERT_EQUAL(4, *(tripleBuffer.GetReadPointer()));
    } tripleBuffer.EndRead();
}
开发者ID:jhu-cisst,项目名称:cisst,代码行数:67,代码来源:osaTripleBufferTest.cpp

示例13: timesOne

void WrapperFactoryTest::testUnknown() {
	struct IntFactory {
		static int * timesOne(int * factor) {
			int * result = new int;
			*result = *factor * 1;
			return result;
		}
		static int * timesTwo(int * factor) {
			int * result = new int;
			*result = *factor * 2;
			return result;
		}
		static int * timesThree(int * factor) {
			int * result = new int;
			*result = *factor * 3;
			return result;
		}
	};
	typedef std::function<int * (int *)> IntCreator;
	{
		Util::WrapperFactory<int *, int *, int, IntCreator, Util::FallbackPolicies::ExceptionFallback> factory;
		factory.registerType(1, IntFactory::timesOne);
		factory.registerType(2, IntFactory::timesTwo);
		factory.registerType(3, IntFactory::timesThree);

		int one = 1;
		int two = 2;
		int three = 3;

		int * productA = factory.create(3, &one);
		int * productB = factory.create(2, &two);
		int * productC = factory.create(1, &three);

		CPPUNIT_ASSERT(productA != nullptr);
		CPPUNIT_ASSERT(productB != nullptr);
		CPPUNIT_ASSERT(productC != nullptr);

		CPPUNIT_ASSERT_EQUAL(3, *productA);
		CPPUNIT_ASSERT_EQUAL(4, *productB);
		CPPUNIT_ASSERT_EQUAL(3, *productC);

		delete productC;
		delete productB;
		delete productA;

		typedef Util::FallbackPolicies::ExceptionFallback<int *, int>::Exception FactoryException;
		CPPUNIT_ASSERT_THROW(factory.create(0, &one), FactoryException);
		CPPUNIT_ASSERT_THROW(factory.create(4, &two), FactoryException);
		CPPUNIT_ASSERT_THROW(factory.create(17, &three), FactoryException);
	}
	{
		Util::WrapperFactory<int *, int *, int, IntCreator, Util::FallbackPolicies::NULLFallback> factory;
		factory.registerType(1, IntFactory::timesOne);
		factory.registerType(2, IntFactory::timesTwo);
		factory.registerType(3, IntFactory::timesThree);

		int one = 1;
		int two = 2;
		int three = 3;

		CPPUNIT_ASSERT_EQUAL(static_cast<int *>(nullptr), factory.create(0, &one));
		CPPUNIT_ASSERT_EQUAL(static_cast<int *>(nullptr), factory.create(4, &two));
		CPPUNIT_ASSERT_EQUAL(static_cast<int *>(nullptr), factory.create(17, &three));

		CPPUNIT_ASSERT_NO_THROW(factory.create(0, &one));
		CPPUNIT_ASSERT_NO_THROW(factory.create(4, &two));
		CPPUNIT_ASSERT_NO_THROW(factory.create(17, &three));
	}
	{
		std::ostringstream outputStream;
		Util::FallbackPolicies::DefaultCreatorFallback<int *, int> fallback(2, outputStream);
		Util::WrapperFactory<int *, int *, int, IntCreator, Util::FallbackPolicies::DefaultCreatorFallback> factory(fallback);
		factory.registerType(1, IntFactory::timesOne);
		factory.registerType(2, IntFactory::timesTwo);
		factory.registerType(3, IntFactory::timesThree);

		int one = 1;
		int two = 2;
		int three = 3;

		int * productA = factory.create(0, &one);
		int * productB = factory.create(4, &two);
		int * productC = factory.create(17, &three);
		
		CPPUNIT_ASSERT(outputStream.good());
		CPPUNIT_ASSERT(!outputStream.str().empty());

		CPPUNIT_ASSERT(productA != nullptr);
		CPPUNIT_ASSERT(productB != nullptr);
		CPPUNIT_ASSERT(productC != nullptr);

		CPPUNIT_ASSERT_EQUAL(2, *productA);
		CPPUNIT_ASSERT_EQUAL(4, *productB);
		CPPUNIT_ASSERT_EQUAL(6, *productC);

		delete productC;
		delete productB;
		delete productA;
	}
}
开发者ID:PADrend,项目名称:Util,代码行数:100,代码来源:WrapperFactoryTest.cpp

示例14: checkGenericArraysEqual

static bool checkGenericArraysEqual(const GenericArray & expected, const GenericArray & actual) {
	CPPUNIT_ASSERT_EQUAL(expected.size(), actual.size());
	return std::equal(expected.cbegin(), expected.cend(), actual.cbegin(), &checkGenericsEqual);
}
开发者ID:PADrend,项目名称:Util,代码行数:4,代码来源:GenericConversionTest.cpp

示例15: CreateText

void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
{
    delete m_text;
    CreateText(style);

    // Asking for invalid index should fail.
    WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(1) );

    // Getting position shouldn't return wxDefaultPosition except if the method
    // is not implemented at all in the current port.
    const wxPoint pos0 = m_text->PositionToCoords(0);
    if ( pos0 == wxDefaultPosition )
    {
#if defined(__WXMSW__) || defined(__WXGTK20__)
        CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." );
#endif
        return;
    }

    CPPUNIT_ASSERT(pos0.x >= 0);
    CPPUNIT_ASSERT(pos0.y >= 0);


    m_text->SetValue("Hello");
    wxYield(); // Let GTK layout the control correctly.

    // Position of non-first character should be positive.
    const long posHello4 = m_text->PositionToCoords(4).x;
    CPPUNIT_ASSERT( posHello4 > 0 );

    // Asking for position beyond the last character should succeed and return
    // reasonable result.
    CPPUNIT_ASSERT( m_text->PositionToCoords(5).x > posHello4 );

    // But asking for the next position should fail.
    WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(6) );

    // Test getting the coordinates of the last character when it is in the
    // beginning of a new line to exercise MSW code which has specific logic
    // for it.
    m_text->AppendText("\n");
    const wxPoint posLast = m_text->PositionToCoords(m_text->GetLastPosition());
    CPPUNIT_ASSERT_EQUAL( pos0.x, posLast.x );
    CPPUNIT_ASSERT( posLast.y > 0 );


    // Add enough contents to the control to make sure it has a scrollbar.
    m_text->SetValue("First line" + wxString(50, '\n') + "Last line");
    m_text->SetInsertionPoint(0);
    wxYield(); // Let GTK layout the control correctly.

    // This shouldn't change anything for the first position coordinates.
    CPPUNIT_ASSERT_EQUAL( pos0, m_text->PositionToCoords(0) );

    // And the last one must be beyond the window boundary and so not be
    // visible -- but getting its coordinate should still work.
    CPPUNIT_ASSERT
    (
        m_text->PositionToCoords(m_text->GetLastPosition()).y > TEXT_HEIGHT
    );


    // Now make it scroll to the end and check that the first position now has
    // negative offset as its above the visible part of the window while the
    // last position is in its bounds.
    m_text->SetInsertionPointEnd();

    CPPUNIT_ASSERT( m_text->PositionToCoords(0).y < 0 );
    CPPUNIT_ASSERT
    (
        m_text->PositionToCoords(m_text->GetInsertionPoint()).y <= TEXT_HEIGHT
    );
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:73,代码来源:textctrltest.cpp


注:本文中的CPPUNIT_ASSERT_EQUAL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。