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


C++ Row::fieldCount方法代码示例

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


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

示例1: testRow

void DataTest::testRow()
{
	Row row;
	row.append("field0", 0);
	row.append("field1", 1);
	row.append("field2", 2);
	row.append("field3", 3);
	row.append("field4", 4);

	assert (row["field0"] == 0);
	assert (row["field1"] == 1);
	assert (row["field2"] == 2);
	assert (row["field3"] == 3);
	assert (row["field4"] == 4);

	assert (row[0] == 0);
	assert (row[1] == 1);
	assert (row[2] == 2);
	assert (row[3] == 3);
	assert (row[4] == 4);

	try
	{
		int i; i = row[5]; // to silence gcc
		fail ("must fail");
	}catch (RangeException&) {}

	try
	{
		int i; i = row["a bad name"]; // to silence gcc
		fail ("must fail");
	}catch (NotFoundException&) {}

	assert (5 == row.fieldCount());
	assert (row[0] == 0);
	assert (row["field0"] == 0);
	assert (row[1] == 1);
	assert (row["field1"] == 1);
	assert (row[2] == 2);
	assert (row["field2"] == 2);
	assert (row[3] == 3);
	assert (row["field3"] == 3);
	assert (row[4] == 4);
	assert (row["field4"] == 4);

	Row row2;

	row2.append("field0", 5);
	row2.append("field1", 4);
	row2.append("field2", 3);
	row2.append("field3", 2);
	row2.append("field4", 1);

	assert (row != row2);

	Row row3;

	row3.append("field0", 0);
	row3.append("field1", 1);
	row3.append("field2", 2);
	row3.append("field3", 3);
	row3.append("field4", 4);

	assert (row3 == row);
	assert (!(row < row3 | row3 < row));

	Row row4(row3.names());
	try
	{
		row4.set("badfieldname", 0);
		fail ("must fail");
	}catch (NotFoundException&) {}

	row4.set("field0", 0);
	row4.set("field1", 1);
	row4.set("field2", 2);
	row4.set("field3", 3);
	row4.set("field4", 4);
	assert (row3 == row4);
	try
	{
		row4.set(5, 0);
		fail ("must fail");
	}catch (RangeException&) {}
	row4.set("field0", 1);
	assert (row3 != row4);
	assert (row3 < row4);
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:88,代码来源:DataTest.cpp


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