本文整理汇总了C++中Dynamic::Group方法的典型用法代码示例。如果您正苦于以下问题:C++ Dynamic::Group方法的具体用法?C++ Dynamic::Group怎么用?C++ Dynamic::Group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamic
的用法示例。
在下文中一共展示了Dynamic::Group方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintTable
/*
#define MY_TRACE_
void PrintTable(const Dynamic & table)
{
#if !defined(MY_TRACE_)
(void)table;
#else
size_t shift_size = 0;
StringVector cols = table.GetColumnNames();
StringVector::const_iterator beg = cols.begin();
for (; beg != cols.end(); ++beg)
{
if (beg->size() > shift_size)
shift_size = beg->size();
}
std::string shift;
beg = cols.begin();
for (; beg != cols.end(); ++beg)
{
std::cout << shift << " | " << *beg;
shift = std::string(shift_size, ' ');
}
std::cout << std::endl;
std::string shift_;
const size_t h_size = table.height(), w_size = table.width();
for (size_t row = 0; row < h_size; ++row)
{
for (size_t col = 0; col < w_size; ++col)
{
//if (col > 0)
// shift_ = std::string(shift_size, ' '); //shift_ = shift.size();
print(std::cout, table.GetCellValue(row, col), shift_ + " | ", false);
}
std::cout << std::endl;
}
#endif // MY_TRACE_
}
*/
void GroupCases()
{
std::string error;
Dynamic table = TABLE;
_COMMON_TABLE_INIT(table);
_COMMON_TABLE_INIT_(table);
_COMMON_TABLE_INIT_2(table);
/*
Error cases
*/
{
std::string error;
Dynamic group_table(table.Group("",
"COUNT, SUM(name4)", &error));
NKIT_TEST_ASSERT(!error.empty());
}
// --------------------
{
std::string error;
Dynamic group_table(table.Group("name,name1",
"", &error));
NKIT_TEST_ASSERT(!error.empty());
}
// --------------------
{
std::string error;
Dynamic group_table(table.Group("name,name1,__NOT_EXISTS__",
"COUNT, SUM(name4)", &error));
NKIT_TEST_ASSERT(!error.empty());
}
// --------------------
{
std::string error;
Dynamic group_table(table.Group("name,name1,name3",
"COUNT, SUM(name4),__WRONG_AGGREGATOR__(name3)", &error));
NKIT_TEST_ASSERT(!error.empty());
}
// --------------------
{
std::string error;
Dynamic group_table(table.Group("name,name1,name3",
"COUNT, MAX(name)", &error)); // string -> MAX
NKIT_TEST_ASSERT(!error.empty());
}
/*
Good cases
*/
{
std::string error;
//CINFO(table);
Dynamic group_table(table.Group("name3",
"COUNT, SUM(name4)", &error));
NKIT_TEST_ASSERT_WITH_TEXT(error.empty(), error);
//CINFO(group_table);
}
{
std::string error;
//.........这里部分代码省略.........