List:Commits« Previous MessageNext Message »
From:sebrecht Date:May 14 2007 1:11pm
Subject:ODBC C-tests commit: r104 - trunk/testsuites/t_bugs_time
View as plain text  
Added:
   trunk/testsuites/t_bugs_time/cleantest.c
   trunk/testsuites/t_bugs_time/createtable.c
Modified:
   trunk/testsuites/t_bugs_time/bug_12520.c
   trunk/testsuites/t_bugs_time/bug_25846.c
   trunk/testsuites/t_bugs_time/t_bugs_time_suite.c
   trunk/testsuites/t_bugs_time/t_bugs_time_suite.h
Log:
fix bug in test syntax



Modified: trunk/testsuites/t_bugs_time/bug_12520.c
===================================================================
--- trunk/testsuites/t_bugs_time/bug_12520.c	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/bug_12520.c	2007-05-14 11:11:56 UTC (rev 104)
@@ -3,35 +3,39 @@
 
 OT_TEST_METHOD(bug_12520_test1) 
 {
-    SQLHANDLE            stmt = get_statement();
-    SQLINTEGER           my_time_cb;
-    SQLINTEGER           my_date_cb;
-    SQL_TIMESTAMP_STRUCT my_time_ts;
-    SQL_TIMESTAMP_STRUCT my_date_ts;
+test_printf("ghi\n");
+ SQLHANDLE            stmt = get_statement();
+ SQLINTEGER           my_time_cb;
+ SQLINTEGER           my_date_cb;
+ SQL_TIMESTAMP_STRUCT my_time_ts;
+ SQL_TIMESTAMP_STRUCT my_date_ts;
     
-	SQLLEN				len;
-	char				datetime[50];
+ SQLLEN				len;
+ char				datetime[50];
 
-    CHECK_SQL_S(SQLExecDirect(stmt, 
-        "INSERT INTO bug12520 (c) values (1)", SQL_NTS), stmt);
+ CHECK_SQL_S(SQLExecDirect(stmt, 
+			   "INSERT INTO bug12520 (c) values (1)",
+			   SQL_NTS), stmt);
 
-    reset_statement(stmt);    
+ reset_statement(stmt);    
 
-    CHECK_SQL_S(SQLExecDirect(stmt, 
-        "SELECT a,b FROM bug12520", SQL_NTS), stmt);
+ CHECK_SQL_S(SQLExecDirect(stmt, 
+			   "SELECT a,b FROM bug12520", 
+			   SQL_NTS), stmt);
 
-    /* Bind the TIMESTAMP buffer for TIME column */
-    CHECK_SQL_S(SQLBindCol(stmt, 1, SQL_C_CHAR, 
-        &datetime, 50, &len), stmt);
+   /* Bind the TIMESTAMP buffer for TIME column */
+ CHECK_SQL_S(SQLBindCol(stmt, 1, SQL_C_CHAR, 
+			&datetime, 50, &len), stmt);
 
-    CHECK_SQL_S(SQLBindCol(stmt, 2, SQL_C_TIMESTAMP, 
-        &my_time_ts, sizeof(my_time_ts), &my_time_cb), stmt);
+ CHECK_SQL_S(SQLBindCol(stmt, 2, SQL_C_TIMESTAMP, 
+			&my_time_ts, sizeof(my_time_ts),
+			&my_time_cb), stmt);
 
-    CHECK_SQL_S(SQLFetch(stmt), stmt);
+ CHECK_SQL_S(SQLFetch(stmt), stmt);
 
-	OT_ASSERT_STR_MSG("Unexpected date", "0000-00-00 00:00:00", datetime);
-	OT_ASSERT_INT_MSG("Unexpected length", SQL_NULL_DATA, my_time_cb);
+ OT_ASSERT_STR_MSG("Unexpected date", "0000-00-00 00:00:00", datetime);
+ OT_ASSERT_INT_MSG("Unexpected length", SQL_NULL_DATA, my_time_cb);
 
 
-    free_statement(stmt);    
+ free_statement(stmt);
 }

