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

34 lines
864 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::pair;
TEST(getPairs, emptyCollection) {
EXPECT_THAT(getPairs(vector<int>()), IsEmpty());
}
TEST(getPairs, oneElementCollection) {
EXPECT_THAT(getPairs(vector<int>{1}), IsEmpty());
}
TEST(getPairs, validCollection) {
{
const auto actual = getPairs(vector<int> { 1, 2 });
const vector<pair<int, int>> expected { { 1, 2 } };
2016-05-12 19:21:25 +00:00
EXPECT_THAT(actual, ElementsAreArray(expected));
}
{
const auto actual = getPairs(vector<int> { 1, 2, 3 });
const vector<pair<int, int>> expected { { 1, 2 }, { 2, 3 } };
2016-05-12 19:21:25 +00:00
EXPECT_THAT(actual, ElementsAreArray(expected));
}
{
const auto actual = getPairs(vector<int> { 1, 2, 3, 4 });
const vector<pair<int, int>> expected { { 1, 2 }, { 2, 3 }, { 3, 4 } };
2016-05-12 19:21:25 +00:00
EXPECT_THAT(actual, ElementsAreArray(expected));
}
}