aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
commit31773f157bf8164364649b5f470f52dece0a4317 (patch)
tree33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql
parent2c7938962d8689e175574fc1e817c05049f27905 (diff)
parenteff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff)
downloadydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql')
-rw-r--r--yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql82
1 files changed, 82 insertions, 0 deletions
diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql
new file mode 100644
index 0000000000..aa9ed74d8f
--- /dev/null
+++ b/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql
@@ -0,0 +1,82 @@
+(
+#comment
+(let config (DataSource 'config))
+(let world (Configure! world config 'PureDataSource 'yt))
+
+(let res_sink (DataSink 'result))
+
+(let test (lambda '(world data dataType) (block '(
+ (let world (Write! world res_sink (Key) (ToBytes data) '('('type))))
+ (let world (Write! world res_sink (Key) (FromBytes (ToBytes data) dataType) '('('type))))
+ (return world)
+))))
+
+(let testEmpty (lambda '(world dataType) (block '(
+ (let n (ToBytes (Nothing (OptionalType (DataType dataType)))))
+ (let world (Write! world res_sink (Key) n '('('type))))
+ (let world (Write! world res_sink (Key) (FromBytes n dataType) '('('type))))
+ (return world)
+))))
+
+(let testFail (lambda '(world bytes dataType) (block '(
+ (let world (Write! world res_sink (Key) (Exists (FromBytes bytes dataType)) '('('type))))
+ (return world)
+))))
+
+(let world (Apply test world (Uint8 '7) 'Uint8))
+(let world (Apply test world (Bool 'True) 'Bool))
+(let world (Apply test world (Bool 'False) 'Bool))
+(let world (Apply test world (Int32 'x"abcdef12") 'Int32))
+(let world (Apply test world (Int64 'x"71717171abcdef12") 'Int64))
+(let world (Apply test world (Uint32 'x"abcdef12") 'Uint32))
+(let world (Apply test world (Uint64 'x"ddddddddabcdef12") 'Uint64))
+(let world (Apply test world (Float '2) 'Float))
+(let world (Apply test world (Double '2) 'Double))
+(let world (Apply test world (String '"abc") 'String))
+(let world (Apply test world (Utf8 '"яндекс") 'Utf8))
+(let world (Apply test world (Yson '"[1;2]") 'Yson))
+(let world (Apply test world (Json '@@{"id":1}@@) 'Json))
+
+(let world (Apply test world (Just (Uint8 '7)) 'Uint8))
+(let world (Apply test world (Just (Bool 'True)) 'Bool))
+(let world (Apply test world (Just (Bool 'False)) 'Bool))
+(let world (Apply test world (Just (Int32 'x"abcdef12")) 'Int32))
+(let world (Apply test world (Just (Int64 'x"71717171abcdef12")) 'Int64))
+(let world (Apply test world (Just (Uint32 'x"abcdef12")) 'Uint32))
+(let world (Apply test world (Just (Uint64 'x"ddddddddabcdef12")) 'Uint64))
+(let world (Apply test world (Just (Float '2)) 'Float))
+(let world (Apply test world (Just (Double '2)) 'Double))
+(let world (Apply test world (Just (String '"abc")) 'String))
+(let world (Apply test world (Just (Utf8 '"яндекс")) 'Utf8))
+(let world (Apply test world (Just (Yson '"[1;2]")) 'Yson))
+(let world (Apply test world (Just (Json '@@{"id":1}@@)) 'Json))
+
+(let world (Apply testEmpty world 'Uint8))
+(let world (Apply testEmpty world 'Bool))
+(let world (Apply testEmpty world 'Int32))
+(let world (Apply testEmpty world 'Int64))
+(let world (Apply testEmpty world 'Uint32))
+(let world (Apply testEmpty world 'Uint64))
+(let world (Apply testEmpty world 'Float))
+(let world (Apply testEmpty world 'Double))
+(let world (Apply testEmpty world 'String))
+(let world (Apply testEmpty world 'Utf8))
+(let world (Apply testEmpty world 'Yson))
+(let world (Apply testEmpty world 'Json))
+
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint8))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Bool))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int32))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int64))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint32))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint64))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Float))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Double))
+(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'String))
+(let world (Apply testFail world (String 'x"ffff") 'Utf8))
+(let world (Apply testFail world (String '"][") 'Yson))
+(let world (Apply testFail world (String '"}{") 'Json))
+
+(let world (Commit! world res_sink))
+(return world)
+)