py_void_ut.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "ut3/py_test_engine.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. using namespace NPython;
  4. Y_UNIT_TEST_SUITE(TPyVoidTest) {
  5. Y_UNIT_TEST(FromPython) {
  6. TPythonTestEngine engine;
  7. engine.ToMiniKQL<void>(
  8. "import yql\n"
  9. "\n"
  10. "def Test():\n"
  11. " return yql.Void\n",
  12. [](const NUdf::TUnboxedValue& value) {
  13. UNIT_ASSERT(value);
  14. UNIT_ASSERT(false == value.IsBoxed());
  15. });
  16. }
  17. Y_UNIT_TEST(ToPython) {
  18. TPythonTestEngine engine;
  19. engine.ToPython<void>(
  20. [](const TType* type, const NUdf::IValueBuilder& vb) {
  21. Y_UNUSED(type); Y_UNUSED(vb);
  22. return NUdf::TUnboxedValue::Void();
  23. },
  24. "import yql\n"
  25. "\n"
  26. "def Test(value):\n"
  27. " assert str(value) == 'yql.Void'\n"
  28. " assert repr(value) == 'yql.Void'\n"
  29. " assert isinstance(value, yql.TVoid)\n"
  30. " assert value is yql.Void\n");
  31. }
  32. }