test_engine_checks.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from imgui_bundle._imgui_bundle import imgui as imgui # type: ignore
  2. import traceback
  3. def _check(result: bool, backtrace_nb: int) -> None:
  4. traceback_info = traceback.extract_stack()
  5. caller_info = traceback_info[-backtrace_nb]
  6. filename, line_num, func_name, line_code = caller_info
  7. imgui.test_engine.check(
  8. filename,
  9. func_name,
  10. line_num,
  11. imgui.test_engine.TestCheckFlags_.none,
  12. result,
  13. line_code,
  14. )
  15. def CHECK(result: bool) -> None:
  16. _check(result, 3)
  17. def check_no_ret(result: bool) -> None:
  18. """
  19. Not implemented, because I did not understand the intended behavior
  20. #define IM_CHECK_OP(_LHS, _RHS, _OP, _RETURN) \
  21. do \
  22. { \
  23. ... \
  24. if (ImGuiTestEngine_Check(__FILE__, __func__, __LINE__, ImGuiTestCheckFlags_None, __res, expr_buf.c_str())) \
  25. IM_ASSERT(__res); \
  26. if (_RETURN && !__res) \
  27. return; \
  28. } while (0)
  29. """
  30. raise NotImplementedError()