From 9ea3ac76a93e4256dd8926574b2225726c6744cf Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 23 Nov 2019 20:41:04 +0100 Subject: =?UTF-8?q?ResultList=20i=20brakuj=C4=85ce=20por=C3=B3wnania=20(#2?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudatlas/interpreter/InterpreterTests.java | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) (limited to 'src/test/java/pl') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java index aaac9ce..1c7be00 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java @@ -481,6 +481,132 @@ public class InterpreterTests { ); } + @Test + public void testBinopOnListResultFails() throws Exception { + assertInterpreterRun( + "SELECT max(distinct(cardinality) + num_cores) AS x", + new String[] { + } + ); + } + + @Test + public void testAggregateResultList() throws Exception { + assertInterpreterRun( + "SELECT sum(cardinality) AS cardinality; SELECT sum(distinct(cardinality)) AS dc", + new String[] { + "/uw: cardinality: 3", + "/uw: dc: 1", + "/pjwstk: cardinality: 2", + "/pjwstk: dc: 1", + "/: cardinality: 5", + "/: dc: 5" + } + ); + } + + @Test + public void testEq() throws Exception { + assertInterpreterRun( + "SELECT 1 = 1 AS oeo, 1 = 0 AS oez", + new String[] { + "/uw: oeo: true", + "/uw: oez: false", + "/pjwstk: oeo: true", + "/pjwstk: oez: false", + "/: oeo: true", + "/: oez: false" + } + ); + } + + @Test + public void testNeq() throws Exception { + assertInterpreterRun( + "SELECT 1 <> 1 AS ono, 1 <> 0 AS onz", + new String[] { + "/uw: ono: false", + "/uw: onz: true", + "/pjwstk: ono: false", + "/pjwstk: onz: true", + "/: ono: false", + "/: onz: true" + } + ); + } + + @Test + public void testLt() throws Exception { + assertInterpreterRun( + "SELECT 0 < 1 AS zlo, 1 < 1 AS olo, 1 < 0 AS olz", + new String[] { + "/uw: zlo: true", + "/uw: olo: false", + "/uw: olz: false", + "/pjwstk: zlo: true", + "/pjwstk: olo: false", + "/pjwstk: olz: false", + "/: zlo: true", + "/: olo: false", + "/: olz: false", + } + ); + } + + @Test + public void testLeq() throws Exception { + assertInterpreterRun( + "SELECT 0 <= 1 AS zlo, 1 <= 1 AS olo, 1 <= 0 AS olz", + new String[] { + "/uw: zlo: true", + "/uw: olo: true", + "/uw: olz: false", + "/pjwstk: zlo: true", + "/pjwstk: olo: true", + "/pjwstk: olz: false", + "/: zlo: true", + "/: olo: true", + "/: olz: false", + } + ); + } + + @Test + public void testGeq() throws Exception { + assertInterpreterRun( + "SELECT 0 >= 1 AS zgo, 1 >= 1 AS ogo, 1 >= 0 AS ogz", + new String[] { + "/uw: zgo: false", + "/uw: ogo: true", + "/uw: ogz: true", + "/pjwstk: zgo: false", + "/pjwstk: ogo: true", + "/pjwstk: ogz: true", + "/: zgo: false", + "/: ogo: true", + "/: ogz: true", + } + ); + } + + @Test + public void testGt() throws Exception { + assertInterpreterRun( + "SELECT 0 > 1 AS zgo, 1 > 1 AS ogo, 1 > 0 AS ogz", + new String[] { + "/uw: zgo: false", + "/uw: ogo: false", + "/uw: ogz: true", + "/pjwstk: zgo: false", + "/pjwstk: ogo: false", + "/pjwstk: ogz: true", + "/: zgo: false", + "/: ogo: false", + "/: ogz: true", + } + ); + } + private void assertInterpreterRun(String query, String[] expectedOutput) throws Exception { ByteArrayInputStream in = new ByteArrayInputStream(query.getBytes()); -- cgit v1.2.3