Date: Friday, December 16, 2005 @ 22:24:28
Author: marc
Path: /cvsroot/carob/carob/test
Added: 30-ResultSet/TestSimpleUnicode.cpp (1.1)
30-ResultSet/TestSimpleUnicode.hpp (1.1)
Modified: CarobTestLauncher.cpp (1.13 -> 1.14) GNUmakefile (1.15 -> 1.16)
Added TestSimpleUnicode
------------------------------------+
30-ResultSet/TestSimpleUnicode.cpp | 102 +++++++++++++++++++++++++++++++++++
30-ResultSet/TestSimpleUnicode.hpp | 41 ++++++++++++++
CarobTestLauncher.cpp | 5 +
GNUmakefile | 4 +
4 files changed, 151 insertions(+), 1 deletion(-)
Index: carob/test/30-ResultSet/TestSimpleUnicode.cpp
diff -u /dev/null carob/test/30-ResultSet/TestSimpleUnicode.cpp:1.1
--- /dev/null Fri Dec 16 22:24:28 2005
+++ carob/test/30-ResultSet/TestSimpleUnicode.cpp Fri Dec 16 22:24:28 2005
@@ -0,0 +1,102 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Marc Herbert
+ * Contributor(s):
+ */
+
+#include "Common.hpp"
+#include "CarobException.hpp"
+#include "DriverResultSet.hpp"
+#include "Statement.hpp"
+
+
+#include "TestSimpleUnicode.hpp"
+
+#define TABLE_NAME L"unicodebasic"
+
+#define DEFAULT_SQL_STRING_TYPE L"VARCHAR(200)"
+#define TABLE_TYPE "(teststring " DEFAULT_SQL_STRING_TYPE L")"
+
+
+using namespace CarobNS;
+
+using std::wstring;
+
+// warning: some DBMS (e.g., PostgreSQL) support only C-style, Null Terminated
Strings.
+
+namespace {
+
+ // PBK
+ // phi beta kappa + zero + last character (kappa) again
+ wchar_t wide_pbk_[] = { 0x03c6, 0x03b2, 0x03ba };
+ // this is is even more evil (see SEQUOIA-133)
+// wchar_t wide_pbk_[] = { 0x03c6, 0x03b2, 0x03ba, 0, 0x03ba };
+ wstring wide_pbk(wide_pbk_, 3);
+}
+
+void TestSimpleUnicode::testBasic()
+{
+ std::wstring fctName(L"TestSimpleUnicode::testBasic");
+
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, L"Executing replace table " TABLE_NAME L" "
TABLE_TYPE);
+ }
+
+ createOrReplaceTable(connectionPtr, TABLE_NAME, TABLE_TYPE);
+
+ Statement *stmt = connectionPtr->createStatement();
+
+ wstring insertcmd(L"INSERT INTO " TABLE_NAME " values ('");
+ insertcmd += wide_pbk;
+ insertcmd += L"')";
+
+ int updatecount = stmt->executeUpdate(insertcmd);
+ CPPUNIT_ASSERT(1 == updatecount);
+
+ return;
+
+ DriverResultSet* drsPtr = stmt->executeQuery(L"SELECT * FROM " TABLE_NAME);
+ CPPUNIT_ASSERT(drsPtr->next());
+
+ wstring returned_pbk = drsPtr->getString(1);
+ CPPUNIT_ASSERT(0 == wide_pbk.compare(returned_pbk));
+
+ CPPUNIT_ASSERT(!drsPtr->next());
+
+ delete stmt; // take cares of drsPtr
+}
+
+// List of tests in this class
+CppUnit::Test* TestSimpleUnicode::suite()
+{
+ CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestExecReadRequest" );
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestSimpleUnicode>(
+ "testBasic", &TestSimpleUnicode::testBasic));
+
+ return suiteOfTests;
+}
+
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: carob/test/30-ResultSet/TestSimpleUnicode.hpp
diff -u /dev/null carob/test/30-ResultSet/TestSimpleUnicode.hpp:1.1
--- /dev/null Fri Dec 16 22:24:28 2005
+++ carob/test/30-ResultSet/TestSimpleUnicode.hpp Fri Dec 16 22:24:28 2005
@@ -0,0 +1,41 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Marc Herbert
+ * Contributor(s):
+ */
+
+#ifndef TESTSIMPLEUNICODE_H_
+#define TESTSIMPLEUNICODE_H_
+
+#include "../ConnectionSetup.hpp"
+
+/**
+ * TODO
+ */
+class TestSimpleUnicode : public ConnectionSetup
+{
+public:
+ /** Suite of tests to be run */
+ static CppUnit::Test* suite();
+
+
+ void testBasic();
+
+};
+
+#endif /*TESTSIMPLEUNICODE_H_*/
Index: carob/test/CarobTestLauncher.cpp
diff -u carob/test/CarobTestLauncher.cpp:1.13
carob/test/CarobTestLauncher.cpp:1.14
--- carob/test/CarobTestLauncher.cpp:1.13 Fri Dec 16 16:28:39 2005
+++ carob/test/CarobTestLauncher.cpp Fri Dec 16 22:24:28 2005
@@ -37,6 +37,7 @@
#include "TestExecWriteRequest.hpp"
#include "TestStatement.hpp"
#include "01-Unit/TestStringCodecs.hpp"
+#include "30-ResultSet/TestSimpleUnicode.hpp"
using namespace CarobNS;
@@ -45,6 +46,9 @@
setLogLevel(LOG_LEVEL_INFO);
//setLogLevel(LOG_LEVEL_NONE);
std::locale::global(std::locale(""));
+ // workaround for TestSimpleUnicode
+ // std::locale::global(std::locale("en_US.utf8"));
+
std::set_unexpected(UnexpectedException::convertUnexpected);
CppUnit::TextUi::TestRunner runner;
// For QT ui, replace the above line by this:
@@ -57,6 +61,7 @@
runner.addTest(TestStatement::suite());
runner.addTest(TestDriverResultSet::suite());
runner.addTest(TestStringCodecs::suite());
+ runner.addTest(TestSimpleUnicode::suite());
// add our own protector
CarobProtector* cprot = new CarobProtector();
Index: carob/test/GNUmakefile
diff -u carob/test/GNUmakefile:1.15 carob/test/GNUmakefile:1.16
--- carob/test/GNUmakefile:1.15 Fri Dec 16 17:41:08 2005
+++ carob/test/GNUmakefile Fri Dec 16 22:24:28 2005
@@ -54,7 +54,9 @@
${RM} ${TESTOBJS} CarobTestLauncher.o ${EXE}
testslist:
- { printf "# To update me, delete me.\nTESTSRCS = \\\\\n" ; for i in
*cpp 01-Unit/Test*cpp ; do printf "$$i \\\\\n"; done ; } > $@
+ { printf "# To update me, delete me.\nTESTSRCS = \\\\\n" ; for i in \
+ *cpp 01-Unit/Test*.cpp 30-ResultSet/Test*.cpp ; \
+ do printf "$$i \\\\\n"; done ; } > $@
distclean: clean
${RM} testslist
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits