Mercurial > malikania
annotate tests/libcommon/util/main.cpp @ 46:b0593a3e2ca8
Server: use Boost.Asio and add basic authentication support
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 04 Dec 2016 21:26:18 +0100 |
parents | f30c84b4b9ed |
children | 858621081b95 |
rev | line source |
---|---|
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
1 /* |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
2 * main.cpp -- test util |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
3 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
4 * Copyright (c) 2013-2016 Malikania Authors |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
5 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
6 * Permission to use, copy, modify, and/or distribute this software for any |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
7 * purpose with or without fee is hereby granted, provided that the above |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
8 * copyright notice and this permission notice appear in all copies. |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
9 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
17 */ |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
18 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
19 #define BOOST_TEST_MODULE "Util" |
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
20 #include <boost/test/unit_test.hpp> |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
21 |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
22 #include <malikania/util.hpp> |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
23 |
43
fabbe1759cec
Misc: switch to mlk namespace, closes #589
David Demelier <markand@malikania.fr>
parents:
33
diff
changeset
|
24 using namespace mlk; |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
25 |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
26 /* |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
27 * util::clamp |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
28 * ------------------------------------------------------------------ |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
29 */ |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
30 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
31 BOOST_AUTO_TEST_SUITE(clamp) |
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
32 |
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
33 BOOST_AUTO_TEST_CASE(normal) |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
34 { |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
35 BOOST_REQUIRE_EQUAL(5, util::clamp(5, 0, 10)); |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
36 } |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
37 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
38 BOOST_AUTO_TEST_CASE(minimum) |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
39 { |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
40 BOOST_REQUIRE_EQUAL(0, util::clamp(0, 0, 10)); |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
41 } |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
42 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
43 BOOST_AUTO_TEST_CASE(maximum) |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
44 { |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
45 BOOST_REQUIRE_EQUAL(10, util::clamp(10, 0, 10)); |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
46 } |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
47 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
48 BOOST_AUTO_TEST_CASE(less) |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
49 { |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
50 BOOST_REQUIRE_EQUAL(0, util::clamp(-10, 0, 10)); |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
51 } |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
52 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
53 BOOST_AUTO_TEST_CASE(higher) |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
54 { |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
55 BOOST_REQUIRE_EQUAL(10, util::clamp(20, 0, 10)); |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
56 } |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
57 |
44
f30c84b4b9ed
Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents:
43
diff
changeset
|
58 BOOST_AUTO_TEST_SUITE_END() |