Skip to content

Commit

Permalink
Fix assertSorted
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored and tdcmeehan committed Apr 22, 2024
1 parent 6d052a3 commit 17a6feb
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

Expand Down Expand Up @@ -1025,9 +1026,7 @@ public void testDistinctLimitInternal(Session session)
assertQuerySucceeds(session, "SELECT DISTINCT custkey FROM orders LIMIT 10000");

assertQuery(session, "" +
"SELECT DISTINCT x " +
"FROM (VALUES 1) t(x) JOIN (VALUES 10, 20) u(a) ON t.x < u.a " +
"LIMIT 100",
"SELECT DISTINCT x FROM (VALUES 1) t(x) JOIN (VALUES 10, 20) u(a) ON t.x < u.a LIMIT 100",
"SELECT 1");
}

Expand Down Expand Up @@ -2677,15 +2676,15 @@ public void testShowCatalogsLikeWithEscape()
{
try {
MaterializedResult result = computeActual(getSession(), "SHOW CATALOGS LIKE 't$_%' ESCAPE ''");
assertTrue(false);
fail();
}
catch (Exception e) {
assertEquals("Escape string must be a single character", e.getMessage());
}

try {
MaterializedResult result = computeActual(getSession(), "SHOW CATALOGS LIKE 't$_%' ESCAPE '$$'");
assertTrue(false);
fail();
}
catch (Exception e) {
assertEquals("Escape string must be a single character", e.getMessage());
Expand Down Expand Up @@ -3035,15 +3034,15 @@ public void testShowSession()

try {
computeActual(session, "SHOW SESSION LIKE 't$_%' ESCAPE ''");
assertTrue(false);
fail();
}
catch (Exception e) {
assertEquals("Escape string must be a single character", e.getMessage());
}

try {
computeActual(session, "SHOW SESSION LIKE 't$_%' ESCAPE '$$'");
assertTrue(false);
fail();
}
catch (Exception e) {
assertEquals("Escape string must be a single character", e.getMessage());
Expand Down Expand Up @@ -7261,21 +7260,19 @@ public void testArraySort()
assertSorted(result.getMaterializedRows().get(0).getFields());
}

private static boolean assertSorted(List<Object> array)
private static void assertSorted(List<Object> array)
{
int i = 1;
for (; i < array.size(); i++) {
if (array.get(i) == null) {
break;
}
assertThat(((Comparable) array.get(i)).compareTo((Comparable) array.get(i - 1)) >= 0);
assertTrue(((Comparable) array.get(i)).compareTo((Comparable) array.get(i - 1)) >= 0);
}

while (i < array.size()) {
assertThat(array.get(i++) == null);
assertNull(array.get(i++));
}

return true;
}

@Test
Expand Down

0 comments on commit 17a6feb

Please sign in to comment.