55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#include <gtest/gtest.h>
|
|
#include "simulator.hpp"
|
|
#include <vector>
|
|
#include <filesystem>
|
|
#include <memory>
|
|
|
|
class SimulatorTest : public testing::Test {
|
|
protected:
|
|
SimulatorTest() :
|
|
bodies({
|
|
Body(
|
|
Position{Decimal(0), Decimal(0), Decimal(0)},
|
|
Velocity{Decimal(0), Decimal(0), Decimal(0)},
|
|
Mass(1.0),
|
|
"body1"
|
|
),
|
|
Body(
|
|
Position{Decimal(1), Decimal(0), Decimal(0)},
|
|
Velocity{Decimal(0), Decimal(1), Decimal(0)},
|
|
Mass(1.0),
|
|
"body2"
|
|
)
|
|
})
|
|
{
|
|
simulator = std::make_unique<Simulator>(
|
|
bodies,
|
|
Decimal(0.1), // step_size
|
|
1, // steps_per_save
|
|
std::filesystem::path("test_output.json"), // output_file
|
|
0, // current_step
|
|
true // overwrite_output
|
|
);
|
|
}
|
|
|
|
std::vector<Body> bodies;
|
|
std::unique_ptr<Simulator> simulator;
|
|
};
|
|
|
|
TEST_F(SimulatorTest, Step) {
|
|
// Take a step
|
|
//TODO
|
|
}
|
|
|
|
TEST_F(SimulatorTest, TotalEnergy) {
|
|
//TODO
|
|
// Decimal initial_energy = simulator->total_energy();
|
|
|
|
// simulator->step(Decimal(0.1));
|
|
|
|
// Decimal new_energy = simulator->total_energy();
|
|
|
|
// EXPECT_NEAR(initial_energy, new_energy, 1e-10);
|
|
}
|
|
|