Added timeline constructor overloads

This commit is contained in:
Daniel Wolf 2016-12-01 20:23:41 +01:00
parent 6d67f77f62
commit 1e5a21dbfb
6 changed files with 28 additions and 1 deletions

View File

@ -29,6 +29,11 @@ public:
} }
} }
template<typename collection_type>
BoundedTimeline(TimeRange range, collection_type collection) :
BoundedTimeline(range, collection.begin(), collection.end())
{}
BoundedTimeline(TimeRange range, std::initializer_list<Timed<T>> initializerList) : BoundedTimeline(TimeRange range, std::initializer_list<Timed<T>> initializerList) :
BoundedTimeline(range, initializerList.begin(), initializerList.end()) BoundedTimeline(range, initializerList.begin(), initializerList.end())
{} {}

View File

@ -24,6 +24,11 @@ public:
} }
} }
template<typename collection_type>
ContinuousTimeline(TimeRange range, T defaultValue, collection_type collection) :
ContinuousTimeline(range, defaultValue, collection.begin(), collection.end())
{}
ContinuousTimeline(TimeRange range, T defaultValue, std::initializer_list<Timed<T>> initializerList) : ContinuousTimeline(TimeRange range, T defaultValue, std::initializer_list<Timed<T>> initializerList) :
ContinuousTimeline(range, defaultValue, initializerList.begin(), initializerList.end()) ContinuousTimeline(range, defaultValue, initializerList.begin(), initializerList.end())
{} {}

View File

@ -98,6 +98,11 @@ public:
} }
} }
template<typename collection_type>
explicit Timeline(collection_type collection) :
Timeline(collection.begin(), collection.end())
{}
explicit Timeline(std::initializer_list<Timed<T>> initializerList) : explicit Timeline(std::initializer_list<Timed<T>> initializerList) :
Timeline(initializerList.begin(), initializerList.end()) Timeline(initializerList.begin(), initializerList.end())
{} {}

View File

@ -22,6 +22,10 @@ TEST(BoundedTimeline, constructors_initializeState) {
BoundedTimeline<int>(range, args.begin(), args.end()), BoundedTimeline<int>(range, args.begin(), args.end()),
ElementsAreArray(expected) ElementsAreArray(expected)
); );
EXPECT_THAT(
BoundedTimeline<int>(range, vector<Timed<int>>(args)),
ElementsAreArray(expected)
);
EXPECT_THAT( EXPECT_THAT(
BoundedTimeline<int>(range, args), BoundedTimeline<int>(range, args),
ElementsAreArray(expected) ElementsAreArray(expected)

View File

@ -24,6 +24,10 @@ TEST(ContinuousTimeline, constructors_initializeState) {
ContinuousTimeline<int>(range, defaultValue, args.begin(), args.end()), ContinuousTimeline<int>(range, defaultValue, args.begin(), args.end()),
ElementsAreArray(expected) ElementsAreArray(expected)
); );
EXPECT_THAT(
ContinuousTimeline<int>(range, defaultValue, vector<Timed<int>>(args)),
ElementsAreArray(expected)
);
EXPECT_THAT( EXPECT_THAT(
ContinuousTimeline<int>(range, defaultValue, args), ContinuousTimeline<int>(range, defaultValue, args),
ElementsAreArray(expected) ElementsAreArray(expected)

View File

@ -24,6 +24,10 @@ TEST(Timeline, constructors_initializeState) {
Timeline<int>(args.begin(), args.end()), Timeline<int>(args.begin(), args.end()),
ElementsAreArray(expected) ElementsAreArray(expected)
); );
EXPECT_THAT(
Timeline<int>(vector<Timed<int>>(args)),
ElementsAreArray(expected)
);
EXPECT_THAT( EXPECT_THAT(
Timeline<int>(args), Timeline<int>(args),
ElementsAreArray(expected) ElementsAreArray(expected)