This documentation is automatically generated by competitive-verifier/competitive-verifier
// competitive-verifier: STANDALONE
#include <cstdlib>
#include <iostream>
#include <vector>
#include <array>
#include "tools/assert_that.hpp"
#include "tools/resize.hpp"
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 3, 4, 0);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 0);
}
}
}
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 0, 4, 5);
assert_that(v.size() == 0);
}
{
std::vector<int> v;
tools::resize(v, 3);
assert_that(v.size() == 3);
}
{
std::vector<int> v;
tools::resize(v, 0);
assert_that(v.size() == 0);
}
{
std::array<std::vector<std::vector<int>>, 3> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::array<std::vector<int>, 4>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::vector<std::array<int, 5>>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::array<std::array<std::array<int, 5>, 4>, 3> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::array<int, 3> v;
tools::resize(v, 3);
assert_that(v.size() == 3);
}
return 0;
}
#line 1 "tests/resize.test.cpp"
// competitive-verifier: STANDALONE
#include <cstdlib>
#include <iostream>
#include <vector>
#include <array>
#line 1 "tools/assert_that.hpp"
#line 6 "tools/assert_that.hpp"
#define assert_that_impl(cond, file, line, func) do {\
if (!cond) {\
::std::cerr << file << ':' << line << ": " << func << ": Assertion `" << #cond << "' failed." << '\n';\
::std::exit(EXIT_FAILURE);\
}\
} while (false)
#define assert_that(...) assert_that_impl((__VA_ARGS__), __FILE__, __LINE__, __func__)
#line 1 "tools/resize.hpp"
#line 5 "tools/resize.hpp"
#include <cstddef>
#line 7 "tools/resize.hpp"
#include <cassert>
namespace tools {
template <class T, class Allocator, typename Head>
void resize(::std::vector<T, Allocator>& vector, const Head& head) {
vector.resize(head);
}
template <class T, ::std::size_t N, typename Head>
void resize([[maybe_unused]] ::std::array<T, N>& array, [[maybe_unused]] const Head& head) {
assert(array.size() == static_cast<::std::size_t>(head));
}
template <class T, class Allocator, typename Head, typename... Tail>
void resize(::std::vector<T, Allocator>& vector, const Head& head, const Tail&... tail);
template <class T, ::std::size_t N, typename Head, typename... Tail>
void resize(::std::array<T, N>& array, const Head& head, const Tail&... tail);
template <class T, class Allocator, typename Head, typename... Tail>
void resize(::std::vector<T, Allocator>& vector, const Head& head, const Tail&... tail) {
vector.resize(head);
for (auto& child : vector) {
::tools::resize(child, tail...);
}
}
template <class T, ::std::size_t N, typename Head, typename... Tail>
void resize(::std::array<T, N>& array, [[maybe_unused]] const Head& head, const Tail&... tail) {
assert(array.size() == static_cast<::std::size_t>(head));
for (auto& child : array) {
::tools::resize(child, tail...);
}
}
}
#line 9 "tests/resize.test.cpp"
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 3, 4, 0);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 0);
}
}
}
{
std::vector<std::vector<std::vector<int>>> v;
tools::resize(v, 0, 4, 5);
assert_that(v.size() == 0);
}
{
std::vector<int> v;
tools::resize(v, 3);
assert_that(v.size() == 3);
}
{
std::vector<int> v;
tools::resize(v, 0);
assert_that(v.size() == 0);
}
{
std::array<std::vector<std::vector<int>>, 3> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::array<std::vector<int>, 4>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::vector<std::vector<std::array<int, 5>>> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::array<std::array<std::array<int, 5>, 4>, 3> v;
tools::resize(v, 3, 4, 5);
assert_that(v.size() == 3);
for (int i = 0; i < 3; ++i) {
assert_that(v[i].size() == 4);
for (int j = 0; j < 4; ++j) {
assert_that(v[i][j].size() == 5);
}
}
}
{
std::array<int, 3> v;
tools::resize(v, 3);
assert_that(v.size() == 3);
}
return 0;
}