db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1404190 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/SQLBoolean.java testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Date Wed, 31 Oct 2012 15:13:23 GMT
Author: kahatlen
Date: Wed Oct 31 15:13:23 2012
New Revision: 1404190

URL: http://svn.apache.org/viewvc?rev=1404190&view=rev
Log:
DERBY-5971: Improve test coverage for SQLBoolean class

Remove two unused methods and add test cases for binary operators.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java?rev=1404190&r1=1404189&r2=1404190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java Wed Oct 31
15:13:23 2012
@@ -1002,28 +1002,6 @@ public final class SQLBoolean
 	}
 
 	/**
-	 * Return a false truth value.
-	 *
-	 *
-	 * @return	A SQLBoolean representing the FALSE truth value
-	 */
-	public static SQLBoolean falseTruthValue()
-	{
-		return BOOLEAN_FALSE;
-	}
-
-	/**
-	 * Return a true truth value.
-	 *
-	 *
-	 * @return	A SQLBoolean representing the TRUE truth value
-	 */
-	public static SQLBoolean trueTruthValue()
-	{
-		return BOOLEAN_TRUE;
-	}
-	
-	/**
 	 * Determine whether this SQLBoolean contains the given boolean value.
 	 *
 	 * This method is used by generated code to determine when to do

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java?rev=1404190&r1=1404189&r2=1404190&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Wed Oct 31 15:13:23 2012
@@ -1525,6 +1525,151 @@ public class BooleanValuesTest  extends 
         goodStatement( conn, "drop table alumnus" );
         goodStatement( conn, "drop table livenessChange" );
     }
+
+    /**
+     * Test that the binary operators return the expected values for all
+     * possible combinations of operands.
+     */
+    public void test_22_binary_operators() throws SQLException {
+        setAutoCommit(false);
+
+        // Create a table with two columns containing all combinations of
+        // legal boolean values.
+        Statement s = createStatement();
+        s.execute("create table combos(b1 boolean, b2 boolean)");
+        assertUpdateCount(s, 9,
+                "insert into combos select * from "
+                + "(values true, false, cast(null as boolean)) v1, "
+                + "(values true, false, cast(null as boolean)) v2");
+
+        // Equals operator (=)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 = b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "true"  },
+                    { "false", "true" , "false" },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "false" },
+                    { "true" , "true" , "true"  },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // Not equals operator (<>)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 <> b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "false" },
+                    { "false", "true" , "true"  },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "true"  },
+                    { "true" , "true" , "false" },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // Less than operator (<)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 < b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "false" },
+                    { "false", "true" , "true"  },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "false" },
+                    { "true" , "true" , "false" },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // Greater than operator (>)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 > b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "false" },
+                    { "false", "true" , "false" },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "true"  },
+                    { "true" , "true" , "false" },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // Less than or equals operator (<=)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 <= b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "true"  },
+                    { "false", "true" , "true"  },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "false" },
+                    { "true" , "true" , "true"  },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // Greater than or equals operator (>=)
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 >= b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "true"  },
+                    { "false", "true" , "false" },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "true"  },
+                    { "true" , "true" , "true"  },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false",  null   },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // AND operator
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, b1 and b2 from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "false" },
+                    { "false", "true" , "false" },
+                    { "false",  null  , "false" },
+                    { "true" , "false", "false" },
+                    { "true" , "true" , "true"  },
+                    { "true" ,  null  ,  null   },
+                    {  null  , "false", "false" },
+                    {  null  , "true" ,  null   },
+                    {  null  ,  null  ,  null   },
+                });
+
+        // OR operator
+        JDBC.assertFullResultSet(
+                s.executeQuery(
+                    "select b1, b2, (b1 or b2) from combos order by 1, 2"),
+                new String[][] {
+                    { "false", "false", "false" },
+                    { "false", "true" , "true"  },
+                    { "false",  null  ,  null   },
+                    { "true" , "false", "true"  },
+                    { "true" , "true" , "true"  },
+                    { "true" ,  null  , "true"  },
+                    {  null  , "false",  null   },
+                    {  null  , "true" , "true"  },
+                    {  null  ,  null  ,  null   },
+                });
+    }
     
     /**
      * <p>



Mime
View raw message