2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/PODArray.h>
|
|
|
|
#include <Core/Types.h>
|
2016-07-07 16:45:27 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
#define ASSERT_CHECK(cond, res) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (!(cond)) \
|
|
|
|
{ \
|
|
|
|
std::cerr << __FILE__ << ":" << __LINE__ << ":" \
|
|
|
|
<< "Assertion " << #cond << " failed.\n"; \
|
|
|
|
if ((res)) { (res) = false; } \
|
|
|
|
} \
|
2016-07-07 16:45:27 +00:00
|
|
|
} \
|
2020-03-08 21:29:00 +00:00
|
|
|
while (false)
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2019-12-15 06:34:43 +00:00
|
|
|
static void test1()
|
2016-07-07 16:45:27 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
using namespace DB;
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
static constexpr size_t initial_size = 8;
|
|
|
|
static constexpr size_t stack_threshold = 32;
|
|
|
|
using Array = PODArray<UInt64, initial_size, AllocatorWithStackMemory<Allocator<false>, stack_threshold>>;
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool res = true;
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
|
|
|
Array arr2;
|
|
|
|
arr2 = std::move(arr);
|
|
|
|
}
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2 = std::move(arr);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr = std::move(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
|
|
|
arr.push_back(4);
|
|
|
|
arr.push_back(5);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2 = std::move(arr);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 5), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr = std::move(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 5), res);
|
|
|
|
}
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
|
|
|
arr2.push_back(6);
|
|
|
|
arr2.push_back(7);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2 = std::move(arr);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
|
|
|
arr2.push_back(6);
|
|
|
|
arr2.push_back(7);
|
|
|
|
arr2.push_back(8);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr = std::move(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 5), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 6), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 7), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 8), res);
|
|
|
|
}
|
2016-07-07 16:45:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
if (!res)
|
|
|
|
std::cerr << "Some errors were found in test 1\n";
|
2016-07-07 22:49:38 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 06:34:43 +00:00
|
|
|
static void test2()
|
2016-07-07 22:49:38 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
using namespace DB;
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
static constexpr size_t initial_size = 8;
|
|
|
|
static constexpr size_t stack_threshold = 32;
|
|
|
|
using Array = PODArray<UInt64, initial_size, AllocatorWithStackMemory<Allocator<false>, stack_threshold>>;
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool res = true;
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
|
|
|
Array arr2;
|
|
|
|
arr.swap(arr2);
|
|
|
|
arr2.swap(arr);
|
|
|
|
}
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(1);
|
|
|
|
arr2.push_back(2);
|
|
|
|
arr2.push_back(3);
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-08 21:40:00 +00:00
|
|
|
ASSERT_CHECK((arr2.empty()), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-08 21:40:00 +00:00
|
|
|
ASSERT_CHECK((arr.empty()), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(1);
|
|
|
|
arr2.push_back(2);
|
|
|
|
arr2.push_back(3);
|
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 5), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-08 21:40:00 +00:00
|
|
|
ASSERT_CHECK((arr2.empty()), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-08 21:40:00 +00:00
|
|
|
ASSERT_CHECK((arr.empty()), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 5), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
|
|
|
arr2.push_back(6);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 5), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 6), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 6), res);
|
|
|
|
}
|
2016-07-07 22:49:38 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr2.push_back(3);
|
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.swap(arr2);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 3), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 5), res);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
|
|
|
|
arr.swap(arr2);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr.size() == 2), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 5), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Array arr;
|
|
|
|
|
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
|
|
|
|
|
|
|
Array arr2;
|
|
|
|
|
|
|
|
arr2.push_back(4);
|
|
|
|
arr2.push_back(5);
|
|
|
|
arr2.push_back(6);
|
|
|
|
arr2.push_back(7);
|
|
|
|
arr2.push_back(8);
|
|
|
|
|
|
|
|
arr.swap(arr2);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 5), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 6), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 7), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 8), res);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
|
|
|
|
arr.swap(arr2);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 6), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 7), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 8), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Array arr;
|
|
|
|
|
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
|
|
|
arr.push_back(4);
|
|
|
|
arr.push_back(5);
|
|
|
|
|
|
|
|
Array arr2;
|
|
|
|
|
|
|
|
arr2.push_back(6);
|
|
|
|
arr2.push_back(7);
|
|
|
|
arr2.push_back(8);
|
|
|
|
arr2.push_back(9);
|
|
|
|
arr2.push_back(10);
|
|
|
|
|
|
|
|
arr.swap(arr2);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 6), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 7), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 8), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 9), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 10), res);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 5), res);
|
|
|
|
|
|
|
|
arr.swap(arr2);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr[4] == 5), res);
|
|
|
|
|
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 6), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 7), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 8), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 9), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 10), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
std::cerr << "Some errors were found in test 2\n";
|
2016-07-07 22:49:38 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 06:34:43 +00:00
|
|
|
static void test3()
|
2016-07-08 14:53:00 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
using namespace DB;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
static constexpr size_t initial_size = 8;
|
|
|
|
static constexpr size_t stack_threshold = 32;
|
|
|
|
using Array = PODArray<UInt64, initial_size, AllocatorWithStackMemory<Allocator<false>, stack_threshold>>;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool res = true;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
|
|
|
Array arr2{std::move(arr)};
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2{std::move(arr)};
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-18 02:02:24 +00:00
|
|
|
ASSERT_CHECK((arr.empty()), res); // NOLINT
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Array arr;
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
arr.push_back(1);
|
|
|
|
arr.push_back(2);
|
|
|
|
arr.push_back(3);
|
|
|
|
arr.push_back(4);
|
|
|
|
arr.push_back(5);
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Array arr2{std::move(arr)};
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2020-03-18 02:02:24 +00:00
|
|
|
ASSERT_CHECK((arr.empty()), res); // NOLINT
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASSERT_CHECK((arr2.size() == 5), res);
|
|
|
|
ASSERT_CHECK((arr2[0] == 1), res);
|
|
|
|
ASSERT_CHECK((arr2[1] == 2), res);
|
|
|
|
ASSERT_CHECK((arr2[2] == 3), res);
|
|
|
|
ASSERT_CHECK((arr2[3] == 4), res);
|
|
|
|
ASSERT_CHECK((arr2[4] == 5), res);
|
|
|
|
}
|
2016-07-08 14:53:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
if (!res)
|
|
|
|
std::cerr << "Some errors were found in test 3\n";
|
2016-07-08 14:53:00 +00:00
|
|
|
}
|
|
|
|
|
2016-07-07 22:49:38 +00:00
|
|
|
int main()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
std::cout << "test 1\n";
|
|
|
|
test1();
|
|
|
|
std::cout << "test 2\n";
|
|
|
|
test2();
|
|
|
|
std::cout << "test 3\n";
|
|
|
|
test3();
|
|
|
|
|
|
|
|
return 0;
|
2016-07-07 16:45:27 +00:00
|
|
|
}
|