Mercurial > code
view misc/test-join.cpp @ 593:c767f1202e8e
Ini: move to bitbucket
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 05 Sep 2016 22:00:23 +0200 |
parents | dcef88285f8c |
children |
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. */ #include "join.hpp" TEST(Join, empty) { std::string expected = ""; std::string result = join<int>({}); ASSERT_EQ(expected, result); } TEST(Join, one) { std::string expected = "1"; std::string result = join({1}); ASSERT_EQ(expected, result); } TEST(Join, two) { std::string expected = "1:2"; std::string result = join({1, 2}); ASSERT_EQ(expected, result); } TEST(Join, delimiterString) { std::string expected = "1;;2;;3"; std::string result = join({1, 2, 3}, ";;"); ASSERT_EQ(expected, result); } TEST(Join, delimiterChar) { std::string expected = "1@2@3@4"; std::string result = join({1, 2, 3, 4}, '@'); ASSERT_EQ(expected, result); }