Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function(dissolve_add_test)
target_link_libraries(
${TEST_NAME}
PUBLIC ${WHOLE_ARCHIVE_FLAG} ${BASIC_LINK_LIBS} ${MODULENOGUI_LINK_LIBS} ${NO_WHOLE_ARCHIVE_FLAG}
PRIVATE ${CORE_LINK_LIBS} GTest::gtest_main
PRIVATE ${CORE_LINK_LIBS} testing GTest::gtest_main
)

if(DISSOLVE_UNIT_TEST_GUI)
Expand All @@ -62,6 +62,13 @@ function(dissolve_add_test)

endfunction()

add_library(testing testing.cpp testGraph.cpp testing.h testGraph.h)
target_link_libraries(testing PRIVATE GTest::gtest_main)
target_include_directories(
testing PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src ${PROJECT_SOURCE_DIR} ${CONAN_INCLUDE_DIRS_GTEST}
${CONAN_INCLUDE_DIRS_PUGIXML}
)

# Add unit test subdirectories
add_subdirectory(algorithms)
add_subdirectory(classes)
Expand Down
2 changes: 1 addition & 1 deletion tests/algorithms/array3DIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "templates/algorithms.h"
#include "templates/array3D.h"
#include <gtest/gtest.h>
#include <iostream>

