You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2022/01/19 22:32:43 UTC
[cassandra] 02/02: Preserve tests that use BigInt numbers
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 0dc5a289e8dd586150253d951e6e229480c0ffc8
Author: Francisco Guerrero <fr...@gmail.com>
AuthorDate: Fri Jan 14 16:13:00 2022 -0800
Preserve tests that use BigInt numbers
Patch by Francisco Guerrero; reviewed by brandonwilliams and ycai for
CASSANDRA-17133
---
.../cassandra/cql3/functions/TimeFctsTest.java | 38 ++++++++++++++++++++++
.../cql3/validation/entities/TimeuuidTest.java | 1 +
2 files changed, 39 insertions(+)
diff --git a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
index b0a4bb9..106dd70 100644
--- a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java
@@ -60,6 +60,15 @@ public class TimeFctsTest
}
@Test
+ public void testMinTimeUuidFromBigInt()
+ {
+ long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
+ ByteBuffer input = LongType.instance.decompose(timeInMillis);
+ ByteBuffer output = executeFunction(TimeFcts.minTimeuuidFct, input);
+ assertEquals(UUIDGen.minTimeUUID(timeInMillis), TimeUUIDType.instance.compose(output));
+ }
+
+ @Test
public void testMaxTimeUuid()
{
long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
@@ -69,6 +78,15 @@ public class TimeFctsTest
}
@Test
+ public void testMaxTimeUuidFromBigInt()
+ {
+ long timeInMillis = DATE_TIME.toInstant().toEpochMilli();
+ ByteBuffer input = LongType.instance.decompose(timeInMillis);
+ ByteBuffer output = executeFunction(TimeFcts.maxTimeuuidFct, input);
+ assertEquals(UUIDGen.maxTimeUUID(timeInMillis), TimeUUIDType.instance.compose(output));
+ }
+
+ @Test
public void testDateOf()
{
@@ -142,6 +160,16 @@ public class TimeFctsTest
}
@Test
+ public void testBigIntegerToDate()
+ {
+ long millis = DATE.toInstant().toEpochMilli();
+
+ ByteBuffer input = LongType.instance.decompose(millis);
+ ByteBuffer output = executeFunction(toDate(TimestampType.instance), input);
+ assertEquals(DATE.toInstant().toEpochMilli(), SimpleDateType.instance.toTimeInMillis(output));
+ }
+
+ @Test
public void testTimestampToDateWithEmptyInput()
{
ByteBuffer output = executeFunction(toDate(TimestampType.instance), ByteBufferUtil.EMPTY_BYTE_BUFFER);
@@ -157,6 +185,16 @@ public class TimeFctsTest
}
@Test
+ public void testBigIntegerToTimestamp()
+ {
+ long millis = DATE_TIME.toInstant().toEpochMilli();
+
+ ByteBuffer input = LongType.instance.decompose(millis);
+ ByteBuffer output = executeFunction(toTimestamp(TimestampType.instance), input);
+ assertEquals(DATE_TIME.toInstant().toEpochMilli(), LongType.instance.compose(output).longValue());
+ }
+
+ @Test
public void testTimestampToUnixTimestampWithEmptyInput()
{
ByteBuffer output = executeFunction(TimeFcts.toUnixTimestamp(TimestampType.instance), ByteBufferUtil.EMPTY_BYTE_BUFFER);
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
index 0f1f8f0..178da6a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
@@ -65,6 +65,7 @@ public class TimeuuidTest extends CQLTester
}
assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1234567) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
+ assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1564830182000) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org