-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <library/cpp/testing/unittest/registar.h> | ||
|
||
#include <ydb/core/scheme/scheme_tablecell.h> | ||
#include <ydb/core/scheme/scheme_type_registry.h> | ||
|
||
extern "C" { | ||
#include "postgres.h" | ||
#include "catalog/pg_type_d.h" | ||
} | ||
|
||
namespace NKikimr { | ||
namespace NTable { | ||
|
||
Y_UNIT_TEST_SUITE(PgTest) { | ||
|
||
Y_UNIT_TEST(DumpIntCells) { | ||
NScheme::TTypeRegistry typeRegistry; | ||
|
||
i64 intVal = 55555; | ||
|
||
{ | ||
TCell cell((const char *)&intVal, sizeof(i64)); | ||
NScheme::TTypeInfo typeInfo(NScheme::TInt64::TypeId); | ||
|
||
TString printRes = DbgPrintCell(cell, typeInfo, typeRegistry); | ||
UNIT_ASSERT_STRINGS_EQUAL(printRes, "Int64 : 55555"); | ||
} | ||
|
||
{ | ||
NScheme::TTypeInfo pgTypeInfo(NPg::TypeDescFromPgTypeId(INT8OID)); | ||
auto desc = pgTypeInfo.GetPgTypeDesc(); | ||
auto res = NPg::PgNativeBinaryFromNativeText(Sprintf("%u", intVal), desc); | ||
UNIT_ASSERT_C(!res.Error, *res.Error); | ||
TString binary = res.Str; | ||
TCell pgCell((const char*)binary.data(), binary.size()); | ||
|
||
TString printRes = DbgPrintCell(pgCell, pgTypeInfo, typeRegistry); | ||
UNIT_ASSERT_STRINGS_EQUAL(printRes, "pgint8 : 55555"); | ||
} | ||
} | ||
|
||
Y_UNIT_TEST(DumpStringCells) { | ||
NScheme::TTypeRegistry typeRegistry; | ||
|
||
char strVal[] = "This is the value"; | ||
|
||
{ | ||
TCell cell((const char*)&strVal, sizeof(strVal) - 1); | ||
NScheme::TTypeInfo typeInfo(NScheme::TString::TypeId); | ||
|
||
TString printRes = DbgPrintCell(cell, typeInfo, typeRegistry); | ||
UNIT_ASSERT_STRINGS_EQUAL(printRes, TStringBuilder() << "String : " << strVal); | ||
} | ||
|
||
{ | ||
NScheme::TTypeInfo pgTypeInfo(NPg::TypeDescFromPgTypeId(TEXTOID)); | ||
auto desc = pgTypeInfo.GetPgTypeDesc(); | ||
auto res = NPg::PgNativeBinaryFromNativeText(strVal, desc); | ||
UNIT_ASSERT_C(!res.Error, *res.Error); | ||
TString binary = res.Str; | ||
TCell pgCell((const char*)binary.data(), binary.size()); | ||
|
||
TString printRes = DbgPrintCell(pgCell, pgTypeInfo, typeRegistry); | ||
UNIT_ASSERT_STRINGS_EQUAL(printRes, TStringBuilder() << "pgtext : " << strVal); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
UNITTEST_FOR(ydb/core/scheme) | ||
|
||
FORK_SUBTESTS() | ||
|
||
SRCS( | ||
scheme_tablecell_pg_ut.cpp | ||
) | ||
|
||
PEERDIR( | ||
ydb/core/scheme | ||
ydb/library/yql/public/udf/service/exception_policy | ||
ydb/library/yql/parser/pg_wrapper | ||
) | ||
|
||
ADDINCL( | ||
ydb/library/yql/parser/pg_wrapper/postgresql/src/include | ||
) | ||
|
||
IF (OS_WINDOWS) | ||
CFLAGS( | ||
"-D__thread=__declspec(thread)" | ||
-Dfstat=microsoft_native_fstat | ||
-Dstat=microsoft_native_stat | ||
) | ||
ENDIF() | ||
|
||
NO_COMPILER_WARNINGS() | ||
|
||
YQL_LAST_ABI_VERSION() | ||
|
||
END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,5 @@ END() | |
|
||
RECURSE_FOR_TESTS( | ||
ut | ||
ut_pg | ||
) |