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


C++ Tstring::at方法代码示例

本文整理汇总了C++中Tstring::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Tstring::at方法的具体用法?C++ Tstring::at怎么用?C++ Tstring::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tstring的用法示例。


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

示例1: if

Tstring & TestMeanSql::gen_value(GenCtx & pCtx, Tstring & pResult)
{
	size_t i;
	Tstring lV;
	std::ostringstream lOs;
	// Either generate a good value...
	if (pCtx.doGood())
	{
		int const lType = MVTRand::getRange(0, 15);
		switch (lType)
		{
			// Note: We don't generate collections here, because it's not (yet) a recursive structure, and here we're supposed to be 'good'.
			case 0: default: MVTRand::getString(lV, 5, 15, true, true); lOs << "'" << lV << "'"; break;
			case 1: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()); if (MVTRand::getBool()) lOs << "U"; break;
			case 2: lOs << MVTRand::getFloatRange(0.0, std::numeric_limits<float>::max()) << "f"; break;
			case 3: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()); break;
			case 4: lOs << (MVTRand::getBool() ? "TRUE" : "FALSE"); break;
			case 5: MVTRand::getString(lV, 5, 15, true, true); lOs << "U'http://" << lV << "'"; break;
			case 6: MVTRand::getString(lV, 5, 15, true, true); lOs << "X'"; for (i = 0; i < lV.length(); i++) { lOs << std::hex << std::setw(2) << std::setfill('0') << (int)lV.at(i); } lOs << std::dec << "'"; break;
			case 7: lOs << "INTERVAL'" << MVTRand::getRange(0, std::numeric_limits<int>::max()) << ":" << std::setw(2) << std::setfill('0') << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59) << ".12345'"; break;
			case 8: lOs << "TIMESTAMP'" << std::setw(4) << std::setfill('0') << MVTRand::getRange(0, 2200) << "-" << std::setw(2) << MVTRand::getRange(1, 12) << "-" << MVTRand::getRange(1, 31) << " " << MVTRand::getRange(0, 23) << ":" << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59); break;
			case 9: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << std::dec; break;
			case 10: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec; break;
			case 11: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec << "["; if (MVTRand::getBool()) lOs << ":FIRST"; else lOs << MVTRand::getRange(0, 100); lOs << "]"; break;
			case 12: lOs << gen_SELECT(pCtx, lV); break; // Not necessarily 'good' currently, but who cares...
			case 13: lOs << "${" << gen_SELECT(pCtx, lV) << "}"; break;
		}
	}
	// Or generate a bad value...
	else
	{
		int const lType = MVTRand::getRange(0, 18);
		switch (lType)
		{
			// Note: We do generate collections here, because here all is permitted :).
			case 0: default:
				#if TEST_ISSUE_DOUBLE_QUOTED_VAL
					MVTRand::getString(lV, 5, 15, true, true); lOs << "\"" << lV << "\""; break;
				#endif
			case 1: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()) << "bla"; break;
			case 2: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()) << MVTRand::getRange(0, std::numeric_limits<int>::max()) << MVTRand::getRange(0, std::numeric_limits<int>::max()); break;
			case 3: lOs << MVTRand::getFloatRange(0.0, std::numeric_limits<float>::max()) << "fbla"; break;
			case 4: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()) << "bla"; break;
			case 5: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()) << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()); break;
			case 6: lOs << randomKeyword(); break;
			case 7: lOs << gen_collection(pCtx, lV); break;
			case 8: lOs << "MAYBE"; break;
			case 9: MVTRand::getString(lV, 5, 15, true, true); lOs << "U'http://" << lV << (pCtx.doGood() ? "'" : ""); break;
			case 10: MVTRand::getString(lV, 5, 15, true, true); lOs << "X'"; for (i = 0; i < lV.length(); i++) { lOs << std::hex << (int)lV.at(i); } lOs << std::dec << (pCtx.doGood() ? "'" : ""); break;
			case 11: lOs << "INTERVAL'"; if (pCtx.doGood()) lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()); else lOs << MVTRand::getString(lV, 5, 15, false, true); lOs << ":" << MVTRand::getRange(0, pCtx.doGood() ? 59 : 1000) << (pCtx.doGood() ? ":" : ";") << MVTRand::getRange(0, pCtx.doGood() ? 59 : 1000) << ".12345'"; break;
			case 12: lOs << "TIMESTAMP'" << MVTRand::getRange(0, 10000) << "-" << MVTRand::getRange(1, pCtx.doGood() ? 12 : 1000) << "-" << MVTRand::getRange(1, pCtx.doGood() ? 31 : 1000) << " " << MVTRand::getRange(0, pCtx.doGood() ? 23 : 1000) << ":" << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59); break;
			case 13: lOs << "@"; if (pCtx.doGood()) lOs << std::hex << MVTRand::getRange(0x50001, 0x500001) << std::dec; else lOs << MVTRand::getString(lV, 5, 15, false, true); break;
			case 14: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << (pCtx.doGood() ? randomProperty() : randomWord()) << std::dec; break;
			case 15: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec << "["; if (pCtx.doGood()) lOs << MVTRand::getRange(0, 100); else lOs << randomWord(); lOs << "]"; break;
			case 16: lOs << "${" << gen_whatever(pCtx, lV) << "}"; break;
		}
	}
	return pResult = lOs.str();
}
开发者ID:affinitydb,项目名称:tests_kernel,代码行数:59,代码来源:testmeansql.cpp


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