Skip to content

Commit 76fc2b7

Browse files
fix(tests): Fix receive function test (#66)
1 parent 402bb9b commit 76fc2b7

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

examples/data/program-test-6.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
{ "title": "RSI",
1+
{ "title": "Bollinger Bands",
22
"description": "This program is generated by the compiler, it represents the bollinger bands operator",
33
"date": "now",
44
"apiVersion": "v1",
55
"author": "Eduardo",
66
"entryOperator": "754",
7-
"output": { "37": [ "o1", "o2" ] },
7+
"output": { "37": [ "o2", "o1", "o3" ] },
88
"operators": [
9-
{ "id": "37", "type": "Output", "numPorts": 2 },
9+
{ "id": "37", "type": "Output", "numPorts": 3 },
1010
{ "id": "495", "type": "Minus" },
1111
{ "id": "861", "type": "Plus" },
1212
{ "id": "996", "type": "Scale", "value": 2 },
@@ -16,8 +16,9 @@
1616
{ "id": "754", "type": "Input", "numPorts": 1 }
1717
],
1818
"connections": [
19-
{ "from": "495", "to": "37", "fromPort": "o1", "toPort": "i2" },
20-
{ "from": "861", "to": "37", "fromPort": "o1", "toPort": "i1" },
19+
{ "from": "510", "to": "37", "fromPort": "o1", "toPort": "i3" },
20+
{ "from": "495", "to": "37", "fromPort": "o1", "toPort": "i1" },
21+
{ "from": "861", "to": "37", "fromPort": "o1", "toPort": "i2" },
2122
{ "from": "996", "to": "495", "fromPort": "o1", "toPort": "i2" },
2223
{ "from": "510", "to": "495", "fromPort": "o1", "toPort": "i1" },
2324
{ "from": "996", "to": "861", "fromPort": "o1", "toPort": "i2" },

libs/api/test/test_bollinger_bands_generated.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ TEST_CASE("read pipeline test bollinger_bands") {
2727
int end = 10000;
2828
int o1 = 0;
2929
int o2 = 0;
30+
int o3 = 0;
31+
int firstdown = 0;
32+
int firstma = 0;
33+
int firstup = 0;
3034
int lastdown = -1;
3135
int lastup = -1;
36+
int lastma = -1;
3237
v.push_back(start);
3338
for (int i = start + 1; i < end; i++) {
3439
int random_value = rand();
@@ -50,21 +55,42 @@ TEST_CASE("read pipeline test bollinger_bands") {
5055
if (output.find("37")->second.count("o1") > 0) {
5156
for (int j = 0; j < output.find("37")->second.find("o1")->second.size(); j++) {
5257
int now = output.find("37")->second.find("o1")->second.at(j).time;
53-
if (lastup >= 0) REQUIRE(now - 1 == lastup);
58+
if (lastup >= 0)
59+
REQUIRE(now - 1 == lastup);
60+
else
61+
firstup = now;
5462
lastup = now;
5563
o1++;
5664
}
5765
}
5866
if (output.find("37")->second.count("o2") > 0) {
5967
for (int j = 0; j < output.find("37")->second.find("o2")->second.size(); j++) {
6068
int now = output.find("37")->second.find("o2")->second.at(j).time;
61-
if (lastdown >= 0) REQUIRE(now - 1 == lastdown);
69+
if (lastdown >= 0)
70+
REQUIRE(now - 1 == lastdown);
71+
else
72+
firstdown = now;
6273
lastdown = now;
6374
o2++;
6475
}
6576
}
77+
if (output.find("37")->second.count("o3") > 0) {
78+
for (int j = 0; j < output.find("37")->second.find("o3")->second.size(); j++) {
79+
int now = output.find("37")->second.find("o3")->second.at(j).time;
80+
if (lastma >= 0)
81+
REQUIRE(now - 1 == lastma);
82+
else
83+
firstma = now;
84+
lastma = now;
85+
o3++;
86+
}
87+
}
6688
}
6789
}
6890
REQUIRE(o1 == o2);
91+
REQUIRE(o3 == o2);
92+
REQUIRE(o1 > 0);
93+
REQUIRE(firstup == firstdown);
94+
REQUIRE(firstup == firstma);
6995
}
7096
}

0 commit comments

Comments
 (0)