Mercurial > code
view 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 |
line wrap: on
line source
/* * test-join.cpp -- test join function * * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define BOOST_TEST_MODULE "Join" #include <boost/test/unit_test.hpp> #include "join.hpp" BOOST_AUTO_TEST_CASE(empty) { std::string expected = ""; std::string result = join<int>({}); BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(one) { std::string expected = "1"; std::string result = join({1}); BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(two) { std::string expected = "1:2"; std::string result = join({1, 2}); BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(delimiterString) { std::string expected = "1;;2;;3"; std::string result = join({1, 2, 3}, ";;"); BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(delimiterChar) { std::string expected = "1@2@3@4"; std::string result = join({1, 2, 3, 4}, '@'); BOOST_REQUIRE_EQUAL(expected, result); }