Modified: trunk/testsuites/t_bugs_time/bug_25846.c
===================================================================
--- trunk/testsuites/t_bugs_time/bug_25846.c	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/bug_25846.c	2007-05-14 11:11:56 UTC (rev 104)
@@ -1,103 +1,112 @@
 #include "t_bugs_time_suite.h"
 
 
-OT_TEST_METHOD(bug_25846_test1) 
+OT_TEST_METHOD(bug_25846_test1)
 {
-    SQLHANDLE            stmt = get_statement();
+ SQLHANDLE            stmt = get_statement();
     
-    SQLSMALLINT          column_count;
-    SQLLEN               my_time_cb;
-    SQLLEN               my_date_cb;
-    SQL_TIMESTAMP_STRUCT my_time_ts;
-    SQL_TIMESTAMP_STRUCT my_date_ts;
+ SQLSMALLINT          column_count;
+ SQLLEN               my_time_cb;
+ SQLLEN               my_date_cb;
+ SQL_TIMESTAMP_STRUCT my_time_ts;
+ SQL_TIMESTAMP_STRUCT my_date_ts;
     
-    struct tm           *current_ts;
-    time_t               sec_time;
+ struct tm           *current_ts;
+ time_t               sec_time;
 
-    /* Insert any not 00 time and current date */
-    CHECK_SQL_S(SQLExecDirect(stmt, 
-        "INSERT INTO my_time_tab (ID, my_time, my_date) \
-         VALUES (0, '15:45:30', CURDATE())", SQL_NTS), stmt);
+ /* Insert any not 00 time and current date */
+ CHECK_SQL_S(SQLExecDirect(stmt, 
+			   "INSERT INTO my_time_tab (ID, my_time, my_date) VALUES (0, '15:45:30', CURDATE())",

+			   SQL_NTS), stmt);
 
-    reset_statement(stmt);    
+ reset_statement(stmt);    
 
-    CHECK_SQL_S(SQLExecDirect(stmt, 
-        "SELECT ID, my_time, my_date FROM my_time_tab", SQL_NTS), stmt);
+ CHECK_SQL_S(SQLExecDirect(stmt, 
+			   "SELECT ID, my_time, my_date FROM my_time_tab",
+			   SQL_NTS), stmt);
 
-    CHECK_SQL_S(SQLNumResultCols(stmt, &column_count), stmt);
+ CHECK_SQL_S(SQLNumResultCols(stmt, &column_count), stmt);
 
-    /* Bind the TIMESTAMP buffer for TIME column */
-    CHECK_SQL_S(SQLBindCol(stmt, 2, SQL_C_TIMESTAMP, 
-        &my_time_ts, sizeof(my_time_ts), &my_time_cb), stmt);
+ /* Bind the TIMESTAMP buffer for TIME column */
+ CHECK_SQL_S(SQLBindCol(stmt, 2, SQL_C_TIMESTAMP, 
+			&my_time_ts, sizeof(my_time_ts), 
+			&my_time_cb), stmt);
 
-    /* Bind the TIMESTAMP buffer for DATE column */
-    CHECK_SQL_S(SQLBindCol(stmt, 3, SQL_C_TIMESTAMP, 
-        &my_date_ts, sizeof(my_date_ts), &my_date_cb), stmt);
+ /* Bind the TIMESTAMP buffer for DATE column */
+ CHECK_SQL_S(SQLBindCol(stmt, 3, SQL_C_TIMESTAMP, 
+			&my_date_ts, sizeof(my_date_ts), 
+			&my_date_cb), stmt);
 
-    CHECK_SQL_S(SQLFetch(stmt), stmt);
+ CHECK_SQL_S(SQLFetch(stmt), stmt);
 
-    sec_time= time(NULL);
-    current_ts= localtime(&sec_time);
+ sec_time= time(NULL);
+ current_ts= localtime(&sec_time);
     
-    OT_ASSERT_INT_MSG("Unexpected value of hours",   15, my_time_ts.hour);
-    OT_ASSERT_INT_MSG("Unexpected value of minutes", 45, my_time_ts.minute);
-    OT_ASSERT_INT_MSG("Unexpected value of seconds", 30, my_time_ts.second);
+ OT_ASSERT_INT_MSG("Unexpected value of hours",   15, my_time_ts.hour);
+ OT_ASSERT_INT_MSG("Unexpected value of minutes", 45, my_time_ts.minute);
+ OT_ASSERT_INT_MSG("Unexpected value of seconds", 30, my_time_ts.second);
 
-    /* Most cases when we are not testin at 12:00 AM */
-    if (my_time_ts.day == current_ts->tm_mday)
-    {
-        /* Check the current year and TIMESTAMP year from TIME column */
-        OT_ASSERT_INT_MSG("Unexpected value of years", 
-            (current_ts->tm_year + 1900), my_time_ts.year);
+   /* Most cases when we are not testin at 12:00 AM */
+ if (my_time_ts.day == current_ts->tm_mday)
+   {
+     /* Check the current year and TIMESTAMP year from TIME column */
+     OT_ASSERT_INT_MSG("Unexpected value of years", 
+		       (current_ts->tm_year + 1900), 
+		       my_time_ts.year);
 
-        /* Check the current year and TIMESTAMP year from DATE column */
-        OT_ASSERT_INT_MSG("Unexpected value of years", 
-            (current_ts->tm_year + 1900), my_date_ts.year);
+     /* Check the current year and TIMESTAMP year from DATE column */
+     OT_ASSERT_INT_MSG("Unexpected value of years", 
+		       (current_ts->tm_year + 1900),
+		       my_date_ts.year);
 
-        /* Check the current month and TIMESTAMP month from TIME column */
-        OT_ASSERT_INT_MSG("Unexpected value of months", 
-            (current_ts->tm_mon + 1), my_time_ts.month);
+     /* Check the current month and TIMESTAMP month from TIME column */
+     OT_ASSERT_INT_MSG("Unexpected value of months", 
+		       (current_ts->tm_mon + 1),
+		       my_time_ts.month);
 
-        /* Check the current month and TIMESTAMP month from DATE column */
-        OT_ASSERT_INT_MSG("Unexpected value of months", 
-            (current_ts->tm_mon + 1), my_date_ts.month);
+     /* Check the current month and TIMESTAMP month from DATE column */
+     OT_ASSERT_INT_MSG("Unexpected value of months", 
+		       (current_ts->tm_mon + 1),
+		       my_date_ts.month);
 
-        /* Check the current day and TIMESTAMP day from TIME column */
-        OT_ASSERT_INT_MSG("Unexpected value of days", 
-            current_ts->tm_mday, my_time_ts.day);
+     /* Check the current day and TIMESTAMP day from TIME column */
+     OT_ASSERT_INT_MSG("Unexpected value of days", 
+		       current_ts->tm_mday, 
+		       my_time_ts.day);
 
-        /* Check the current day and TIMESTAMP day from DATE column */
-        OT_ASSERT_INT_MSG("Unexpected value of days", 
-            current_ts->tm_mday, my_date_ts.day);
+     /* Check the current day and TIMESTAMP day from DATE column */
+     OT_ASSERT_INT_MSG("Unexpected value of days", 
+		       current_ts->tm_mday,
+		       my_date_ts.day);
 
-    }
-    else
-    {
-        /* Check the current year and TIMESTAMP year from TIME column */
-        OT_ASSERT_MSG("Unexpected value of years", 
-            (current_ts->tm_year + 1900) >= my_time_ts.year);
+   }
+ else
+   {
+     /* Check the current year and TIMESTAMP year from TIME column */
+     OT_ASSERT_MSG("Unexpected value of years", 
+		   (current_ts->tm_year + 1900) >= my_time_ts.year);
 
-        /* Check the year from TIME and from DATE columns */
-        OT_ASSERT_MSG("Unexpected value of years", 
-            my_time_ts.year >= my_date_ts.year);
+     /* Check the year from TIME and from DATE columns */
+     OT_ASSERT_MSG("Unexpected value of years", 
+		   my_time_ts.year >= my_date_ts.year);
 
-        /* Check the current month and TIMESTAMP month from TIME column */
-        OT_ASSERT_MSG("Unexpected value of months", 
-            (current_ts->tm_mon + 1) >= my_time_ts.month);
+     /* Check the current month and TIMESTAMP month from TIME column */
+     OT_ASSERT_MSG("Unexpected value of months", 
+		   (current_ts->tm_mon + 1) >= my_time_ts.month);
 
-        /* Check the month from TIME and from DATE columns */
-        OT_ASSERT_MSG("Unexpected value of months", 
-            my_time_ts.month >= my_date_ts.month);
+     /* Check the month from TIME and from DATE columns */
+     OT_ASSERT_MSG("Unexpected value of months", 
+		   my_time_ts.month >= my_date_ts.month);
 
-        /* Check the current day and TIMESTAMP day from TIME column */
-        OT_ASSERT_MSG("Unexpectedul  value of days", 
-            current_ts->tm_mday >= my_time_ts.day);
+     /* Check the current day and TIMESTAMP day from TIME column */
+     OT_ASSERT_MSG("Unexpectedul  value of days", 
+		   current_ts->tm_mday >= my_time_ts.day);
 
-        /* Check the day from TIME and from DATE columns */
-        OT_ASSERT_MSG("Unexpected value of days", 
-            my_time_ts.day >= my_date_ts.day);
+     /* Check the day from TIME and from DATE columns */
+     OT_ASSERT_MSG("Unexpected value of days", 
+		   my_time_ts.day >= my_date_ts.day);
 
-    }
+   }
 
-    free_statement(stmt);    
+ free_statement(stmt);
 }

