本文整理了Java中io.prestosql.testing.assertions.Assert
类的一些代码示例,展示了Assert
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert
类的具体详情如下:
包路径:io.prestosql.testing.assertions.Assert
类名称:Assert
[英]This class provides replacements for TestNG's faulty assertion methods.
So far, the reason for having this class is the TestNG #543 - Unexpected Behaviour: assertEquals for Iterable bug, which boils down to assertEquals(Iterable, Iterable) neglecting any fields on the Iterable itself (only comparing its elements). This can lead to false positive results in tests using the faulty assertion.
[中]此类提供TestNG错误断言方法的替换。
到目前为止,拥有这个类的原因是{$0$}错误,它归结为assertEquals(Iterable,Iterable),忽略了Iterable本身的任何字段(仅比较其元素)。这可能导致在使用错误断言的测试中出现假阳性结果。
代码示例来源:origin: prestosql/presto
@Test
public void testSpecialFloatingPointValues()
{
MaterializedResult actual = computeActual("SELECT nan(), infinity(), -infinity()");
MaterializedRow row = getOnlyElement(actual.getMaterializedRows());
assertEquals(row.getField(0), Double.NaN);
assertEquals(row.getField(1), Double.POSITIVE_INFINITY);
assertEquals(row.getField(2), Double.NEGATIVE_INFINITY);
}
代码示例来源:origin: prestosql/presto
@Test
public void testLimit()
{
assertEquals(computeActual("SELECT * FROM orders LIMIT 10").getRowCount(), 10);
}
代码示例来源:origin: prestosql/presto
@Test
public void testNonDeterministicFilter()
{
MaterializedResult materializedResult = computeActual("SELECT u FROM ( SELECT if(rand() > 0.5, 0, 1) AS u ) WHERE u <> u");
assertEquals(materializedResult.getRowCount(), 0);
materializedResult = computeActual("SELECT u, v FROM ( SELECT if(rand() > 0.5, 0, 1) AS u, 4*4 AS v ) WHERE u <> u and v > 10");
assertEquals(materializedResult.getRowCount(), 0);
materializedResult = computeActual("SELECT u, v, w FROM ( SELECT if(rand() > 0.5, 0, 1) AS u, 4*4 AS v, 'abc' AS w ) WHERE v > 10");
assertEquals(materializedResult.getRowCount(), 1);
}
代码示例来源:origin: prestosql/presto
@Test
public void testDefaultExplainGraphvizFormat()
{
String query = "SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN (FORMAT GRAPHVIZ) " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getGraphvizExplainPlan(query, LOGICAL));
}
代码示例来源:origin: prestosql/presto
@Test
public void testIOExplain()
{
String query = "SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN (TYPE IO) " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan(query, IO));
}
代码示例来源:origin: prestosql/presto
@Test
public void testLogicalExplainTextFormat()
{
String query = "SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan(query, LOGICAL));
}
代码示例来源:origin: prestosql/presto
@Test
public void testDistributedExplain()
{
String query = "SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN (TYPE DISTRIBUTED) " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan(query, DISTRIBUTED));
}
代码示例来源:origin: prestosql/presto
@Test
public void testExplainOfExplainAnalyze()
{
String query = "EXPLAIN ANALYZE SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan(query, LOGICAL));
}
代码示例来源:origin: prestosql/presto
@Test
public void selectLargeInterval()
{
MaterializedResult result = computeActual("SELECT INTERVAL '30' DAY");
assertEquals(result.getRowCount(), 1);
assertEquals(result.getMaterializedRows().get(0).getField(0), new SqlIntervalDayTime(30, 0, 0, 0, 0));
result = computeActual("SELECT INTERVAL '" + Short.MAX_VALUE + "' YEAR");
assertEquals(result.getRowCount(), 1);
assertEquals(result.getMaterializedRows().get(0).getField(0), new SqlIntervalYearMonth(Short.MAX_VALUE, 0));
}
代码示例来源:origin: prestosql/presto
@Test
public void testShowCatalogsLike()
{
MaterializedResult result = computeActual(format("SHOW CATALOGS LIKE '%s'", getSession().getCatalog().get()));
assertEquals(result.getOnlyColumnAsSet(), ImmutableSet.of(getSession().getCatalog().get()));
}
代码示例来源:origin: prestosql/presto
@Test
public void testLimit()
{
MaterializedResult actual = computeActual("SELECT orderkey FROM orders LIMIT 10");
MaterializedResult all = computeExpected("SELECT orderkey FROM orders", actual.getTypes());
assertEquals(actual.getMaterializedRows().size(), 10);
assertContains(all, actual);
}
代码示例来源:origin: io.prestosql/presto-main
private static void assertPositionCount(List<Page> pages, int positionCount)
{
int totalPositionCount = 0;
for (Page page : pages) {
totalPositionCount += page.getPositionCount();
}
assertEquals(totalPositionCount, positionCount);
}
代码示例来源:origin: prestosql/presto
@Test
public void testLimitInInlineView()
{
MaterializedResult actual = computeActual("SELECT orderkey FROM (SELECT orderkey FROM orders LIMIT 100) T LIMIT 10");
MaterializedResult all = computeExpected("SELECT orderkey FROM orders", actual.getTypes());
assertEquals(actual.getMaterializedRows().size(), 10);
assertContains(all, actual);
}
代码示例来源:origin: prestosql/presto
@Test
public void testExplainSetSessionWithUsing()
{
Session session = Session.builder(getSession())
.addPreparedStatement("my_query", "SET SESSION foo = ?")
.build();
MaterializedResult result = computeActual(session, "EXPLAIN (TYPE LOGICAL) EXECUTE my_query USING 7");
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), "SET SESSION foo = 7");
}
代码示例来源:origin: prestosql/presto
@Test
public void testDescribeTable()
{
MaterializedResult actualColumns = computeActual("DESC orders").toTestTypes();
assertEquals(actualColumns, getExpectedOrdersTableDescription(isDateTypeSupported(), isParameterizedVarcharSupported()));
}
代码示例来源:origin: prestosql/presto
@Test
public void testExplainExecute()
{
Session session = Session.builder(getSession())
.addPreparedStatement("my_query", "SELECT * FROM orders")
.build();
MaterializedResult result = computeActual(session, "EXPLAIN (TYPE LOGICAL) EXECUTE my_query");
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan("SELECT * FROM orders", LOGICAL));
}
代码示例来源:origin: prestosql/presto
@Test
public void testExplainExecuteWithUsing()
{
Session session = Session.builder(getSession())
.addPreparedStatement("my_query", "SELECT * FROM orders WHERE orderkey < ?")
.build();
MaterializedResult result = computeActual(session, "EXPLAIN (TYPE LOGICAL) EXECUTE my_query USING 7");
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan("SELECT * FROM orders WHERE orderkey < 7", LOGICAL));
}
代码示例来源:origin: io.prestosql/presto-main
@Test
public void testAliasedTableColumns()
{
// https://github.com/prestodb/presto/issues/11385
// TPCH tables have a hidden "row_number" column, which triggers this bug.
assertEquals(
runner.execute("SELECT * FROM orders AS t (a, b, c, d, e, f, g, h, i)"),
runner.execute("SELECT * FROM orders"));
}
}
代码示例来源:origin: prestosql/presto
@Test
public void testShowTablesLikeWithEscape()
{
assertQueryFails("SHOW TABLES IN a LIKE '%$_%' ESCAPE", "line 1:36: mismatched input '<EOF>'. Expecting: <string>");
assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
Set<Object> allTables = computeActual("SHOW TABLES FROM information_schema").getOnlyColumnAsSet();
assertEquals(allTables, computeActual("SHOW TABLES FROM information_schema LIKE '%_%'").getOnlyColumnAsSet());
Set<Object> result = computeActual("SHOW TABLES FROM information_schema LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
assertNotEquals(allTables, result);
assertThat(result).contains("table_privileges").allMatch(schemaName -> ((String) schemaName).contains("_"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testCreateAndDropTable()
{
int tablesBeforeCreate = listMemoryTables().size();
assertUpdate("CREATE TABLE test AS SELECT * FROM tpch.tiny.nation", "SELECT count(*) FROM nation");
assertEquals(listMemoryTables().size(), tablesBeforeCreate + 1);
assertUpdate("DROP TABLE test");
assertEquals(listMemoryTables().size(), tablesBeforeCreate);
}
内容来源于网络,如有侵权,请联系作者删除!