blob: 66c58a0ebccf0ebf886ec0a31704b722fb83a017 (
plain) (
blame)
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
|
#include "routing.h"
#include <functional>
#include "utility.h"
using namespace flask;
using namespace flask::black_magic;
template <int N> struct ThrowTest{};
int main()
{
try
{
throw ThrowTest<is_int("1<int>22",0)>();
}
catch(ThrowTest<0>)
{
}
try
{
throw ThrowTest<is_int("1<int>22",1)>();
}
catch(ThrowTest<1>)
{
}
{
constexpr Router r = Router("/");
static_assert(r.validate<void()>(), "Good handler");
static_assert(!r.validate<void(int)>(), "Bad handler - no int argument");
}
{
constexpr Router r = Router("/blog/<int>");
static_assert(!r.validate<void()>(), "Bad handler - need argument");
static_assert(r.validate<void(int)>(), "Good handler");
static_assert(!r.validate<void(std::string)>(), "Bad handler - int is not convertible to std::string");
static_assert(r.validate<void(double)>(), "Acceptable handler - int will be converted to double");
}
}
|