Added: trunk/testsuites/t_bugs_time/cleantest.c
===================================================================
--- trunk/testsuites/t_bugs_time/cleantest.c	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/cleantest.c	2007-05-14 11:11:56 UTC (rev 104)
@@ -0,0 +1,26 @@
+/* ******************************************
+ * This test is just to clean the database.
+ * All created tables, that are used during
+ * the tests, will be dropped.
+ *
+ * created: 05/14/2007 susanne
+
+ ****************************************** */
+
+#include "t_bugs_time_suite.h"
+
+OT_TEST_METHOD(cleantest) 
+{
+  SQLHANDLE stmt;
+  stmt = get_statement();
+
+  CHECK_SQL_S(SQLExecDirect(stmt, 
+			    "DROP TABLE IF EXISTS my_time_tab", 
+			    SQL_NTS), stmt);
+  reset_statement(stmt);
+  CHECK_SQL_S(SQLExecDirect(stmt, 
+			    "drop table if exists bug12520", 
+			    SQL_NTS), stmt);
+  free_statement(stmt);
+}
+

Added: trunk/testsuites/t_bugs_time/createtable.c
===================================================================
--- trunk/testsuites/t_bugs_time/createtable.c	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/createtable.c	2007-05-14 11:11:56 UTC (rev 104)
@@ -0,0 +1,38 @@
+/* ******************************************
+ * This test is just necessary to create the
+ * database test tables for the bug time 
+ * tests.
+ * If the table still exist, it'll dropped 
+ * first.
+ * This tables will be created:
+ * my_time_tab
+ * bug12520
+ *
+ * created: 05/14/2007 susanne
+
+ ****************************************** */
+
+#include "t_bugs_time_suite.h"
+
+OT_TEST_METHOD(createtable) 
+{
+  SQLHANDLE stmt;  
+  stmt = get_statement();
+    
+  CHECK_SQL_S(SQLExecDirect(stmt, 
+			    "DROP TABLE IF EXISTS my_time_tab", 
+			    SQL_NTS), stmt);
+  reset_statement(stmt);
+  CHECK_SQL_S(SQLExecDirect(stmt, 
+			    "CREATE TABLE my_time_tab (ID INT PRIMARY KEY, my_time TIME, my_date DATE)",
+			    SQL_NTS), stmt);
+  reset_statement(stmt);
+  CHECK_SQL_S(SQLExecDirect(stmt, 
+			    "DROP TABLE IF EXISTS bug12520", 
+			    SQL_NTS), stmt);
+  reset_statement(stmt);
+  CHECK_SQL_S(SQLExecDirect(stmt,
+			    "CREATE TABLE bug12520 ( a DATETIME default '0000-00-00 00:00', b DATETIME default
'0000-00-00 00:00', c  int)", 
+			    SQL_NTS), stmt);
+  free_statement(stmt);
+}

