rhubarb-lip-sync/rhubarb/tests/pairsTests.cpp

35 lines
839 B
C++
Raw Normal View History

2016-05-12 19:21:25 +00:00
#include <gmock/gmock.h>
#include "tools/pairs.h"
2016-05-12 19:21:25 +00:00
using namespace testing;
using std::vector;
using std::initializer_list;
using std::pair;
TEST(getPairs, emptyCollection) {
EXPECT_THAT(getPairs(vector<int>()), IsEmpty());
}
TEST(getPairs, oneElementCollection) {
EXPECT_THAT(getPairs(vector<int>{1}), IsEmpty());
}
TEST(getPairs, validCollection) {
{
auto actual = getPairs(vector<int>{ 1, 2 });
vector<pair<int, int>> expected{ {1, 2} };
EXPECT_THAT(actual, ElementsAreArray(expected));
}
{
auto actual = getPairs(vector<int>{ 1, 2, 3 });
vector<pair<int, int>> expected{ {1, 2}, {2, 3} };
EXPECT_THAT(actual, ElementsAreArray(expected));
}
{
auto actual = getPairs(vector<int>{ 1, 2, 3, 4 });
vector<pair<int, int>> expected{ {1, 2}, {2, 3}, {3, 4} };
EXPECT_THAT(actual, ElementsAreArray(expected));
}
}