-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_input.cpp
More file actions
44 lines (34 loc) · 927 Bytes
/
Copy pathtest_input.cpp
File metadata and controls
44 lines (34 loc) · 927 Bytes
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
#include <catch2/catch.hpp>
#include <faasm/emulator.h>
#include "faabric/util/func.h"
#include "faasm/input.h"
namespace tests {
TEST_CASE("Test parse string to ints", "[input]")
{
const char* input = "0 123 99987 5";
int* actual = faasm::parseStringToIntArray(input, 4);
REQUIRE(actual[0] == 0);
REQUIRE(actual[1] == 123);
REQUIRE(actual[2] == 99987);
REQUIRE(actual[3] == 5);
delete[] actual;
}
TEST_CASE("Test string input", "[input]")
{
faabric::Message msg = faabric::util::messageFactory("foo", "bar");
std::string expected;
std::string defaultVal = "default";
SECTION("No input")
{
expected = defaultVal;
}
SECTION("Input")
{
expected = "foobar baz blah";
msg.set_inputdata(expected);
}
setEmulatedMessage(msg);
const char* actual = faasm::getStringInput(defaultVal.c_str());
REQUIRE(actual == expected);
}
}