#include "iostream"
namespace UnitTest
{

Expand Down
1 change: 0 additions & 1 deletion tests/algorithms/zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "templates/algorithms.h"
#include <array>
#include <gtest/gtest.h>
#include <string_view>
#include <vector>

namespace UnitTest
Expand Down
5 changes: 3 additions & 2 deletions tests/classes/cells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Copyright (c) 2026 Team Dissolve and contributors

#include "classes/atomType.h"
#include "classes/configuration.h"
#include "classes/species.h"
#include "kernels/energy.h"
#include "main/dissolve.h"
#include "math/mathFunc.h"
#include "tests/graphData.h"
#include <gtest/gtest.h>
#include "nodes/species.h"
#include "tests/testGraph.h"

namespace UnitTest
{
Expand Down
5 changes: 3 additions & 2 deletions tests/classes/cells3.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "classes/configuration.h"
#include "kernels/energy.h"
#include "nodes/species.h"
#include "templates/algorithms.h"
#include "tests/graphData.h"
#include <gtest/gtest.h>
#include "tests/testGraph.h"

namespace UnitTest
{
Expand Down
4 changes: 2 additions & 2 deletions tests/classes/cells4.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "tests/graphData.h"
#include <gtest/gtest.h>
#include "classes/configuration.h"
#include "tests/testGraph.h"

namespace UnitTest
{
Expand Down
3 changes: 1 addition & 2 deletions tests/classes/doubleKeyedMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Copyright (c) 2026 Team Dissolve and contributors

#include "templates/doubleKeyedMap.h"
#include <gtest/gtest.h>
#include <tests/testData.h>
#include "tests/testing.h"

namespace UnitTest
{
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/empiricalFormula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2026 Team Dissolve and contributors

#include "classes/empiricalFormula.h"
#include "tests/testData.h"
#include "classes/species.h"
#include <gtest/gtest.h>

TEST(EmpiricalFormulaTest, Order)
Expand Down
42 changes: 19 additions & 23 deletions tests/classes/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include "math/history.h"
#include "nodes/number.h"
#include "tests/graphData.h"
#include "tests/testData.h"
#include <gtest/gtest.h>
#include "nodes/species.h"
#include "tests/testGraph.h"

namespace UnitTest
{
Expand Down Expand Up @@ -80,11 +79,11 @@ TEST(History, CustomClass)
for (auto n = 1; n <= 5; ++n)
{
sum += n;
EXPECT_TRUE(DissolveSystemTest::checkData1D(d * (sum / n), "Original", a.push(d * n, avgLength), "Averaged"));
EXPECT_TRUE(testData1D(d * (sum / n), "Original", a.push(d * n, avgLength), "Averaged"));
}

tomlRoundTrip(a, b);
EXPECT_TRUE(DissolveSystemTest::checkData1D(a.average(), "A", b.average(), "B"));
EXPECT_TRUE(testData1D(a.average(), "A", b.average(), "B"));
}

TEST(History, CustomClassWithInitialiser)
Expand Down Expand Up @@ -131,15 +130,13 @@ TEST(History, CustomClassWithInitialiser)
for (auto n = 0; n < 3; ++n)
{
auto avg = a.push(p, avgLength);
EXPECT_TRUE(testData1D(p.partials().get("Ar//Ar"), "Partial", avg.partials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D(p.boundPartials().get("Ar//Ar"), "BoundPartial", avg.boundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D(p.boundTotal(), "BoundTotal", avg.boundTotal(), "Averaged"));
EXPECT_TRUE(
DissolveSystemTest::checkData1D(p.partials().get("Ar//Ar"), "Partial", avg.partials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(p.boundPartials().get("Ar//Ar"), "BoundPartial",
avg.boundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(p.boundTotal(), "BoundTotal", avg.boundTotal(), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(p.unboundPartials().get("Ar//Ar"), "UnboundPartial",
avg.unboundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(p.unboundTotal(), "UnboundTotal", avg.unboundTotal(), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(p.total(), "Total", avg.total(), "Averaged"));
testData1D(p.unboundPartials().get("Ar//Ar"), "UnboundPartial", avg.unboundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D(p.unboundTotal(), "UnboundTotal", avg.unboundTotal(), "Averaged"));
EXPECT_TRUE(testData1D(p.total(), "Total", avg.total(), "Averaged"));
}

// Accumulate opposite trig values - just test partials as the totals are not automatically modified by PartialSet
Expand All @@ -149,21 +146,20 @@ TEST(History, CustomClassWithInitialiser)
for (auto n = 1; n <= 3; ++n)
{
auto avg = a.push(p, avgLength);
EXPECT_TRUE(
DissolveSystemTest::checkData1D(p.partials().get("Ar//Ar"), "Partial", avg.partials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D((dcos * (avgLength - n) - dsin * n) / avgLength, "BoundPartial",
avg.boundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(DissolveSystemTest::checkData1D((dsin * (avgLength - n) - dcos * n) / avgLength, "UnboundPartial",
avg.unboundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D(p.partials().get("Ar//Ar"), "Partial", avg.partials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D((dcos * (avgLength - n) - dsin * n) / avgLength, "BoundPartial",
avg.boundPartials().get("Ar//Ar"), "Averaged"));
EXPECT_TRUE(testData1D((dsin * (avgLength - n) - dcos * n) / avgLength, "UnboundPartial",
avg.unboundPartials().get("Ar//Ar"), "Averaged"));
}

tomlRoundTrip(a, b);
auto avgA = a.average();
auto avgB = b.average();
EXPECT_TRUE(DissolveSystemTest::checkData1D(avgA.boundPartials().get("Ar//Ar"), "BoundPartialA",
avgB.boundPartials().get("Ar//Ar"), "BoundPartialB"));
EXPECT_TRUE(DissolveSystemTest::checkData1D(avgA.unboundPartials().get("Ar//Ar"), "UnboundPartialA",
avgB.unboundPartials().get("Ar//Ar"), "UnboundPartialB"));
EXPECT_TRUE(
testData1D(avgA.boundPartials().get("Ar//Ar"), "BoundPartialA", avgB.boundPartials().get("Ar//Ar"), "BoundPartialB"));
EXPECT_TRUE(testData1D(avgA.unboundPartials().get("Ar//Ar"), "UnboundPartialA", avgB.unboundPartials().get("Ar//Ar"),
"UnboundPartialB"));
}

} // namespace UnitTest
1 change: 0 additions & 1 deletion tests/classes/neta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "data/elements.h"
#include "data/ff/ff.h"
#include "templates/algorithms.h"
#include "tests/testData.h"
#include <format>
#include <gtest/gtest.h>

Expand Down
5 changes: 2 additions & 3 deletions tests/classes/neutronWeights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

#include "classes/neutronWeights.h"
#include "classes/isotopologueSet.h"
#include "tests/graphData.h"
#include "classes/species.h"
#include "tests/tempFile.h"
#include "tests/testData.h"
#include <gtest/gtest.h>
#include "tests/testing.h"

namespace UnitTest
{
Expand Down
1 change: 0 additions & 1 deletion tests/classes/potentialSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "classes/atomType.h"
#include "math/data1D.h"
#include "math/history.h"
#include "tests/testData.h"
#include <gtest/gtest.h>

namespace UnitTest
Expand Down
1 change: 0 additions & 1 deletion tests/classes/speciesSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "classes/site.h"
#include "classes/species.h"
#include "tests/testData.h"
#include <gtest/gtest.h>

namespace UnitTest
Expand Down
3 changes: 1 addition & 2 deletions tests/classes/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include "classes/structure.h"
#include "nodes/calculateBonding.h"
#include "tests/graphData.h"
#include "tests/testGraph.h"
#include <cmath>
#include <gtest/gtest.h>

namespace UnitTest
{
Expand Down
Loading