• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TestMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CheckInvariant

void CheckInvariant( const TestMap& m )
{	
//	assert( map.__rb_verify() );
    EH_STD::size_t total = 0;
    EH_DISTANCE( m.begin(), m.end(), total );
    assert( m.size() == total );
}
开发者ID:rickyharis39,项目名称:nolf2,代码行数:7,代码来源:test_map.cpp


示例2: PtmapLoad

//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::EresUnittest_Unrank
//
//	@doc:
//		Rehydrate all trees encoded in the map
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTreeMapTest::EresUnittest_Unrank()
{
	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();
	
	TestMap *ptmap = PtmapLoad(pmp);	
	
	// debug print
	CWStringDynamic str(pmp);
	COstreamString oss(&str);
	
	ULLONG ullCount = ptmap->UllCount();
	
	for (ULONG ulRank = 0; ulRank < ullCount; ulRank++)
	{
		oss << "=== tree rank: " << ulRank << " ===" << std::endl;
		BOOL fFlag = true;
		CNode *pnd = ptmap->PrUnrank(pmp, &fFlag, ulRank);
		(void) pnd->OsPrint(oss);
		
		pnd->Release();
	}
	
	GPOS_TRACE(str.Wsz());
	GPOS_DELETE(ptmap);

	return GPOS_OK;
}
开发者ID:HanumathRao,项目名称:gporca,代码行数:37,代码来源:CTreeMapTest.cpp


示例3: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::PtmapLoad
//
//	@doc:
//		Create a semantically meaningful tree map by simulating a MEMO 
//		layout
//
//---------------------------------------------------------------------------
CTreeMapTest::TestMap *
CTreeMapTest::PtmapLoad
	(
	IMemoryPool *pmp
	)
{
	TestMap *ptmap = GPOS_NEW(pmp) TestMap(pmp, &Pnd);
	
	// init raw data
	for (ULONG ulPos = 0; ulPos < ulElems; ulPos++)
	{
		rgul[ulPos] = ulPos;
	}

	
	// simulate the following MEMO with individual edge insertions
	struct SEdge
	{
		// number of parent node
		ULONG m_ulParent;
		
		// position of child
		ULONG m_ulPos;
		
		// number of child node
		ULONG m_ulChild;
	}
	rgedge[]=
	{
		// root group: Join [4,3], HashJoin[4,3]{8}, HashJoin[3,4]{9}
		{9, 1, 7}, {9, 0, 6}, {9, 0, 5},
		{8, 0, 7}, {8, 1, 5}, {8, 1, 6},
		
		// group 4: C, TabScan{7} 
		
		// group 3: Join[1,2], HashJoin[1,2]{5}, SortMergeJoin[1,2]{6}
		{5, 0, 0}, {5, 0, 1}, {5, 1, 2}, {5, 1, 3}, {5, 1, 4},
		{6, 0, 1}, {6, 1, 3}, {6, 1, 4},
		
		// group 2: B, TabScan{2}, IndexScan{3}, Sort[2]{4}
		{4, 0, 2}
		
		// group 1: A, TabScan{0}, IndexScan{1}
	};
		
	for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(rgedge); ul++)
	{
		SEdge &edge = rgedge[ul];
		ptmap->Insert(&rgul[edge.m_ulParent], edge.m_ulPos, &rgul[edge.m_ulChild]);
	}

	return ptmap;
}
开发者ID:HanumathRao,项目名称:gporca,代码行数:62,代码来源:CTreeMapTest.cpp


示例4: main

int main()
{
	TestMap testMap;
	map<int, int> myMap;
	myMap.insert(std::make_pair(2, 4));
	myMap.insert(std::make_pair(6, 8));
	testMap.setMap(myMap);
	myMap.clear();
	myMap.insert(std::make_pair(1, 3));
	myMap.insert(std::make_pair(5, 7));
	testMap.setMap(myMap);
	myMap.clear();
	testMap.getMap();
	system("pause");
	return 0;
}
开发者ID:administratoroot,项目名称:CppTest,代码行数:16,代码来源:CopyMap.cpp