Modified: trunk/testsuites/t_bugs_time/t_bugs_time_suite.c
===================================================================
--- trunk/testsuites/t_bugs_time/t_bugs_time_suite.c	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/t_bugs_time_suite.c	2007-05-14 11:11:56 UTC (rev 104)
@@ -1,41 +1,22 @@
 #include "t_bugs_time_suite.h"
 
 
-OT_TEST_SETUP(bugs_time_setup) 
+OT_SUITE_SETUP(bugs_time_setup) 
 {  
-  SQLHANDLE stmt;  
-  OT_ASSERT(global_connect());
-  stmt = get_statement(); 
-    
-  CHECK_SQL_S(SQLExecDirect(stmt, 
-      "DROP TABLE IF EXISTS my_time_tab", SQL_NTS), stmt);
-
-  CHECK_SQL_S(SQLExecDirect(stmt, 
-      "CREATE TABLE my_time_tab (ID INT PRIMARY KEY, \
-       my_time TIME, my_date DATE)", SQL_NTS), stmt);
-
-  CHECK_SQL_S(SQLExecDirect(stmt, 
-      "DROP TABLE IF EXISTS bug12520", SQL_NTS), stmt);
-
-  CHECK_SQL_S(SQLExecDirect(stmt, 
-      "CREATE TABLE bug12520 ( a DATETIME default '0000-00-00 00:00', \
-      b DATETIME default '0000-00-00 00:00', \
-      c  int)", SQL_NTS), stmt);
-	free_statement(stmt);
+  if (!global_connect())
+    return "Cannot create global connection!";
+  else
+    return NULL;
 }	
 
