2016-05-12 19:21:25 +00:00
|
|
|
#include <gmock/gmock.h>
|
2017-09-10 20:17:17 +00:00
|
|
|
#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) {
|
|
|
|
{
|
2019-01-02 19:00:34 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
{
|
2019-01-02 19:00:34 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
{
|
2019-01-02 19:00:34 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|