view misc/test-join.cpp @ 614:687b42509012

Misc: remove strip, there is alternative in boost
author David Demelier <markand@malikania.fr>
date Mon, 21 Aug 2017 11:14:05 +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);
}