| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "PClockMock.h" | ||
| 8 | |||
| 9 | #include <ctime> | ||
| 10 | #include <nanobind/nanobind.h> | ||
| 11 | #include <nanobind/stl/string.h> | ||
| 12 | #include <nanobind/stl/chrono.h> | ||
| 13 | |||
| 14 | namespace nb = nanobind; | ||
| 15 | |||
| 16 |
1/7✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→12) not taken.
✗ Branch 2 (16→17) not taken.
✗ Branch 3 (16→18) not taken.
✗ Branch 4 (16→23) not taken.
✗ Branch 5 (25→26) not taken.
✗ Branch 6 (25→27) not taken.
|
4 | NB_MODULE(clockMock, m) { |
| 17 |
2/4✓ Branch 0 (2→3) taken 1 times.
✗ Branch 1 (2→163) not taken.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→161) not taken.
|
1 | m.doc() = "Nanobind bindings for ClockMock class"; |
| 18 | 2 | nb::class_<PClockMock>(m, "PClockMock") | |
| 19 | |||
| 20 | // Constructor | ||
| 21 | 2 | .def(nb::init<>()) | |
| 22 | |||
| 23 | // Clock API methods | ||
| 24 | 2 | .def("now", &PClockMock::now, | |
| 25 | "Get the mocked current time") | ||
| 26 | |||
| 27 | 1 | .def("sleep", [](const PClockMock &c, time_t ellapsedTime) { | |
| 28 | ✗ | c.sleep(ellapsedTime); | |
| 29 | ✗ | }, | |
| 30 | "Sleep for the given elapsed time (no real sleep in mock)") | ||
| 31 | |||
| 32 | // Mock API methods | ||
| 33 | 4 | .def("setCurrentTime", [](PClockMock &c, time_t currentTime) { | |
| 34 | 3 | c.setCurrentTime(currentTime); | |
| 35 | 3 | }, | |
| 36 | "Set the mocked current time") | ||
| 37 | |||
| 38 | 4 | .def("setMockPrefix", [](PClockMock &c, const std::string &prefix) { | |
| 39 | 2 | c.setMockPrefix(prefix); | |
| 40 | 2 | }, | |
| 41 | "Set the mock prefix for logging") | ||
| 42 | |||
| 43 | 1 | .def("resetIndex", &PClockMock::resetIndex, | |
| 44 | "Reset the mock index to start from the beginning of the mock data") | ||
| 45 | |||
| 46 | 2 | .def("close", &PClockMock::close, | |
| 47 | "Close the mock and release resources"); | ||
| 48 | |||
| 49 | // Static methods | ||
| 50 |
1/2✓ Branch 0 (158→159) taken 1 times.
✗ Branch 1 (158→164) not taken.
|
1 | m.def("phoenix_createMockBackend", [](PClockMock &c, const std::string & prefix) -> bool { |
| 51 | ✗ | return phoenix_createMockBackend(c, prefix); | |
| 52 | }, | ||
| 53 | 1 | nb::arg("c"), nb::arg("prefix") = "", | |
| 54 | "Create the mock backend with the given prefix"); | ||
| 55 | 1 | } | |
| 56 |