-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
90 lines (76 loc) · 2.17 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include "prettyprint.hpp"
#define block(...) \
{ \
__VA_ARGS__; \
std::cout << std::endl << "------------" << std::endl; \
}
template<typename Type>
std::vector<Type>& operator<<(std::vector<Type>& vec, Type&& val)
{
vec.push_back(val);
return vec;
}
void test(int argc, char** argv)
{
using namespace pretty::streamops;
block({
std::vector<std::string> args(argv + 0, argv + argc);
std::cout << args << std::endl;
});
block({
std::vector<char> vec;
vec << 'h' << 'e' << 'l' << 'o' << ' ' << 'w' << 'o' << 'r' << 'l' << 'd' << '!';
std::cout << vec << std::endl;
});
block({
std::vector<wchar_t> vec;
vec << L'g' << L'o' << L'd' << L'b' << L'y' << L'e' << L'w' << L'o' << L'r' << L'l' << L'd';
std::cout << vec << std::endl;
});
block({
std::cout << pretty::to_string("hello world!") << std::endl;
std::cout << pretty::to_string(L"goodbye world!") << std::endl;
});
block({
struct Foo
{
int a;
int b;
int c;
};
std::map<std::string, Foo> stuff;
stuff["blorp"] = Foo{42, 7, 3};
stuff["dengs"] = Foo{53, 94, 20};
stuff["wolpo"] = Foo{94, 29, 20};
std::cout << stuff << std::endl;
});
block({
std::map<std::string, std::vector<std::map<float, std::string>>> st;
auto mk = [](int howmany, float fval, const std::string& str)
{
int i;
std::map<float, std::string> map;
std::vector<std::map<float, std::string>> vec;
for(i=0; i<howmany; i++)
{
map[fval * i] = str;
}
vec.push_back(map);
return vec;
};
st["funk"] = mk(3, 4.881, "shpork");
st["pork"] = mk(7, 9.001, "giraffes");
st["huli"] = mk(2, 6.032, "matey");
std::cout << st << std::endl;
});
block({
std::function<bool(std::array<long long, 666>)> whatever;
std::cout << whatever << std::endl;
});
}
int main(int argc, char* argv[])
{
test(argc, argv);
return 0;
}