Mercurial > code
comparison modules/join/test/main.cpp @ 615:e8661a550a12
Join: dedicate new module directory, #684
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 21 Aug 2017 11:31:22 +0200 |
parents | |
children | 266f32919d0a |
comparison
equal
deleted
inserted
replaced
614:687b42509012 | 615:e8661a550a12 |
---|---|
1 /* | |
2 * test-join.cpp -- test join function | |
3 * | |
4 * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #define BOOST_TEST_MODULE "Join" | |
20 #include <boost/test/unit_test.hpp> | |
21 | |
22 #include "join.hpp" | |
23 | |
24 BOOST_AUTO_TEST_CASE(empty) | |
25 { | |
26 std::string expected = ""; | |
27 std::string result = join<int>({}); | |
28 | |
29 BOOST_REQUIRE_EQUAL(expected, result); | |
30 } | |
31 | |
32 BOOST_AUTO_TEST_CASE(one) | |
33 { | |
34 std::string expected = "1"; | |
35 std::string result = join({1}); | |
36 | |
37 BOOST_REQUIRE_EQUAL(expected, result); | |
38 } | |
39 | |
40 BOOST_AUTO_TEST_CASE(two) | |
41 { | |
42 std::string expected = "1:2"; | |
43 std::string result = join({1, 2}); | |
44 | |
45 BOOST_REQUIRE_EQUAL(expected, result); | |
46 } | |
47 | |
48 BOOST_AUTO_TEST_CASE(delimiterString) | |
49 { | |
50 std::string expected = "1;;2;;3"; | |
51 std::string result = join({1, 2, 3}, ";;"); | |
52 | |
53 BOOST_REQUIRE_EQUAL(expected, result); | |
54 } | |
55 | |
56 BOOST_AUTO_TEST_CASE(delimiterChar) | |
57 { | |
58 std::string expected = "1@2@3@4"; | |
59 std::string result = join({1, 2, 3, 4}, '@'); | |
60 | |
61 BOOST_REQUIRE_EQUAL(expected, result); | |
62 } |