Date: Thursday, November 10, 2005 @ 17:04:12
  Author: gilles
    Path: /cvsroot/carob/carob/test

Modified: TestStatement.cpp (1.1 -> 1.2) TestStatement.hpp (1.1 -> 1.2)

Added setMaxRows test


-------------------+
 TestStatement.cpp |   39 +++++++++++++++++++++++++++++++++++++++
 TestStatement.hpp |    6 ++++++
 2 files changed, 45 insertions(+)


Index: carob/test/TestStatement.cpp
diff -u carob/test/TestStatement.cpp:1.1 carob/test/TestStatement.cpp:1.2
--- carob/test/TestStatement.cpp:1.1    Thu Nov 10 12:03:33 2005
+++ carob/test/TestStatement.cpp        Thu Nov 10 17:04:12 2005
@@ -201,6 +201,42 @@
   delete statementPtr;
 }
 
+void TestStatement::testExecuteQueryWithMaxRows()
+{
+  wstring fctName(L"TestStatement::testExecuteQueryGood");
+  Statement* statementPtr = NULL;
+  try
+  {
+    statementPtr = connectionPtr->createStatement();
+    if (isDebugEnabled())
+    {
+      logDebug(fctName, L"Executing read");
+    }
+    statementPtr->setMaxRows(1);
+    DriverResultSet* drsPtr = statementPtr->executeQuery(
+        L"select * from address;", false);
+    logDebug(fctName, *drsPtr);
+    //Display five rows for debugging...
+//    wcerr<<L"Row\tId\tName\t\tCost"<<endl;
+    wcerr<<L"Id\tFirstName\t\tLastName"<<endl;
+    drsPtr->next();
+    int32_t* iPtr = drsPtr->getInt(1);
+    wstring* wsPtr = drsPtr->getString(2);
+    wstring* ws2Ptr = drsPtr->getString(3);
+    wcerr<<*iPtr<<L"\t"<<*wsPtr<<L"\t"<<*ws2Ptr<<endl;
+    
+    //This next() should return false because we asked just 1 row
+    CPPUNIT_ASSERT(drsPtr->next() == false);
+  }
+  catch (...)
+  {
+    if (isErrorEnabled())
+      logError(fctName, L"Catched unexpected exception");
+    CPPUNIT_ASSERT(false);
+  }
+  delete statementPtr;
+}
+
 CppUnit::Test* TestStatement::suite()
 {
   CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestStatement" );
@@ -222,6 +258,9 @@
   suiteOfTests->addTest(new CppUnit::TestCaller<TestStatement>(
                                  "testExecuteUpdateGood", 
                                  &TestStatement::testExecuteUpdateGood));
+  suiteOfTests->addTest(new CppUnit::TestCaller<TestStatement>(
+                                 "testExecuteQueryWithMaxRows", 
+                                 &TestStatement::testExecuteQueryWithMaxRows));
 
   return suiteOfTests;
 }
Index: carob/test/TestStatement.hpp
diff -u carob/test/TestStatement.hpp:1.1 carob/test/TestStatement.hpp:1.2
--- carob/test/TestStatement.hpp:1.1    Thu Nov 10 12:03:33 2005
+++ carob/test/TestStatement.hpp        Thu Nov 10 17:04:12 2005
@@ -69,6 +69,12 @@
    * that there is no error.
    */
   void testExecuteUpdateGood();
+
+  /**
+   * Tests a read with max rows to 1 and checks that the second call to next()
+   * returns false
+   */
+  void testExecuteQueryWithMaxRows();
 };
 
 #endif /*TESTSTATEMENT_H_*/

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to