From 3d3d295301473f4ba41c9dfa859e140bcbbf2ba2 Mon Sep 17 00:00:00 2001 From: tianchen Date: Wed, 25 Sep 2019 10:32:42 +0800 Subject: [PATCH] add test --- .../compare/TestRangeEqualsVisitor.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/java/vector/src/test/java/org/apache/arrow/vector/compare/TestRangeEqualsVisitor.java b/java/vector/src/test/java/org/apache/arrow/vector/compare/TestRangeEqualsVisitor.java index 04d73e231cda2..6cfd70ddc7732 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/compare/TestRangeEqualsVisitor.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/compare/TestRangeEqualsVisitor.java @@ -86,6 +86,31 @@ public void testIntVectorEqualsWithNull() { } } + @Test + public void testEqualsWithTypeChange() { + try (final IntVector vector1 = new IntVector("intVector1", allocator); + final IntVector vector2 = new IntVector("intVector2", allocator); + final BigIntVector vector3 = new BigIntVector("bigIntVector", allocator)) { + + vector1.allocateNew(2); + vector1.setValueCount(2); + vector2.allocateNew(2); + vector2.setValueCount(2); + + vector1.setSafe(0, 1); + vector1.setSafe(1, 2); + + vector2.setSafe(0, 1); + vector2.setSafe(1, 2); + + RangeEqualsVisitor visitor = new RangeEqualsVisitor(vector1, vector2); + Range range = new Range(0, 0, 2); + assertTrue(vector1.accept(visitor, range)); + // visitor left vector changed, will reset and check type again + assertFalse(vector3.accept(visitor, range)); + } + } + @Test public void testBaseFixedWidthVectorRangeEqual() { try (final IntVector vector1 = new IntVector("int", allocator);