示例5: TEST

TEST(CollectionUtilsTest, mapInsertOrReplaceCopy) {
    typedef std::map<std::string, std::string> TestMap;

    TestMap testMap;
    const std::string key("Key");
    std::string value1("Value");
    std::string value2("Value2");
    
    MapUtils::insertOrReplace(testMap, key, value1);
    ASSERT_EQ(1u, testMap.size());
    ASSERT_EQ(value1, testMap[key]);
    
    MapUtils::insertOrReplace(testMap, key, value2);
    ASSERT_EQ(1u, testMap.size());
    ASSERT_EQ(value2, testMap[key]);
}
开发者ID:kduske,项目名称:Tippi,代码行数:16,代码来源:CollectionUtilsTest.cpp


示例6: main

int main( int argc, const char** argv)
{
	try
	{
		if (argc < 3)
		{
			throw std::runtime_error( "missing arguments <nof inserts> <nof queries>");
		}
		unsigned int nofInserts;
		unsigned int nofQueries;
		try
		{
			nofInserts = strus::utils::toint( argv[1]);
			nofQueries = strus::utils::toint( argv[2]);
		}
		catch (const std::exception& e)
		{
			throw std::runtime_error( std::string("bad values for arguments <nof inserts> <nof queries> (2 non negative integers expected): ") + e.what());
		}
		initRand();
		typedef strus::StringMap<strus::Index> TestMap;
		TestMap testmap;
		conotrie::CompactNodeTrie origmap;
		std::vector<std::string> keyar;

		std::size_t ii = 0;
		for (; ii<nofInserts; ++ii)
		{
			std::string key;
			do
			{
				key = randomKey( 32);
			}
			while (testmap.find(key) != testmap.end());

			testmap[ key] = ii+1;
			keyar.push_back( key);
		}
		testmap.clear();

		std::clock_t start;
		double duration;
		start = std::clock();

		for (ii=0; ii<nofInserts; ++ii)
		{
			testmap[ keyar[ ii]] = ii+1;
		}
		duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
		std::cerr << "inserted " << nofInserts << " keys in STL map in " << doubleToString(duration) << " seconds" << std::endl;

		start = std::clock();
		for (ii=0; ii<nofInserts; ++ii)
		{
			origmap.set( keyar[ ii].c_str(), ii+1);
		}
		duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
		std::cerr << "inserted " << nofInserts << " keys in variable size node tree in " << doubleToString(duration) << " seconds" << std::endl;

		start = std::clock();
		for (ii=0; ii<nofQueries; ++ii)
		{
			unsigned int keyidx = RANDINT(0,nofInserts);
			TestMap::const_iterator
				mi = testmap.find( keyar[ keyidx]);
			if (mi == testmap.end() || mi->second != (strus::Index)keyidx+1)
			{
				throw std::logic_error("TESTMAP LOOKUP FAILED");
			}
		}
		duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
		std::cerr << "queried boost unordered map with " << nofQueries << " random selected keys in " << doubleToString(duration) << " seconds" << std::endl;

		start = std::clock();
		for (ii=0; ii<nofQueries; ++ii)
		{
			unsigned int keyidx = RANDINT(0,nofInserts);
			conotrie::CompactNodeTrie::NodeData val;
			if (!origmap.get( keyar[ keyidx].c_str(), val)
			||  val != keyidx+1)
			{
				throw std::runtime_error( "VARIABLE SIZE NODE LOOKUP FAILED");
			}
		}
		duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
		std::cerr << "queried variable size node tree " << nofQueries << " random selected keys in " << doubleToString(duration) << " seconds" << std::endl;

		TestMap::const_iterator
			ti = testmap.begin(), te = testmap.end();

		for (; ti != te; ++ti)
		{
			conotrie::CompactNodeTrie::NodeData val;
			if (!origmap.get( ti->first, val))
			{
				throw std::runtime_error( std::string( "inserted key '") + ti->first + "' disapeared in variable size node tree");
			}
		}

		conotrie::CompactNodeTrie::const_iterator
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例7: ExecuteAll

// Executes all tests and returns the number of failures.
int ExecuteAll() {
    const int num_tests = tests.size();
    std::cout << "Executing " << num_tests << " tests..." << std::endl;
    std::vector<std::string> failures;
    int passing = 0;
    for (auto it = tests.begin(); it != tests.end(); ++it) {
        sel::State state{true};
        const bool result = it->second(state);
        if (result) {
            passing += 1;
            std::cout << "." << std::flush;
        } else {
            std::cout << "x" << std::flush;
            failures.push_back(std::string{"Test \""} +
                               it->first + "\" failed.");
        }
        int size = state.Size();
        if (size != 0)
            failures.push_back(std::string{"Test \""} + it->first
                               + "\" leaked " + std::to_string(size) + " values");
    }
    std::cout << std::endl << passing << " out of "
              << num_tests << " tests finished successfully." << std::endl;
    std::cout << std::endl;
    for_each(failures.begin(), failures.end(),
             [](std::string failure) {
                 std::cout << failure << std::endl;
             });
    return num_tests - passing;
}
开发者ID:PeterTh,项目名称:Selene,代码行数:31,代码来源:Test.cpp


示例8: ExecuteAll

// Executes all tests and returns the number of failures.
int ExecuteAll() {
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	//_CrtSetBreakAlloc(77928);

	const int num_tests = tests.size();
	std::cout << "Executing " << num_tests << " tests..." << std::endl;
	std::vector<std::string> failures;
	int passing = 0;
	for (auto it = tests.begin(); it != tests.end(); ++it) {
		sel::State state{true};
		char progress_marker = 'E';
		bool leaked = false;
		try {
			const bool result = it->second(state);
			int const leak_count = state.Size();
			leaked = leak_count != 0;
			if (result) {
				if (!leaked) {
					passing += 1;
					progress_marker = '.';
				} else {
					failures.push_back(std::string{"Test \""} + it->first
									   + "\" leaked " + std::to_string(leak_count) + " values");
					progress_marker = 'l';
				}
			} else {
				progress_marker = 'x';
				failures.push_back(std::string{"Test \""} +
								   it->first + "\" failed.");
			}
		} catch(std::exception & e) {
			progress_marker = 'e';
			failures.push_back(std::string{"Test \""} + it->first + "\" raised an exception: \"" + e.what() + "\".");
		} catch(...) {
			progress_marker = 'e';
			failures.push_back(std::string{"Test \""} + it->first + "\" raised an exception of unknown type.");
		}
		std::cout << progress_marker << std::flush;
		if (leaked) {
			std::cout << state << std::endl;
		}
	}
	std::cout << std::endl << passing << " out of "
			  << num_tests << " tests finished successfully." << std::endl;
	std::cout << std::endl;
	for_each(failures.begin(), failures.end(),
			 [](std::string failure) {
				 std::cout << failure << std::endl;
			 });
	return num_tests - passing;
}
开发者ID:rcrmn,项目名称:Selene,代码行数:52,代码来源:Test.cpp


示例9: ExecuteTest

// Not used in general runs. For debugging purposes
bool ExecuteTest(const char *test) {
    sel::State state{true};
    auto it = tests.find(test);
    const bool result = it->second(state);
    const std::string pretty_result = result ? "pass!" : "fail.";
    std::cout << "Ran test " << test << " with result: "
              << pretty_result << std::endl;
    return result;
}
开发者ID:xchrdw,项目名称:Selene,代码行数:10,代码来源:Test.cpp


示例10: ExecuteTest

// Not used in general runs. For debugging purposes
bool ExecuteTest(const char *test) {
    sel::State state{true};
    auto it = tests.find(test);
    return it->second(state);
}
开发者ID:PeterTh,项目名称:Selene,代码行数:6,代码来源:Test.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TestNode类代码示例发布时间:2022-05-31
下一篇:
C++ TestList类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap