本文整理汇总了C++中BoundedBuffer::back方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundedBuffer::back方法的具体用法?C++ BoundedBuffer::back怎么用?C++ BoundedBuffer::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundedBuffer
的用法示例。
在下文中一共展示了BoundedBuffer::back方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_buffer_back_throws_after_push_pop
void test_buffer_back_throws_after_push_pop() {
BoundedBuffer<int> buffer { 5 };
buffer.push(5);
buffer.pop();
ASSERT_THROWS(buffer.back(), std::logic_error);
}
示例2: test_buffer_back_gets_last_element_of_two_pushs
void test_buffer_back_gets_last_element_of_two_pushs() {
BoundedBuffer<int> buffer { 5 };
buffer.push(1);
buffer.push(2);
ASSERT_EQUAL(2, buffer.back());
}
示例3: test_buffer_back_gets_element_of_push
void test_buffer_back_gets_element_of_push() {
BoundedBuffer<int> buffer { 5 };
buffer.push(5);
ASSERT_EQUAL(5, buffer.back());
}
示例4: test_buffer_wrap_around_behavior_back
void test_buffer_wrap_around_behavior_back() {
BoundedBuffer<int> buffer { 3 };
std::vector<int> backValues { }, expectedValues { 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 7, 7, 7 };
buffer.push(1);
backValues.push_back(buffer.back());
buffer.push(2);
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
buffer.push(3);
backValues.push_back(buffer.back());
buffer.push(4);
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
buffer.push(5);
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
buffer.push(6);
backValues.push_back(buffer.back());
buffer.push(7);
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
buffer.pop();
backValues.push_back(buffer.back());
ASSERT_EQUAL(expectedValues, backValues);
}
示例5: test_make_bounded_buffer_from_two_rvalue_arguments_second_element_copied
void test_make_bounded_buffer_from_two_rvalue_arguments_second_element_copied() {
MemoryOperationCounter expected{0, 1, true};
MemoryOperationCounter lvalue{};
BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(MemoryOperationCounter{}, lvalue);
ASSERT_EQUAL(expected, buffer.back());
}
示例6: test_make_bounded_buffer_from_two_mixed_arguments_second_element_moved
void test_make_bounded_buffer_from_two_mixed_arguments_second_element_moved() {
MemoryOperationCounter expected{1, 0, true};
MemoryOperationCounter lvalue{};
BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(lvalue, MemoryOperationCounter{});
ASSERT_EQUAL(expected, buffer.back());
}