ClickHouse/base/common/tests/dump_variable.cpp

71 lines
1.1 KiB
C++
Raw Normal View History

#include <common/iostream_debug_helpers.h>
2018-04-06 04:46:18 +00:00
#include <iostream>
#include <memory>
#include <vector>
#include <map>
#include <set>
2018-04-06 04:46:18 +00:00
#include <tuple>
#include <array>
#include <utility>
struct S1;
struct S2 {};
struct S3
{
std::set<const char *> m1;
};
std::ostream & operator<<(std::ostream & stream, const S3 & what)
{
stream << "S3 {m1=";
dumpValue(stream, what.m1) << "}";
return stream;
}
2018-04-06 04:46:18 +00:00
int main(int, char **)
{
int x = 1;
DUMP(x);
DUMP(x, 1, &x);
DUMP(std::make_unique<int>(1));
DUMP(std::make_shared<int>(1));
std::vector<int> vec{1, 2, 3};
DUMP(vec);
auto pair = std::make_pair(1, 2);
DUMP(pair);
auto tuple = std::make_tuple(1, 2, 3);
DUMP(tuple);
std::map<int, std::string> map{{1, "hello"}, {2, "world"}};
DUMP(map);
std::initializer_list<const char *> list{"hello", "world"};
DUMP(list);
std::array<const char *, 2> arr{{"hello", "world"}};
2018-04-06 04:46:18 +00:00
DUMP(arr);
2018-04-06 04:48:48 +00:00
//DUMP([]{});
2018-04-06 04:46:18 +00:00
S1 * s = nullptr;
DUMP(s);
DUMP(S2());
std::set<const char *> variants = {"hello", "world"};
DUMP(variants);
S3 s3 {{"hello", "world"}};
DUMP(s3);
2018-04-06 04:46:18 +00:00
return 0;
}