UI-Dispatch: verify consistency of argument data handling
This commit is contained in:
parent
c96fcc1c6a
commit
87dc04f324
2 changed files with 77 additions and 8 deletions
|
|
@ -32,7 +32,6 @@
|
|||
#include "lib/call-queue.hpp"
|
||||
|
||||
#include <functional>
|
||||
//#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
|
@ -46,8 +45,43 @@ namespace test{
|
|||
|
||||
|
||||
|
||||
namespace { // test data
|
||||
}
|
||||
namespace { // test fixture
|
||||
|
||||
uint calc_sum = 0;
|
||||
uint ctor_sum = 0;
|
||||
uint dtor_sum = 0;
|
||||
|
||||
template<uint i>
|
||||
struct Dummy
|
||||
{
|
||||
uint val_;
|
||||
|
||||
Dummy()
|
||||
: val_(i)
|
||||
{
|
||||
ctor_sum += (val_+1);
|
||||
}
|
||||
|
||||
~Dummy()
|
||||
{
|
||||
dtor_sum += val_;
|
||||
}
|
||||
|
||||
int
|
||||
operator++()
|
||||
{
|
||||
return ++val_;
|
||||
}
|
||||
};
|
||||
|
||||
template<uint i>
|
||||
void
|
||||
increment (Dummy<i>&& dummy) //NOTE: dummy is consumed here
|
||||
{
|
||||
calc_sum += ++dummy;
|
||||
}
|
||||
|
||||
}//(End) test fixture
|
||||
|
||||
|
||||
|
||||
|
|
@ -94,10 +128,41 @@ namespace test{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test consistency of queue data handling
|
||||
* - functors of various types can be mixed
|
||||
* - entries are moved in and out of the queue
|
||||
* - no copying whatsoever happens
|
||||
* - each entry gets invoked
|
||||
* - all entries are invoked in order
|
||||
* - enqueuing and dequeuing can be interspersed
|
||||
* - no memory leaks in bound argument data
|
||||
*/
|
||||
void
|
||||
verify_Consistency ()
|
||||
{
|
||||
UNIMPLEMENTED("verify_Consistency");
|
||||
calc_sum = 0;
|
||||
ctor_sum = 0;
|
||||
dtor_sum = 0;
|
||||
|
||||
CallQueue queue;
|
||||
queue.feed ([]() { increment(Dummy<0>{}); }); //NOTE: each lambda binds a different instantiation of the increment template
|
||||
queue.feed ([]() { increment(Dummy<1>{}); }); // and each invocation closes over an anonymous rvalue instance
|
||||
queue.feed ([]() { increment(Dummy<2>{}); });
|
||||
|
||||
queue.invoke();
|
||||
queue.invoke();
|
||||
queue.feed ([]() { increment(Dummy<3>{}); });
|
||||
queue.feed ([]() { increment(Dummy<4>{}); });
|
||||
|
||||
queue.invoke();
|
||||
queue.invoke();
|
||||
queue.invoke();
|
||||
|
||||
uint expected = (5+1)*5/2;
|
||||
CHECK (calc_sum = expected);
|
||||
CHECK (ctor_sum = expected);
|
||||
CHECK (dtor_sum = expected);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1024,8 +1024,8 @@
|
|||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1501938738836" ID="ID_1257499857" MODIFIED="1501940794505" TEXT="Helper: CallQueue">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1501938738836" ID="ID_1257499857" MODIFIED="1501951450697" TEXT="Helper: CallQueue">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1501938715247" ID="ID_1286525769" MODIFIED="1501938725574" TEXT="simplistic">
|
||||
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="yes"/>
|
||||
|
|
@ -1049,8 +1049,12 @@
|
|||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1501939204166" ID="ID_383444966" MODIFIED="1501946866881" TEXT="CallQueue_test">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1501946847700" ID="ID_1917302142" MODIFIED="1501946851847" TEXT="basic"/>
|
||||
<node CREATED="1501946852555" ID="ID_1617455971" MODIFIED="1501946855975" TEXT="mehrere"/>
|
||||
<node COLOR="#338800" CREATED="1501946847700" ID="ID_1917302142" MODIFIED="1501951434466" TEXT="basic">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1501946852555" ID="ID_1617455971" MODIFIED="1501951436667" TEXT="mehrere">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1501946856587" ID="ID_1780067399" MODIFIED="1501946862958" TEXT="Streß"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1501939212693" ID="ID_1007296291" MODIFIED="1501940740143" TEXT="#1099 DemoGuiRoundtrip">
|
||||
|
|
|
|||
Loading…
Reference in a new issue