db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r711579 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Date Wed, 05 Nov 2008 14:53:22 GMT
Author: rhillegas
Date: Wed Nov  5 06:53:22 2008
New Revision: 711579

URL: http://svn.apache.org/viewvc?rev=711579&view=rev
Log:
DERBY-481: Add some tests for generated columns which coerce between different length character
and numeric columns.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=711579&r1=711578&r2=711579&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Wed Nov  5 06:53:22 2008
@@ -2219,6 +2219,118 @@
              );
     }
 
+    /**
+     * <p>
+     * Test padding and truncation of character and fixed decimal data.
+     * </p>
+     */
+    public  void    test_017_padding()
+        throws Exception
+    {
+        Connection  conn = getConnection();
+
+        //
+        // Schema
+        //
+        goodStatement
+            (
+             conn,
+             "create table t_cc_char\n" +
+             "(\n" +
+             "    a char( 10 ),\n" +
+             "    b char( 5 ) generated always as( upper( a ) ),\n" +
+             "    c char( 10 ) generated always as( upper( a ) ),\n" +
+             "    d char( 15 ) generated always as( upper( a ) ),\n" +
+             "    e varchar( 5 ) generated always as( upper( a ) ),\n" +
+             "    f varchar( 10 ) generated always as( upper( a ) ),\n" +
+             "    g varchar( 15 ) generated always as( upper( a ) )\n" +
+             ")\n"
+             );
+        goodStatement
+            (
+             conn,
+             "create table t_cc_varchar\n" +
+             "(\n" +
+             "    a char( 10 ),\n" +
+             "    b char( 5 ) generated always as( upper( a ) ),\n" +
+             "    c char( 10 ) generated always as( upper( a ) ),\n" +
+             "    d char( 15 ) generated always as( upper( a ) ),\n" +
+             "    e varchar( 5 ) generated always as( upper( a ) ),\n" +
+             "    f varchar( 10 ) generated always as( upper( a ) ),\n" +
+             "    g varchar( 15 ) generated always as( upper( a ) )\n" +
+             ")\n"
+             );
+        goodStatement
+            (
+             conn,
+             "create table t_cc_decimal\n" +
+             "(\n" +
+             "    a decimal( 6, 2 ),\n" +
+             "    b decimal( 5, 1 ) generated always as ( a ),\n" +
+             "    c decimal( 5, 2 ) generated always as ( a ),\n" +
+             "    d decimal( 5, 3 ) generated always as ( a ),\n" +
+             "    e decimal( 6, 1 ) generated always as ( a ),\n" +
+             "    f decimal( 6, 2 ) generated always as ( a ),\n" +
+             "    g decimal( 6, 3 ) generated always as ( a ),\n" +
+             "    h decimal( 7, 1 ) generated always as ( a ),\n" +
+             "    i decimal( 7, 2 ) generated always as ( a ),\n" +
+             "    j decimal( 7, 3 ) generated always as ( a )\n" +
+             ")\n"
+             );
+
+        //
+        // Populate
+        //
+        goodStatement
+            (
+             conn,
+             "insert into t_cc_char( a ) values ( 'abcdefghij' )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_cc_varchar( a ) values ( 'abcdefghij' )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_cc_decimal( a ) values ( 12.345 )"
+             );
+
+        //
+        // Verify
+        //
+        assertResults
+            (
+             conn,
+             "select * from t_cc_char order by a",
+             new String[][]
+             {
+                 { "abcdefghij", "ABCDE", "ABCDEFGHIJ", "ABCDEFGHIJ     ", "ABCDE", "ABCDEFGHIJ",
"ABCDEFGHIJ", },
+             },
+             false
+             );
+        assertResults
+            (
+             conn,
+             "select * from t_cc_varchar order by a",
+             new String[][]
+             {
+                 { "abcdefghij", "ABCDE", "ABCDEFGHIJ", "ABCDEFGHIJ     ", "ABCDE", "ABCDEFGHIJ",
"ABCDEFGHIJ", },
+             },
+             false
+             );
+        assertResults
+            (
+             conn,
+             "select * from t_cc_decimal order by a",
+             new String[][]
+             {
+                 { "12.34", "12.3", "12.34", "12.340", "12.3", "12.34", "12.340", "12.3",
"12.34", "12.340", },
+             },
+             true
+             );
+    }
     
     ///////////////////////////////////////////////////////////////////////////////////
     //



Mime
View raw message