-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_counter.cpp
More file actions
60 lines (43 loc) · 1.11 KB
/
Copy pathtest_counter.cpp
File metadata and controls
60 lines (43 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "utils.h"
#include <catch2/catch.hpp>
#include <faabric/redis/Redis.h>
#include <faabric/state/State.h>
#include <faasm/emulator.h>
#include "faasm/counter.h"
using namespace faasm;
namespace tests {
TEST_CASE("Test normal counter operation", "[counter]")
{
cleanCppTests();
const char* key = "test_counter";
initCounter(key);
REQUIRE(getCounter(key) == 0);
incrementCounter(key);
REQUIRE(getCounter(key) == 1);
incrementCounter(key);
REQUIRE(getCounter(key) == 2);
initCounter(key);
REQUIRE(getCounter(key) == 0);
incrementCounter(key);
REQUIRE(getCounter(key) == 1);
}
TEST_CASE("Test counter over big number", "[counter]")
{
cleanCppTests();
const char* key = "test_counter";
initCounter(key);
for (int i = 0; i < 1000; i++) {
incrementCounter(key);
}
REQUIRE(getCounter(key) == 1000);
}
TEST_CASE("Test uninitialised counter", "[counter]")
{
cleanCppTests();
const char* key = "test_uninit_key";
initCounter(key);
REQUIRE(getCounter(key) == 0);
incrementCounter(key);
REQUIRE(getCounter(key) == 1);
}
}