-OT_TEST_TEARDOWN(bugs_time_teardown)
+OT_SUITE_TEARDOWN(bugs_time_teardown)
 {  
-  SQLHANDLE stmt = get_statement();
-
-  CHECK_SQL_S(SQLExecDirect(stmt, "DROP TABLE IF EXISTS my_time_tab", SQL_NTS), stmt);
-/* CHECK_SQL_S(SQLExecDirect(stmt, "drop table if exists bug12520", SQL_NTS), stmt); */
-	free_statement(stmt);
-
   global_disconnect();
 }
 
-OT_SUITE_REGISTER_START("bugs_time", NULL, NULL)
-  OT_SUITE_ADD_TEST(bug_12520_test1, bugs_time_setup, bugs_time_teardown);
-  OT_SUITE_ADD_TEST(bug_25846_test1, bugs_time_setup, bugs_time_teardown);
+OT_SUITE_REGISTER_START("bugs_time", bugs_time_setup, bugs_time_teardown)
+     OT_SUITE_ADD_TEST(createtable, NULL, NULL);
+     OT_SUITE_ADD_TEST(bug_12520_test1, NULL, NULL);
+OT_SUITE_ADD_TEST(bug_25846_test1, NULL, NULL);
+     OT_SUITE_ADD_TEST(cleantest, NULL, NULL);
 OT_SUITE_REGISTER_END

Modified: trunk/testsuites/t_bugs_time/t_bugs_time_suite.h
===================================================================
--- trunk/testsuites/t_bugs_time/t_bugs_time_suite.h	2007-05-08 12:40:59 UTC (rev 103)
+++ trunk/testsuites/t_bugs_time/t_bugs_time_suite.h	2007-05-14 11:11:56 UTC (rev 104)
@@ -1,9 +1,12 @@
 #include "odbctest.h"
 
 /* Unit testing overhead ;-) */
-OT_TEST_SETUP(bugs_time_setup);
-OT_TEST_TEARDOWN(bugs_time_teardown);
+/*OT_TEST_SETUP(bugs_time_setup);
+  OT_TEST_TEARDOWN(bugs_time_teardown);*/
 
 /* bug_25846.c */
+OT_TEST_METHOD(createtable);
 OT_TEST_METHOD(bug_25846_test1);
 OT_TEST_METHOD(bug_12520_test1);
+OT_TEST_METHOD(cleantest);
+

Thread
ODBC C-tests commit: r104 - trunk/testsuites/t_bugs_timesebrecht14 May