aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/python/bindings/py_void_ut.cpp
blob: 7fbeca204379d07487ca5a2e6d4cf0be1632c464 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "ut3/py_test_engine.h"

#include <library/cpp/testing/unittest/registar.h>


using namespace NPython;

Y_UNIT_TEST_SUITE(TPyVoidTest) {
    Y_UNIT_TEST(FromPython) {
        TPythonTestEngine engine;
        engine.ToMiniKQL<void>(
                "import yql\n"
                "\n"
                "def Test():\n"
                "    return yql.Void\n",
                [](const NUdf::TUnboxedValue& value) {
                    UNIT_ASSERT(value);
                    UNIT_ASSERT(false == value.IsBoxed());
                });
    }

    Y_UNIT_TEST(ToPython) {
        TPythonTestEngine engine;
        engine.ToPython<void>(
                [](const TType* type, const NUdf::IValueBuilder& vb) {
                    Y_UNUSED(type); Y_UNUSED(vb);
                    return NUdf::TUnboxedValue::Void();
                },
                "import yql\n"
                "\n"
                "def Test(value):\n"
                "   assert str(value) == 'yql.Void'\n"
                "   assert repr(value) == 'yql.Void'\n"
                "   assert isinstance(value, yql.TVoid)\n"
                "   assert value is yql.Void\n");
    }
}