Skip to content
Snippets Groups Projects
Commit 91728237 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for SocketModule

parent 2fd59d93
No related branches found
No related tags found
1 merge request!126Begin socket handling: core functionalities are available
......@@ -121,6 +121,7 @@ add_executable (unit_tests
test_SmallArray.cpp
test_SmallVector.cpp
test_Socket.cpp
test_SocketModule.cpp
test_SquareGaussQuadrature.cpp
test_SquareTransformation.cpp
test_SymbolTable.cpp
......
......@@ -5,6 +5,7 @@
#include <utils/pugs_config.hpp>
#include <fstream>
#include <netdb.h>
#include <unistd.h>
// clazy:excludeall=non-pod-global-static
......@@ -20,8 +21,10 @@ TEST_CASE("BinaryExpressionProcessor shift", "[language]")
{
std::ostringstream data;
data << R"(import socket;)";
data << "let fout:ostream, fout = ofstream(\"" << path.string() << "\");\n";
data << R"(fout << 2 << " " << true << " " << 2 + 3 << "\n";)";
data << R"(fout << 2 << " " << true << " " << 2 + 3 << "\n";
fout << createSocketServer(0);)";
TAO_PEGTL_NAMESPACE::string_input input{data.str(), "test.pgs"};
auto ast = ASTBuilder::build(input);
......@@ -53,7 +56,27 @@ TEST_CASE("BinaryExpressionProcessor shift", "[language]")
}
} while (fin);
REQUIRE(file_content == "2 true 5\n");
std::string expected = "2 true 5\n";
char hbuf[NI_MAXHOST];
::gethostname(hbuf, NI_MAXHOST);
expected += hbuf;
expected += ':';
REQUIRE(file_content.size() > expected.size());
REQUIRE(file_content.substr(0, expected.size()) == expected);
std::string suffix = file_content.substr(expected.size(), file_content.size() - expected.size());
auto is_int = [](const std::string& s) {
for (const char& c : s) {
if (not std::isdigit(c)) {
return false;
}
}
return true;
};
REQUIRE(is_int(suffix));
}
std::filesystem::remove(filename);
......
......@@ -4,8 +4,6 @@
#include <language/modules/MathModule.hpp>
#include <language/utils/BuiltinFunctionEmbedder.hpp>
#include <set>
// clazy:excludeall=non-pod-global-static
TEST_CASE("MathModule", "[language]")
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment