2010-01-03 00:02:53 +01:00
|
|
|
|
/*
|
|
|
|
|
|
IterableClassification(Test) - detecting iterability of a generic type
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2010, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file iterable-classification-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref IterableClassification_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
|
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/mobject/session/scope-query.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/effect.hpp"
|
2010-01-03 00:02:53 +01:00
|
|
|
|
#include "lib/meta/duck-detector.hpp"
|
2011-05-16 08:38:27 +02:00
|
|
|
|
#include "lib/time/timevalue.hpp"
|
2010-01-03 00:02:53 +01:00
|
|
|
|
#include "lib/util-foreach.hpp"
|
|
|
|
|
|
#include "lib/itertools.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <deque>
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-03 02:56:50 +01:00
|
|
|
|
namespace lib {
|
|
|
|
|
|
namespace meta {
|
|
|
|
|
|
namespace test {
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
2018-11-15 23:59:23 +01:00
|
|
|
|
using steam::mobject::session::Effect;
|
|
|
|
|
|
using steam::mobject::session::ScopeQuery;
|
2011-05-16 08:38:27 +02:00
|
|
|
|
typedef lib::time::TimeVar Time;
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
|
|
|
|
|
using std::cout;
|
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace { // a custom test container....
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TestSource
|
|
|
|
|
|
{
|
|
|
|
|
|
vector<int> data_;
|
|
|
|
|
|
|
|
|
|
|
|
TestSource(uint num);
|
|
|
|
|
|
|
|
|
|
|
|
typedef vector<int>::iterator sourceIter;
|
|
|
|
|
|
typedef RangeIter<sourceIter> iterator;
|
|
|
|
|
|
|
|
|
|
|
|
iterator begin() ;
|
|
|
|
|
|
iterator end() ;
|
|
|
|
|
|
// note: a bare type definition is sufficient here....
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//(End) test containers
|
|
|
|
|
|
|
|
|
|
|
|
#define SHOW_CHECK(_EXPR_) cout << STRINGIFY(_EXPR_) << "\t : " << (_EXPR_::value? "Yes":"No") << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/*******************************************************************************//**
|
2010-01-03 00:02:53 +01:00
|
|
|
|
* @test verify the (static) classification/detection of iterables.
|
|
|
|
|
|
* Currently (1/10) we're able to detect the following
|
|
|
|
|
|
* - a STL like container with \c begin() and \c end()
|
|
|
|
|
|
* - a Lumiera Forward Iterator
|
2010-01-03 05:43:33 +01:00
|
|
|
|
* This test just retrieves the results of a compile time execution
|
|
|
|
|
|
* of the type detection; thus we just define types and then access
|
|
|
|
|
|
* the generated meta function value.
|
2010-01-03 00:02:53 +01:00
|
|
|
|
*/
|
|
|
|
|
|
class IterableClassification_test : public Test
|
|
|
|
|
|
{
|
2010-01-03 05:43:33 +01:00
|
|
|
|
|
2010-01-03 00:02:53 +01:00
|
|
|
|
void
|
2025-06-07 23:59:57 +02:00
|
|
|
|
run (Arg)
|
2010-01-03 00:02:53 +01:00
|
|
|
|
{
|
2010-01-03 05:43:33 +01:00
|
|
|
|
// define a bunch of STL containers
|
2010-01-03 00:02:53 +01:00
|
|
|
|
typedef std::vector<long> LongVector;
|
|
|
|
|
|
typedef std::multiset<Time> TimeSet;
|
|
|
|
|
|
typedef std::map<int,char> CharMap;
|
|
|
|
|
|
typedef std::list<bool> BoolList;
|
|
|
|
|
|
typedef std::deque<ushort> ShortDeque;
|
2010-01-03 05:43:33 +01:00
|
|
|
|
typedef TestSource CustomCont;
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
2010-01-03 05:43:33 +01:00
|
|
|
|
// some types in compliance to the "Lumiera Forward Iterator" concept
|
2010-01-03 00:02:53 +01:00
|
|
|
|
typedef TestSource::iterator ForwardRangeIter;
|
|
|
|
|
|
typedef TransformIter<ForwardRangeIter, long> TransformedForwardIter;
|
|
|
|
|
|
typedef FilterIter<TransformedForwardIter> FilteredForwardIter;
|
|
|
|
|
|
typedef ScopeQuery<Effect>::iterator CustomForwardIter;
|
|
|
|
|
|
|
2010-01-03 05:43:33 +01:00
|
|
|
|
|
2010-01-03 00:02:53 +01:00
|
|
|
|
// detect STL iteration
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<LongVector> );
|
2010-01-03 05:43:33 +01:00
|
|
|
|
SHOW_CHECK( can_STL_ForEach<TimeSet> );
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<CharMap> );
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<BoolList> );
|
2010-01-03 00:02:53 +01:00
|
|
|
|
SHOW_CHECK( can_STL_ForEach<ShortDeque> );
|
2010-01-03 05:43:33 +01:00
|
|
|
|
SHOW_CHECK( can_STL_ForEach<CustomCont> );
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<ForwardRangeIter> );
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<TransformedForwardIter> );
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<FilteredForwardIter> );
|
|
|
|
|
|
SHOW_CHECK( can_STL_ForEach<CustomForwardIter> );
|
|
|
|
|
|
|
|
|
|
|
|
// detect Lumiera Forward Iterator
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<LongVector> );
|
2010-01-03 05:43:33 +01:00
|
|
|
|
SHOW_CHECK( can_IterForEach<TimeSet> );
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<CharMap> );
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<BoolList> );
|
2010-01-03 00:02:53 +01:00
|
|
|
|
SHOW_CHECK( can_IterForEach<ShortDeque> );
|
2010-01-03 05:43:33 +01:00
|
|
|
|
SHOW_CHECK( can_IterForEach<CustomCont> );
|
2010-01-03 00:02:53 +01:00
|
|
|
|
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<ForwardRangeIter> );
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<TransformedForwardIter> );
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<FilteredForwardIter> );
|
|
|
|
|
|
SHOW_CHECK( can_IterForEach<CustomForwardIter> );
|
2025-06-07 23:59:57 +02:00
|
|
|
|
}
|
2010-01-03 00:02:53 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (IterableClassification_test, "unit common");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace lib::meta::test
|