Commit 08fb44cc authored by Anton Bukov's avatar Anton Bukov

Add SelectMany tests

parent d110077e
...@@ -42,6 +42,7 @@ SET ( ...@@ -42,6 +42,7 @@ SET (
${PROJECT_SOURCE_DIR}/test/PrependTest.cpp ${PROJECT_SOURCE_DIR}/test/PrependTest.cpp
${PROJECT_SOURCE_DIR}/test/ReverseTest.cpp ${PROJECT_SOURCE_DIR}/test/ReverseTest.cpp
${PROJECT_SOURCE_DIR}/test/SelectTest.cpp ${PROJECT_SOURCE_DIR}/test/SelectTest.cpp
${PROJECT_SOURCE_DIR}/test/SelectManyTest.cpp
${PROJECT_SOURCE_DIR}/test/SkipTest.cpp ${PROJECT_SOURCE_DIR}/test/SkipTest.cpp
${PROJECT_SOURCE_DIR}/test/SkipWhileTest.cpp ${PROJECT_SOURCE_DIR}/test/SkipWhileTest.cpp
${PROJECT_SOURCE_DIR}/test/SumTest.cpp ${PROJECT_SOURCE_DIR}/test/SumTest.cpp
......
#include <vector>
#include <string>
#include <gtest/gtest.h>
#include "CommonTests.h"
#include "boolinq.h"
using namespace boolinq;
TEST(SelectMany, AxA)
{
int src[] = {1,2,3};
int ans[] = {1,2,2,3,3,3};
auto rng = from(src);
auto dst = rng.selectMany([](int a){return repeat(a, a);});
CheckRangeEqArray(dst, ans);
}
TEST(SelectMany, OneTwoThree)
{
int src[] = {1,2,3};
int ans[] = {1,2,3,2,4,6,3,6,9};
auto rng = from(src);
auto dst = rng.selectMany([&src](int a){
return from(src).select([a](int v){return a*v;});
});
CheckRangeEqArray(dst, ans);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment