Skip to content

Commit

Permalink
Refined unit test for select_many
Browse files Browse the repository at this point in the history
  • Loading branch information
mrange committed Sep 23, 2012
1 parent 82a74ba commit bd77456
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions Test/CppLinq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ namespace
{
std::wstring concatenate_result =
from (empty)
>> select ([](int i){return std::wstring();})
>> select ([] (int i){return std::wstring ();})
>> concatenate (L"")
;
TEST_ASSERT (true, concatenate_result.empty ());
Expand Down Expand Up @@ -615,14 +615,42 @@ namespace
TEST_PRELUDE ();

{
// TODO: why do I need to use from_copy
auto select_many_result =
from_iterators (customers, customers)
>> select_many ([](customer const & c){return from_copy (c.last_name);})
>> to_vector ()
;

TEST_ASSERT (0, (int)select_many_result.size ());
}
{
std::vector<char> expected;
for (auto customer : customers)
{
expected.insert (
expected.end ()
, customer.last_name.begin ()
, customer.last_name.end ()
);
}

// TODO: figure out why I need to use from_copy
auto select_many_result =
from_array (customers)
>> select_many ([](customer const & c){return from_copy (c.last_name);})
>> to_vector ()
;

TEST_ASSERT (41, (int)select_many_result.size ());
if (TEST_ASSERT ((int)expected.size (), (int)select_many_result.size ()))
{
for (auto iter = 0U; iter < expected.size (); ++iter)
{
if (!TEST_ASSERT (expected[iter], select_many_result[iter]))
{
printf (" @index:%d\r\n", iter);
}
}
}
}

}
Expand Down

0 comments on commit bd77456

Please sign in to comment.