| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef CLOCKMOCKFILE_BINDING_H | ||
| 8 | #define CLOCKMOCKFILE_BINDING_H | ||
| 9 | |||
| 10 | #include "PClockMockFile.h" | ||
| 11 | |||
| 12 | #include <ctime> | ||
| 13 | #include <nanobind/nanobind.h> | ||
| 14 | #include <nanobind/stl/string.h> | ||
| 15 | #include <nanobind/stl/chrono.h> | ||
| 16 | |||
| 17 | namespace nb = nanobind; | ||
| 18 | |||
| 19 | 3 | inline void make_clock_mock_file_binding(nb::module_ &m) { | |
| 20 | nb::module_ m_clock_mock_file = m.def_submodule("clock_mock_file", "Clock mock file utilities for testing"); | ||
| 21 | |||
| 22 | 3 | nb::class_<PClockMockFile>(m_clock_mock_file, "PClockMockFile") | |
| 23 | |||
| 24 | // Constructor | ||
| 25 | 6 | .def(nb::init<>()) | |
| 26 | |||
| 27 | // Clock API methods | ||
| 28 | 6 | .def("now", &PClockMockFile::now, | |
| 29 | "Get the mocked current time") | ||
| 30 | |||
| 31 | 3 | .def("sleep", [](const PClockMockFile &c, time_t ellapsedTime) { | |
| 32 | ✗ | c.sleep(ellapsedTime); | |
| 33 | ✗ | }, | |
| 34 | "Sleep for the given elapsed time (no real sleep in mock)") | ||
| 35 | |||
| 36 | // Mock API methods | ||
| 37 | 3 | .def("setCurrentTime", [](PClockMockFile &c, time_t currentTime) { | |
| 38 | 3 | c.setCurrentTime(currentTime); | |
| 39 | 3 | }, | |
| 40 | "Set the mocked current time") | ||
| 41 | |||
| 42 | 8 | .def("setMockPrefix", [](PClockMockFile &c, const std::string &prefix) { | |
| 43 | 2 | c.setMockPrefix(prefix); | |
| 44 | 2 | }, | |
| 45 | "Set the mock prefix for logging") | ||
| 46 | |||
| 47 | 6 | .def("close", &PClockMockFile::close, | |
| 48 | "Close the mock file and release resources"); | ||
| 49 | |||
| 50 | // Static methods | ||
| 51 |
1/2✓ Branch 0 (133→134) taken 3 times.
✗ Branch 1 (133→162) not taken.
|
3 | m_clock_mock_file.def("phoenix_createMockBackend", [](PClockMockFile &c, const std::string & prefix) -> bool { |
| 52 | ✗ | return phoenix_createMockBackend(c, prefix); | |
| 53 | }, | ||
| 54 | "Create the mock backend with the given prefix"); | ||
| 55 | |||
| 56 |
1/2✓ Branch 0 (156→157) taken 3 times.
✗ Branch 1 (156→163) not taken.
|
3 | m_clock_mock_file.def("phoenix_createClockMock", [](const std::string & prefix, size_t nbTime, time_t firstTime, time_t timeIncrement) -> bool { |
| 57 | ✗ | return phoenix_createClockMock(prefix, nbTime, firstTime, timeIncrement); | |
| 58 | }, | ||
| 59 | 9 | nb::arg("prefix"), nb::arg("nbTime"), nb::arg("firstTime") = 0l, nb::arg("timeIncrement") = 1l, | |
| 60 | "Create a clock mock with the given prefix, number of time points, first time and time increment"); | ||
| 61 | |||
| 62 |
1/2✓ Branch 0 (159→160) taken 3 times.
✗ Branch 1 (159→176) not taken.
|
3 | m_clock_mock_file.def("phoenix_fillClockMock", [](PClockMockFile &mock, size_t nbTime, time_t firstTime, time_t timeIncrement) { |
| 63 | ✗ | phoenix_fillClockMock<PClockMockFile>(mock, nbTime, firstTime, timeIncrement); | |
| 64 | ✗ | }, | |
| 65 | "Fill the given clock mock with time values"); | ||
| 66 | 3 | } | |
| 67 | |||
| 68 | |||
| 69 | #endif // CLOCKMOCKFILE_BINDING_H | ||
| 70 | |||
| 71 | |||
| 72 |