lowka commented on code in PR #3627:
URL: https://github.com/apache/ignite-3/pull/3627#discussion_r1572613224


##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/storage/CatalogEntrySerializationTest.java:
##########
@@ -144,6 +174,85 @@ void test(MarshallableEntryType type) {
         }
     }
 
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("values")
+    public void constantDefault(ColumnType columnType, Object value) throws 
IOException {
+        ConstantValue val = (ConstantValue) DefaultValue.constant(value);
+
+        log.info("{}: {}", columnType, value);
+
+        try (IgniteUnsafeDataOutput os = new IgniteUnsafeDataOutput(128)) {
+            DefaultValue.writeTo(val, os);
+
+            try (IgniteUnsafeDataInput in = new 
IgniteUnsafeDataInput(os.internalArray())) {
+                DefaultValue actual = DefaultValue.readFrom(in);
+                assertEquals(val, actual);
+            }
+        }
+    }
+
+    private static Stream<Arguments> values() {
+        List<Object> list = new ArrayList<>();
+
+        list.add(null);
+        list.add(RND.nextBoolean());
+
+        list.add((byte) RND.nextInt());
+        list.add((short) RND.nextInt());
+        list.add(RND.nextInt());
+        list.add(RND.nextLong());
+        list.add((float) RND.nextDouble());
+        list.add(RND.nextDouble());
+
+        list.add(BigDecimal.valueOf(RND.nextLong()));
+        list.add(BigDecimal.valueOf(RND.nextLong(), RND.nextInt(100)));
+
+        list.add(BigInteger.valueOf(RND.nextLong()));
+
+        list.add(LocalTime.of(RND.nextInt(24), RND.nextInt(60), 
RND.nextInt(60), RND.nextInt(100_000)));
+        list.add(LocalDate.of(RND.nextInt(4000) - 1000, RND.nextInt(12) + 1, 
RND.nextInt(27) + 1));
+        list.add(LocalDateTime.of(
+                LocalDate.of(RND.nextInt(4000) - 1000, RND.nextInt(12) + 1, 
RND.nextInt(27) + 1),
+                LocalTime.of(RND.nextInt(24), RND.nextInt(60), 
RND.nextInt(60), RND.nextInt(100_000))
+        ));
+
+        byte[] bytes = new byte[RND.nextInt(1000)];
+        RND.nextBytes(bytes);
+        list.add(Base64.getEncoder().encodeToString(bytes));
+
+        list.add(UUID.randomUUID());
+
+        // TODO Include ignored values to test after 
https://issues.apache.org/jira/browse/IGNITE-15200
+        //  list.add(Duration.of(11, ChronoUnit.HOURS));
+        //  list.add(Period.of(5, 4, 3));
+
+        BitSet bitSet = new BitSet();
+        for (int i = 0; i < RND.nextInt(100); i++) {
+            int b = RND.nextInt(1024);
+            bitSet.set(b);
+        }
+        list.add(bitSet);
+
+        return list.stream().map(val -> {
+            NativeType nativeType = NativeTypes.fromObject(val);
+            return Arguments.of(nativeType == null ? ColumnType.NULL : 
nativeType.spec().asColumnType(), val);
+        });
+    }
+
+    @Test
+    public void functionCallDefault() throws IOException{

Review Comment:
   Added prefix.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to