Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Merged since v2.5.0, not yet released.
- `StringRepresentation` kept its output buffer, current level and GeoJSON
cursor in file-scope globals shared by every instance. They are now members.
([#178])
- `clear[]` no longer crashes after a simulation whose fire front stopped
everywhere, for instance an ignition in non-burnable fuel. ([#194])

### Changed

Expand Down Expand Up @@ -189,3 +191,4 @@ repository stays easy to return to.
[#178]: https://github.com/forefireAPI/forefire/pull/178
[#180]: https://github.com/forefireAPI/forefire/pull/180
[#183]: https://github.com/forefireAPI/forefire/pull/183
[#194]: https://github.com/forefireAPI/forefire/pull/194
1 change: 1 addition & 0 deletions src/TimeTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ FFEvent* TimeTable::getUpcomingEvent(){
decrement();
} else if ( size() == 1 ) {
// this is the only event left
head = nullptr;
decrement();
} else {
// no events left to be treated (size=0)
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ add_executable(forefire_unit_tests
test_flux_models.cpp
test_http_server.cpp
test_model_registry.cpp
test_propagation_models.cpp)
test_propagation_models.cpp
test_timetable.cpp)

target_link_libraries(forefire_unit_tests PRIVATE forefireL)
target_include_directories(forefire_unit_tests PRIVATE
Expand All @@ -27,7 +28,7 @@ endif()

# doctest groups its cases into suites; registering one CTest entry per suite
# keeps `ctest` output useful without needing doctest's CMake integration.
foreach(_suite "model registry" "propagation models" "flux models" "http server")
foreach(_suite "model registry" "propagation models" "flux models" "http server" "timetable")
string(REPLACE " " "_" _suite_id "${_suite}")
add_test(NAME "unit.${_suite_id}"
COMMAND forefire_unit_tests --test-suite=${_suite} --no-skipped-summary)
Expand Down
52 changes: 52 additions & 0 deletions tests/unit/test_timetable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @file test_timetable.cpp
* @brief The event queue once its last event has been taken out.
* @copyright Copyright (C) 2025 ForeFire, Fire Team, SPE, CNRS/Universita di Corsica.
* @license This program is free software; See LICENSE file for details. (See LICENSE file).
*/

#include "doctest/doctest.h"

#include "FFEvent.h"
#include "TimeTable.h"

#include <limits>

using libforefire::FFEvent;
using libforefire::TimeTable;

TEST_SUITE("timetable") {

TEST_CASE("clear() after the last event was dropped on reinsertion") {
TimeTable table;
table.insert(new FFEvent(nullptr, 1.0, "none"));

// A node that stopped gets an infinite time, and insert() deletes its event.
FFEvent* last = table.getUpcomingEvent();
last->setNewTime(std::numeric_limits<double>::infinity());
table.insert(last);

table.clear();

FFEvent* next = new FFEvent(nullptr, 2.0, "none");
table.insert(next);
CHECK(table.getUpcomingEvent() == next);
delete next;
}

TEST_CASE("dropping an atom's events spares the event being processed") {
TimeTable table;
FFEvent* event = new FFEvent(nullptr, 1.0, "none");
table.insert(event);

FFEvent* upcoming = table.getUpcomingEvent();
REQUIRE(upcoming == event);
table.dropAtomEvents(nullptr);

upcoming->setNewTime(2.0);
table.insert(upcoming);
CHECK(table.getUpcomingEvent() == event);
delete event;
}

}
Loading