本文整理汇总了C++中FixedArray::capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ FixedArray::capacity方法的具体用法?C++ FixedArray::capacity怎么用?C++ FixedArray::capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FixedArray
的用法示例。
在下文中一共展示了FixedArray::capacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
TEST(Containers, ArrayBool)
{
FixedArray<20, bool> array;
FixedArray<20, bool> &cref = array;
EXPECT_TRUE(array.empty());
EXPECT_TRUE(cref.empty());
EXPECT_EQ(array.size(), 0);
EXPECT_EQ(cref.size(), 0);
EXPECT_TRUE(array.push_back(true));
EXPECT_FALSE(array.empty());
EXPECT_FALSE(cref.empty());
EXPECT_EQ(array.front(), true);
EXPECT_EQ(cref.front(), true);
EXPECT_TRUE(array.pop_back());
EXPECT_FALSE(array.pop_back());
EXPECT_TRUE(array.empty());
EXPECT_TRUE(cref.empty());
EXPECT_TRUE(array.push_back(false));
EXPECT_TRUE(array.push_back(true));
EXPECT_EQ(array.front(), false);
EXPECT_EQ(cref.front(), false);
EXPECT_EQ(array.back(), true);
EXPECT_EQ(cref.back(), true);
EXPECT_EQ(array.size(), 2);
EXPECT_EQ(cref.size(), 2);
array.clear();
EXPECT_EQ(array.size(), 0);
EXPECT_TRUE(array.empty());
for(unsigned i=0; i< array.capacity(); i++)
EXPECT_TRUE(array.push_back(i & 1));
EXPECT_FALSE(array.push_back(-1));
for(unsigned i=0; i < array.capacity(); i++)
{
EXPECT_EQ(array[i], int(i & 1));
EXPECT_EQ(cref[i], int(i & 1));
}
for(unsigned i=0; i < array.capacity(); i++)
{
EXPECT_EQ(array.back(), int(array.capacity() - 1 - i) & 1);
EXPECT_EQ(cref.back(), int(cref.capacity() - 1 - i) & 1);
EXPECT_TRUE(array.pop_back());
}
}