|
|
|
@ -5,62 +5,65 @@ |
|
|
|
|
|
|
|
|
|
|
|
using namespace fuc2; |
|
|
|
using namespace fuc2; |
|
|
|
|
|
|
|
|
|
|
|
void test_push_pop_back() { |
|
|
|
|
|
|
|
std::deque<int> ages; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
namespace sample1 { |
|
|
|
ages.push_back(i * 34); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHECK(ages.size() == 5, "wrong count"); |
|
|
|
void test_push_pop_back() { |
|
|
|
|
|
|
|
std::deque<int> ages; |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
ages.pop_back(); |
|
|
|
ages.push_back(i * 34); |
|
|
|
fmt::println("count: {}", ages.size()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EQUAL(ages.size(), size_t(0), "wrong count"); |
|
|
|
CHECK(ages.size() == 5, "wrong count"); |
|
|
|
NOT_EQUAL(ages.size(), size_t(5), "wrong count"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_push_pop_front() { |
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
std::deque<float> ages; |
|
|
|
ages.pop_back(); |
|
|
|
|
|
|
|
fmt::println("count: {}", ages.size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
EQUAL(ages.size(), size_t(0), "wrong count"); |
|
|
|
ages.push_front(i * 34); |
|
|
|
NOT_EQUAL(ages.size(), size_t(5), "wrong count"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CHECK(ages.size() == 5, "wrong count"); |
|
|
|
void test_push_pop_front() { |
|
|
|
|
|
|
|
std::deque<float> ages; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
|
|
|
|
ages.push_front(i * 34); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHECK(ages.size() == 5, "wrong count"); |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
for(int i = 0; i < 5; i++) { |
|
|
|
ages.pop_front(); |
|
|
|
ages.pop_front(); |
|
|
|
fmt::println("count: {}", ages.size()); |
|
|
|
fmt::println("count: {}", ages.size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EQUAL(ages.size(), size_t(0), "wrong count"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NOT_EQUAL(ages.size(), size_t(0), "wrong count"); |
|
|
|
void test_push_blows_up() { |
|
|
|
} |
|
|
|
std::deque<float> ages; |
|
|
|
|
|
|
|
|
|
|
|
void test_push_blows_up() { |
|
|
|
auto runner = [&]() { |
|
|
|
std::deque<float> ages; |
|
|
|
// uncomment this to see how the C++ stdlib sabotages you
|
|
|
|
|
|
|
|
// ages.pop_front();
|
|
|
|
|
|
|
|
|
|
|
|
auto runner = [&]() { |
|
|
|
ages.at(10); |
|
|
|
// uncomment this to see how the C++ stdlib sabotages you
|
|
|
|
}; |
|
|
|
// ages.pop_front();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ages.at(10); |
|
|
|
BLOWS_UP(runner, "pop_front empty should crash"); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BLOWS_UP(runner, "pop_front empty should crash"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
|
fuc2::Set TESTS{ |
|
|
|
return run({ |
|
|
|
|
|
|
|
.name="std::deque basic operations", |
|
|
|
.name="std::deque basic operations", |
|
|
|
.options={ .fail_fast=false }, |
|
|
|
.options={ .fail_fast=false }, |
|
|
|
.tests={ |
|
|
|
.tests={ |
|
|
|
{"push_pop_back", test_push_pop_back}, |
|
|
|
{"push_pop_back", test_push_pop_back}, |
|
|
|
{"push_pop_front", test_push_pop_front}, |
|
|
|
{"push_pop_front", test_push_pop_front}, |
|
|
|
{"push_blows_up", test_push_blows_up}, |
|
|
|
{"push_blows_up", test_push_blows_up}, |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|