Skip to content

Commit 8fa654b

Browse files
committed
Added rudimentary test case for SetWeightHint.
1 parent 3ca6720 commit 8fa654b

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

project/msvc/CppReactTest.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
<ClCompile Include="..\..\tests\src\ObserverTestQ.cpp" />
175175
<ClCompile Include="..\..\tests\src\OperationsTest.cpp" />
176176
<ClCompile Include="..\..\tests\src\OperationsTestQ.cpp" />
177+
<ClCompile Include="..\..\tests\src\ParallelizationTest.cpp" />
177178
<ClCompile Include="..\..\tests\src\SignalTest.cpp" />
178179
<ClCompile Include="..\..\tests\src\SignalTestQ.cpp" />
179180
<ClCompile Include="..\..\tests\src\TransactionTest.cpp" />
@@ -183,6 +184,7 @@
183184
<ClInclude Include="..\..\tests\src\MoveTest.h" />
184185
<ClInclude Include="..\..\tests\src\ObserverTest.h" />
185186
<ClInclude Include="..\..\tests\src\OperationsTest.h" />
187+
<ClInclude Include="..\..\tests\src\ParallelizationTest.h" />
186188
<ClInclude Include="..\..\tests\src\SignalTest.h" />
187189
<ClInclude Include="..\..\tests\src\TransactionTest.h" />
188190
<ClInclude Include="..\..\tests\src\TestUtil.h" />

project/msvc/CppReactTest.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<ClCompile Include="..\..\tests\src\TransactionTest.cpp">
4646
<Filter>Source Files</Filter>
4747
</ClCompile>
48+
<ClCompile Include="..\..\tests\src\ParallelizationTest.cpp">
49+
<Filter>Source Files</Filter>
50+
</ClCompile>
4851
</ItemGroup>
4952
<ItemGroup>
5053
<ClInclude Include="..\..\tests\src\EventStreamTest.h">
@@ -68,5 +71,8 @@
6871
<ClInclude Include="..\..\tests\src\TestUtil.h">
6972
<Filter>Header Files</Filter>
7073
</ClInclude>
74+
<ClInclude Include="..\..\tests\src\ParallelizationTest.h">
75+
<Filter>Header Files</Filter>
76+
</ClInclude>
7177
</ItemGroup>
7278
</Project>

tests/src/ParallelizationTest.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
// Copyright Sebastian Jeckel 2014.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#include "ParallelizationTest.h"
8+
#include "TestUtil.h"
9+
10+
#include "react/engine/PulsecountEngine.h"
11+
#include "react/engine/ToposortEngine.h"
12+
#include "react/engine/SubtreeEngine.h"
13+
14+
///////////////////////////////////////////////////////////////////////////////////////////////////
15+
namespace {
16+
17+
using namespace react;
18+
19+
using P1 = DomainParams<sequential_concurrent,ToposortEngine>;
20+
using P2 = DomainParams<parallel_concurrent,ToposortEngine>;
21+
using P3 = DomainParams<parallel_concurrent,PulsecountEngine>;
22+
using P4 = DomainParams<parallel_concurrent,SubtreeEngine>;
23+
24+
INSTANTIATE_TYPED_TEST_CASE_P(SeqToposortQ, ParallelizationTest, P1);
25+
INSTANTIATE_TYPED_TEST_CASE_P(ParToposortQ, ParallelizationTest, P2);
26+
INSTANTIATE_TYPED_TEST_CASE_P(PulsecountQ, ParallelizationTest, P3);
27+
INSTANTIATE_TYPED_TEST_CASE_P(SubtreeQ, ParallelizationTest, P4);
28+
29+
} // ~namespace

tests/src/ParallelizationTest.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
// Copyright Sebastian Jeckel 2014.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#pragma once
8+
9+
#include "gtest/gtest.h"
10+
11+
#include "react/Domain.h"
12+
#include "react/Signal.h"
13+
#include "react/Event.h"
14+
#include "react/Observer.h"
15+
#include "react/Algorithm.h"
16+
17+
///////////////////////////////////////////////////////////////////////////////////////////////////
18+
namespace {
19+
20+
using namespace react;
21+
using namespace std;
22+
23+
///////////////////////////////////////////////////////////////////////////////////////////////////
24+
/// ParallelizationTest fixture
25+
///////////////////////////////////////////////////////////////////////////////////////////////////
26+
template <typename TParams>
27+
class ParallelizationTest : public testing::Test
28+
{
29+
public:
30+
template <EPropagationMode mode>
31+
class MyEngine : public TParams::template EngineT<mode> {};
32+
33+
REACTIVE_DOMAIN(MyDomain, TParams::mode, MyEngine)
34+
};
35+
36+
TYPED_TEST_CASE_P(ParallelizationTest);
37+
38+
///////////////////////////////////////////////////////////////////////////////////////////////////
39+
/// Iterate1 test
40+
///////////////////////////////////////////////////////////////////////////////////////////////////
41+
TYPED_TEST_P(ParallelizationTest, WeightHint1)
42+
{
43+
using D = typename WeightHint1::MyDomain;
44+
45+
auto sig = MakeVar<D>(0);
46+
auto evn = MakeEventSource<D,int>();
47+
auto cont = MakeContinuation<D>(sig, [] (int v) {});
48+
auto obs = Observe(evn, [] (int v) {});
49+
50+
sig.SetWeightHint(WeightHint::heavy);
51+
evn.SetWeightHint(WeightHint::automatic);
52+
cont.SetWeightHint(WeightHint::light);
53+
obs.SetWeightHint(WeightHint::automatic);
54+
}
55+
56+
///////////////////////////////////////////////////////////////////////////////////////////////////
57+
REGISTER_TYPED_TEST_CASE_P
58+
(
59+
ParallelizationTest,
60+
WeightHint1
61+
);
62+
63+
} // ~namespace

0 commit comments

Comments
 (0)