⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql92selectortest.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   /**    * Tests the outer logical operators AND, OR, NOT with and without brackets.     * For each data there must be a boolean value telling if the result is true or false    */   public void testLogicalOps() {      ArrayList queries = new ArrayList();      ArrayList results = new ArrayList();      boolean t = true;      boolean f = false;            // query 0      queries.add("age=23 AND city='London' AND amount<200.2");      /*  helper                 0.0.0  0.0.1  0.1.0  0.1.1  1.0.0  1.0.1  1.1.0  1.1.1  */      results.add(new boolean[] {false, false, false, false, false, false, false, true });            // query 1      queries.add("age=23 OR city='London' OR amount < 200.2");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f||f||f, f||f||t, f||t||f, f||t||t, t||f||f, t||f||t, t||t||f, t||t||t });            // query 2      queries.add("age=23 OR city='London' AND amount < 200.2");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f||f&&f, f||f&&t, f||t&&f, f||t&&t, t||f&&f, t||f&&t, t||t&&f, t||t&&t });            // query 3      queries.add("age=23 OR city='London' AND amount < 200.2");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f||f&&f, f||f&&t, f||t&&f, f||t&&t, t||f&&f, t||f&&t, t||t&&f, t||t&&t });            // query 4      queries.add("(age=23 AND city='London') OR amount < 200.2");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f&&f||f, f&&f||t, f&&t||f, f&&t||t, t&&f||f, t&&f||t, t&&t||f, t&&t||t });            // query 5      queries.add("age=23 OR (city='London' AND amount < 200.2)");      /*  helper                 0   0  0 , 0   0  1 , 0   1  0 , 0   1  1 , 1   0  0,  1   0  1 , 1   1  0 , 1   1  1  */      results.add(new boolean[] {f||(f&&f), f||(f&&t), f||(t&&f), f||(t&&t), t||(f&&f), t||(f&&t), t||(t&&f), t||(t&&t) });      // query 6      queries.add("NOT age=23 OR (city='London' AND amount < 200.2)");      /*  helper                  0   0  0 ,  0   0  1 ,  0   1  0 ,  0   1  1 ,  1   0  0 ,  1   0  1 ,  1   1  0 ,  1   1  1  */      results.add(new boolean[] {!f||(f&&f), !f||(f&&t), !f||(t&&f), !f||(t&&t), !t||(f&&f), !t||(f&&t), !t||(t&&f), !t||(t&&t) });      // query 7      queries.add("age=23 OR NOT (city='London' AND amount < 200.2)");      /*  helper                 0    0  0 , 0    0  1 , 0    1  0 , 0    1  1 , 1    0  0,  1    0  1 , 1    1  0 , 1    1  1  */      results.add(new boolean[] {f||!(f&&f), f||!(f&&t), f||!(t&&f), f||!(t&&t), t||!(f&&f), t||!(f&&t), t||!(t&&f), t||!(t&&t) });      // query 8      queries.add("(age=23 OR NOT (city='London' AND amount < 200.2))");      /*  helper                 0    0  0 , 0    0  1 , 0    1  0 , 0    1  1 , 1    0  0,  1    0  1 , 1    1  0 , 1    1  1  */      results.add(new boolean[] {f||!(f&&f), f||!(f&&t), f||!(t&&f), f||!(t&&t), t||!(f&&f), t||!(f&&t), t||!(t&&f), t||!(t&&t) });      // query 9      queries.add("NOT (age=23 OR NOT (city='London' AND amount < 200.2))");      /*  helper                   0    0  0 ,    0    0  1 ,    0    1  0 ,    0    1  1 ,    1    0  0,     1    0  1 ,    1    1  0 ,    1    1  1  */      results.add(new boolean[] {!(f||!(f&&f)), !(f||!(f&&t)), !(f||!(t&&f)), !(f||!(t&&t)), !(t||!(f&&f)), !(t||!(f&&t)), !(t||!(t&&f)), !(t||!(t&&t)) });      // query 10      queries.add("NOT (age=23 OR NOT (city='London' AND (amount < 200.2)))");      /*  helper                   0    0  0 ,    0    0  1 ,    0    1  0 ,    0    1  1 ,    1    0  0,     1    0  1 ,    1    1  0 ,    1    1  1  */      results.add(new boolean[] {!(f||!(f&&f)), !(f||!(f&&t)), !(f||!(t&&f)), !(f||!(t&&t)), !(t||!(f&&f)), !(t||!(f&&t)), !(t||!(t&&f)), !(t||!(t&&t)) });      // query 11      queries.add("age=23 OR NOT ((city='London') AND amount < 200.2)");      /*  helper                 0    0  0 , 0    0  1 , 0    1  0 , 0    1  1 , 1    0  0,  1    0  1 , 1    1  0 , 1    1  1  */      results.add(new boolean[] {f||!(f&&f), f||!(f&&t), f||!(t&&f), f||!(t&&t), t||!(f&&f), t||!(f&&t), t||!(t&&f), t||!(t&&t) });      // query 12      queries.add("age=23 OR NOT ((city='London') AND (amount < 200.2))");      /*  helper                 0    0  0 , 0    0  1 , 0    1  0 , 0    1  1 , 1    0  0,  1    0  1 , 1    1  0 , 1    1  1  */      results.add(new boolean[] {f||!(f&&f), f||!(f&&t), f||!(t&&f), f||!(t&&t), t||!(f&&f), t||!(f&&t), t||!(t&&f), t||!(t&&t) });      // query 13      queries.add("age=23 OR NOT ((city='London') AND NOT(amount < 200.2))");      /*  helper                 0    0   0 , 0    0   1 , 0    1   0 , 0    1   1 , 1    0   0,  1    0   1 , 1    1   0 , 1    1   1  */      results.add(new boolean[] {f||!(f&&!f), f||!(f&&!t), f||!(t&&!f), f||!(t&&!t), t||!(f&&!f), t||!(f&&!t), t||!(t&&!f), t||!(t&&!t) });      this.querySet = (String[])queries.toArray(new String[queries.size()]);      this.resultSet = (boolean[][])results.toArray(new boolean[results.size()][]);      // here the real testing is performed (the algorithm is the same for all tests)      selectorPerformTest();   }      /**    * Tests the NULL and NOT NULL statements.      * For each data there must be a boolean value telling if the result is true or false    */   public void testNullOps() {      ArrayList queries = new ArrayList();      ArrayList results = new ArrayList();      boolean t = true;      boolean f = false;            // query 0      queries.add("age IS NULL OR city IS NULL OR amount IS NULL");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {t||t||t, t||t||f, t||f||t, t||f||f, f||t||t, f||t||f, f||f||t, f||f||f });            // query 1      queries.add("age IS NULL AND city IS NULL AND amount IS NULL");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {t&&t&&t, t&&t&&f, t&&f&&t, t&&f&&f, f&&t&&t, f&&t&&f, f&&f&&t, f&&f&&f });            // query 2      queries.add("age IS NOT NULL OR city IS NOT NULL OR amount IS NOT NULL");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f||f||f, f||f||t, f||t||f, f||t||t, t||f||f, t||f||t, t||t||f, t||t||t });            // query 3      queries.add("age IS NOT NULL AND city IS NOT NULL AND amount IS NOT NULL");      /*  helper                 0  0  0, 0  0  1, 0  1  0, 0  1  1, 1  0  0  1  0  1  1  1  0  1  1  1  */      results.add(new boolean[] {f&&f&&f, f&&f&&t, f&&t&&f, f&&t&&t, t&&f&&f, t&&f&&t, t&&t&&f, t&&t&&t });      this.querySet = (String[])queries.toArray(new String[queries.size()]);      this.resultSet = (boolean[][])results.toArray(new boolean[results.size()][]);      // here the real testing is performed (the algorithm is the same for all tests)      selectorPerformTest();   }   /**    * Tests the outer logical operators AND, OR, NOT with and without brackets.     * For each data there must be a boolean value telling if the result is true or false    */   public void testArithmeticOps() {      ArrayList queries = new ArrayList();      ArrayList results = new ArrayList();      boolean t = true;      boolean f = false;            // query 0      queries.add("age = 15+8 AND amount < 300.0+10.0");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 1      queries.add("age = 26-3 AND amount < 300.0-10.0");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 2      queries.add("age = 23*1 AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 3      queries.add("age = 46/2 AND amount < 600.0/2.2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 4      queries.add("age = (26-3) AND amount < 300.0-10.0");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 5      queries.add("age = (23*1) AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 6      queries.add("age = 2*(26-3)-23 AND amount < 300.0-10.0");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });      // query 7      queries.add("age = -(23*1)+46 AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 8      queries.add("age = -23*1+46 AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });      // query 9      queries.add("age = 47-12*2 AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 10      queries.add("2*age = 46 AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 11      queries.add("age+6 = (27+2) AND amount < 110.0*2");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            // query 12      queries.add("age+4 = 27 AND amount < (110.0*2)");      /*  helper                 0  0, 0  1, 0  0, 0  1, 1  0  1  1  1  0  1  1  */      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, t&&f, t&&t, t&&f, t&&t });            this.querySet = (String[])queries.toArray(new String[queries.size()]);      this.resultSet = (boolean[][])results.toArray(new boolean[results.size()][]);      // here the real testing is performed (the algorithm is the same for all tests)      selectorPerformTest();   }   /**    * Tests the IN (...) statements.      * For each data there must be a boolean value telling if the result is true or false    */   public void testInSetOps() {      ArrayList queries = new ArrayList();      ArrayList results = new ArrayList();      boolean t = true;      boolean f = false;            // query 0      queries.add("age IN (25,23,30) AND city IN('London', 'Paris', 'Caslano')");      /*  helper                 0  0, 0  0, 0  1, 0  1, 1  0  1  0  1  1  1  1  */      results.add(new boolean[] {f&&f, f&&f, f&&t, f&&t, t&&f, t&&f, t&&t, t&&t });            // query 1      queries.add("age IN (23) AND city IN('London')");      /*  helper                 0  0, 0  0, 0  1, 0  1, 1  0  1  0  1  1  1  1  */      results.add(new boolean[] {f&&f, f&&f, f&&t, f&&t, t&&f, t&&f, t&&t, t&&t });            // query 2      queries.add("age IN (24,25) AND city IN('London')");      // helper : all must be false      results.add(new boolean[] {f&&f, f&&t, f&&f, f&&t, f&&f, f&&t, f&&f, f&&t });            // query 3      queries.add("age IN (23) AND city IN('Caslano', 'Paris')");      //  helper all must be false      results.add(new boolean[] {f&&f, f&&f, f&&f, f&&f, t&&f, t&&f, t&&f, t&&f });      this.querySet = (String[])queries.toArray(new String[queries.size()]);      this.resultSet = (boolean[][])results.toArray(new boolean[results.size()][]);      // here the real testing is performed (the algorithm is the same for all tests)      selectorPerformTest();   }   /**    * Tests the IN (...) statements.      * For each data there must be a boolean value telling if the result is true or false    */   public void testBetweenOps() {      ArrayList queries = new ArrayList();      ArrayList results = new ArrayList();      boolean t = true;      boolean f = false;      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -