Skip to content

Commit

Permalink
Fix Random generator and Assert test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Svvmy committed Jan 14, 2024
1 parent 7f45948 commit 884e229
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
9 changes: 5 additions & 4 deletions utils/tst/AssertTestSuite.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef GMDS_ASSERT_TEST_H
#define GMDS_ASSERT_TEST_H
#ifndef GMDS_ASSERT_TESTSUITE_H
#define GMDS_ASSERT_TESTSUITE_H

#include "gtest/gtest.h"
#include <gmds/utils/Assert.h>
#include <unit_test_config.h>
using namespace gmds;

#define STR(x) #x
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

TEST(AssertTestSuite, SetAndGetAssertMode)
{
Expand Down Expand Up @@ -71,7 +72,7 @@ TEST(AssertTestSuite, SetAssertModeAndRangeAssert)

setAssertMode(ASSERT_MODE_ABORT);
// Replace the exit(0) test with output to a file or other mechanism
ASSERT_EXIT(GMDS_RANGE_ASSERT(5.0, 0.0, 2.0), ::testing::ExitedWithCode(0), "");
ASSERT_EXIT(GMDS_RANGE_ASSERT(5.0, 0.0, 2.0, STR(test_file.cpp), 42), ::testing::ExitedWithCode(0), "");
}

#endif // GMDS_ASSERT_TEST_H
6 changes: 3 additions & 3 deletions utils/tst/CommonTypesTestSuite.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef COMMON_TYPES_TEST_SUITE_H
#define COMMON_TYPES_TEST_SUITE_H
#ifndef GMDS_COMMON_TYPES_TESTSUITE_H
#define GMDS_COMMON_TYPES_TESTSUITE_H

#include "gtest/gtest.h"
#include <gmds/utils/CommonTypes.h>
Expand Down Expand Up @@ -32,4 +32,4 @@ TEST(CommonTypesTestSuite, KeepFilterTest)
ASSERT_TRUE(std::find(result.begin(), result.end(), 3) != result.end());
}

#endif // COMMON_TYPES_TEST_SUITE_H
#endif // GMDS_COMMON_TYPES_TEST_SUITE_H
14 changes: 8 additions & 6 deletions utils/tst/LogTestSuite.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef GMDS_LOG_TEST_SUITE_H
# define GMDS_LOG_TEST_SUITE_H
#define GMDS_LOG_TEST_SUITE_H

# include "gtest/gtest.h"
# include <gmds/utils/Log.h>
# include <gmds/utils/LogStream.h>
# include <unit_test_config.h>
#include "gtest/gtest.h"
#include <gmds/utils/Log.h>
#include <gmds/utils/LogStream.h>
#include <unit_test_config.h>

using namespace gmds;

Expand Down Expand Up @@ -72,4 +72,6 @@ TEST(LogTestSuite, OperatorStreamTest)
oss << "Test message";
EXPECT_EQ(outStream.str(), oss.str());
}
}
}

#endif // GMDS_LOG_TESTSUITE_H
14 changes: 7 additions & 7 deletions utils/tst/OrientedGraphTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace gmds;

TEST(OrientedGraphTest, GraphNodeAddOutEdge)
TEST(OrientedGraphTestSuite, GraphNodeAddOutEdge)
{
GraphNode node1(1);
GraphNode node2(2);
Expand All @@ -18,7 +18,7 @@ TEST(OrientedGraphTest, GraphNodeAddOutEdge)
ASSERT_EQ(node1.outEdges()[0]->id(), edge.id());
}

TEST(OrientedGraphTest, GraphNodeAddInEdge)
TEST(OrientedGraphTestSuite, GraphNodeAddInEdge)
{
GraphNode node1(1);
GraphNode node2(2);
Expand All @@ -29,7 +29,7 @@ TEST(OrientedGraphTest, GraphNodeAddInEdge)
ASSERT_EQ(node2.inEdges()[0]->id(), edge.id());
}

TEST(OrientedGraphTest, GraphEdgeGetEdgesStartingFrom)
TEST(OrientedGraphTestSuite, GraphEdgeGetEdgesStartingFrom)
{
GraphNode node1(1);
GraphNode node2(2);
Expand All @@ -42,14 +42,14 @@ TEST(OrientedGraphTest, GraphEdgeGetEdgesStartingFrom)
ASSERT_EQ(edge2.getEdgesStartingFrom(&node2).size(), 0);
}

TEST(OrientedGraphTest, OrientedGraphAddEdge)
TEST(OrientedGraphTestSuite, OrientedGraphAddEdge)
{
OrientedGraph graph(3);
ASSERT_TRUE(graph.addEdge(1, 0, 1));
ASSERT_EQ(graph.nbEdges(), 1);
}

TEST(OrientedGraphTest, OrientedGraphUpdateNodes)
TEST(OrientedGraphTestSuite, OrientedGraphUpdateNodes)
{
OrientedGraph graph(3);
graph.addEdge(1, 0, 1);
Expand All @@ -59,14 +59,14 @@ TEST(OrientedGraphTest, OrientedGraphUpdateNodes)
ASSERT_EQ(graph.node(1)->inEdges().size(), 1);
}

TEST(OrientedGraphTest, OrientedGraphNode)
TEST(OrientedGraphTestSuite, OrientedGraphNode)
{
OrientedGraph graph(3);
GraphNode *node = graph.node(1);
ASSERT_EQ(node->id(), 1);
}

TEST(OrientedGraphTest, OrientedGraphEdge)
TEST(OrientedGraphTestSuite, OrientedGraphEdge)
{
OrientedGraph graph(3);
graph.addEdge(1, 0, 1);
Expand Down
10 changes: 6 additions & 4 deletions utils/tst/RandomGeneratorTestSuite.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef GMDS_RANDOM_GENERATOR_TESTSUITE_H
# define GMDS_RANDOM_GENERATOR_TESTSUITE_H
#define GMDS_RANDOM_GENERATOR_TESTSUITE_H

# include <gmds/utils/RandomGenerator.h>
# include "gtest/gtest.h"
# include <unit_test_config.h>
#include "gtest/gtest.h"
#include <gmds/utils/RandomGenerator.h>
#include <unit_test_config.h>

using namespace gmds;

Expand All @@ -30,3 +30,5 @@ TEST(RandomGeneratorTestSuite, Initialization)
// Test if two instances have different seed values
EXPECT_NE(randomGen1.value(), randomGen2.value());
}

#endif // GMDS_RANDOM_GENERATOR_TESTSUITE_H
2 changes: 1 addition & 1 deletion utils/tst/VariableManagerTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ TEST(VariableManagerTestSuite, Compact)
ASSERT_EQ(variableManager.getNbVariables(), 1);
}

#endif // VARIABLE_MANAGER_TEST_H
#endif // GMDS_VARIABLE_MANAGER_TESTSUITE_H

0 comments on commit 884e229

Please sign in to comment.