Date: Friday, December 16, 2005 @ 16:28:40
Author: marc
Path: /cvsroot/carob/carob/test
Added: 01-Unit/TestStringCodecs.cpp (1.1) 01-Unit/TestStringCodecs.hpp
(1.1)
Modified: CarobTestLauncher.cpp (1.12 -> 1.13) GNUmakefile (1.13 -> 1.14)
Removed: unit/TestStringCodecs.cpp (1.1) unit/TestStringCodecs.hpp (1.1)
mv unit 01-Unit
------------------------------+
01-Unit/TestStringCodecs.cpp | 156 +++++++++++++++++++++++++++++++++++++++++
01-Unit/TestStringCodecs.hpp | 46 ++++++++++++
CarobTestLauncher.cpp | 2
GNUmakefile | 2
unit/TestStringCodecs.cpp | 156 -----------------------------------------
unit/TestStringCodecs.hpp | 46 ------------
6 files changed, 204 insertions(+), 204 deletions(-)
Index: carob/test/01-Unit/TestStringCodecs.cpp
diff -u /dev/null carob/test/01-Unit/TestStringCodecs.cpp:1.1
--- /dev/null Fri Dec 16 16:28:40 2005
+++ carob/test/01-Unit/TestStringCodecs.cpp Fri Dec 16 16:28:39 2005
@@ -0,0 +1,156 @@
+/*
+ * Sequoia: Database clustering technology Copyright 2002-2005
+ * Continuent, Inc.
+
+ * 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 <iostream>
+
+#include <cppunit/TestSuite.h>
+#include <cppunit/TestCaller.h>
+
+#include "TestStringCodecs.hpp"
+#include "StringCodecs.hpp"
+
+using namespace CarobNS;
+
+// wchar_t is supposed to be Unicode (UCS-4 or UCS-2) else these tests won't
work
+
+void TestStringCodecs::encode_decode()
+{
+ using std::string;
+ using std::wstring;
+
+ const MBSCodec user_codec;
+
+ const MBSCodec utf8_codec(trylocale(NAME_OF_ANY_UTF8_LOCALE_AVAILABLE));
+
+ const MBSCodec latin9_codec("[EMAIL PROTECTED]");
+ const MBSCodec iso7_codec("el_GR.iso88597");
+
+
+ // TEST STRINGS
+
+ // CAE
+ // c, a` e', + zero + last character (e') again
+ // in latin1, latin2 and UCS: 231, 224, 233
+ wchar_t wide_cae_[] = { 0xe7, 0xe0, 0xe9, 0, 0xe9 };
+ wstring wide_cae(wide_cae_, 5);
+
+ // 195, 167, 195, 160, 195, 169
+ char utf8_cae_[] = { 0xc3, 0xa7, 0xc3, 0xa0, 0xc3, 0xa9, 0, 0xc3, 0xa9 };
+ string utf8_cae(utf8_cae_, 9);
+ char latin1or2_cae_[] = { 0xe7, 0xe0, 0xe9, 0, 0xe9 };
+ string latin1or2_cae(latin1or2_cae_, 5);
+
+ // PBK
+ // phi beta kappa + zero + last character (kappa) again
+ wchar_t wide_pbk_[] = { 0x03c6, 0x03b2, 0x03ba, 0, 0x03ba };
+ wstring wide_pbk(wide_pbk_, 5);
+
+ char utf8_pbk_[] = { 0xcf, 0x86, 0xce, 0xb2, 0xce, 0xba, 0, 0xce, 0xba };
+ string utf8_pbk(utf8_pbk_, 9);
+ char iso7_pbk_[] = { 0xf6, 0xe2, 0xea, 0, 0xea};
+ string iso7_pbk(iso7_pbk_, 5);
+
+
+ // ENCODE
+
+ string utf8s(utf8_codec.encode(wide_cae));
+ string latin9s(latin9_codec.encode(wide_cae));
+
+ string iso7s;
+ try { // testing CodecException
+ iso7s = iso7_codec.encode(wide_cae);
+ std::cerr << "succeeded impossible conversion!" << std::endl;
+ CPPUNIT_ASSERT(false);
+ } catch (CodecException& ce)
+ {
+ // std::cerr << "(conversion error expected)" << std::endl;
+ }
+ iso7s = iso7_codec.encode(wide_pbk);
+
+
+ // COMPARE
+
+ CPPUNIT_ASSERT(0 == utf8_cae.compare(utf8s));
+ CPPUNIT_ASSERT(0 == latin1or2_cae.compare(latin9s));
+ CPPUNIT_ASSERT(0 == iso7s.compare(iso7_pbk));
+
+ // DECODE BACK AND COMPARE
+
+ CPPUNIT_ASSERT(0 == wide_cae.compare(utf8_codec.decode(utf8s)));
+ CPPUNIT_ASSERT(0 == wide_cae.compare(latin9_codec.decode(latin9s)));
+ CPPUNIT_ASSERT(0 == wide_pbk.compare(iso7_codec.decode(iso7s)));
+
+
+ // DUMP to cout (requires terminal, fonts, etc.)
+#if 0
+
+# ifdef __GLIBC__
+ // unwire std::wcout from global C locale, so wcout::imbue() does work
+ // (undocumented "feature", learned the hard way; thx Paolo Carlini)
+ std::ios::sync_with_stdio(false);
+# endif
+
+ std::wcout.imbue(std::locale(""));
+
+
+ std::wcout << L"orig_cae: " << wide_cae << std::endl;
+ std::wcout << L"orig_pbk: " << wide_pbk << std::endl;
+
+ std::cout << "cae encoded to UTF8: " << utf8s << std::endl;
+ std::cout << "cae encoded to latin9 " << latin9s << std::endl;
+ std::cout << "pbk encoded to iso7 " << iso7s << std::endl;
+
+ std::wcout << L"wide back from UTF8: " << utf8_codec.decode(utf8s) <<
std::endl;
+ std::wcout << L"wide back from latin9: " << latin9_codec.decode(latin9s)
<< std::endl;
+ std::wcout << L"wide back from iso7: " << iso7_codec.decode(iso7s) <<
std::endl;
+#endif
+
+}
+
+CppUnit::Test* TestStringCodecs::suite()
+{
+ CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestStringCodecs" );
+
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestStringCodecs>(
+ "encode_decode",
+ &TestStringCodecs::encode_decode));
+ return suiteOfTests;
+}
+
+
+namespace {
+void dumpchars(std::string s)
+{
+ std::cout << "a char string: " ;
+ for (std::string::const_iterator i = s.begin(); i < s.end(); i++)
+ {
+ std::cout << (unsigned int) (unsigned char) *i << "," ;
+ }
+ std::cout << std::endl;
+}
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: carob/test/01-Unit/TestStringCodecs.hpp
diff -u /dev/null carob/test/01-Unit/TestStringCodecs.hpp:1.1
--- /dev/null Fri Dec 16 16:28:40 2005
+++ carob/test/01-Unit/TestStringCodecs.hpp Fri Dec 16 16:28:39 2005
@@ -0,0 +1,46 @@
+/*
+ * Sequoia: Database clustering technology Copyright 2002-2005
+ * Continuent, Inc.
+
+ * 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 CAROB_TESTCODECS_H_
+#define CAROB_TESTCODECS_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/TestCase.h>
+
+
+class TestStringCodecs : public CppUnit::TestFixture
+{
+public:
+ /** Suite of tests to be run */
+ static CppUnit::Test* suite();
+
+ void encode_decode();
+
+};
+
+#endif // include only once
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: carob/test/CarobTestLauncher.cpp
diff -u carob/test/CarobTestLauncher.cpp:1.12
carob/test/CarobTestLauncher.cpp:1.13
--- carob/test/CarobTestLauncher.cpp:1.12 Fri Dec 16 15:57:51 2005
+++ carob/test/CarobTestLauncher.cpp Fri Dec 16 16:28:39 2005
@@ -36,7 +36,7 @@
#include "TestExecReadRequest.hpp"
#include "TestExecWriteRequest.hpp"
#include "TestStatement.hpp"
-#include "unit/TestStringCodecs.hpp"
+#include "01-Unit/TestStringCodecs.hpp"
using namespace CarobNS;
Index: carob/test/GNUmakefile
diff -u carob/test/GNUmakefile:1.13 carob/test/GNUmakefile:1.14
--- carob/test/GNUmakefile:1.13 Fri Dec 16 15:57:51 2005
+++ carob/test/GNUmakefile Fri Dec 16 16:28:39 2005
@@ -54,7 +54,7 @@
${RM} ${TESTOBJS} CarobTestLauncher.o ${EXE}
testslist:
- { printf "# To update me, delete me.\nTESTSRCS = \\\\\n" ; for i in
Test*cpp unit/Test*cpp ; do printf "$$i \\\\\n"; done ; } > $@
+ { printf "# To update me, delete me.\nTESTSRCS = \\\\\n" ; for i in
Test*cpp 01-Unit/Test*cpp ; do printf "$$i \\\\\n"; done ; } > $@
distclean: clean
${RM} testslist
Index: carob/test/unit/TestStringCodecs.cpp
diff -u carob/test/unit/TestStringCodecs.cpp:1.1
carob/test/unit/TestStringCodecs.cpp:removed
--- carob/test/unit/TestStringCodecs.cpp:1.1 Fri Dec 16 15:57:51 2005
+++ carob/test/unit/TestStringCodecs.cpp Fri Dec 16 16:28:40 2005
@@ -1,156 +0,0 @@
-/*
- * Sequoia: Database clustering technology Copyright 2002-2005
- * Continuent, Inc.
-
- * 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 <iostream>
-
-#include <cppunit/TestSuite.h>
-#include <cppunit/TestCaller.h>
-
-#include "TestStringCodecs.hpp"
-#include "StringCodecs.hpp"
-
-using namespace CarobNS;
-
-// wchar_t is supposed to be Unicode (UCS-4 or UCS-2) else these tests won't
work
-
-void TestStringCodecs::encode_decode()
-{
- using std::string;
- using std::wstring;
-
- const MBSCodec user_codec;
-
- const MBSCodec utf8_codec(trylocale(NAME_OF_ANY_UTF8_LOCALE_AVAILABLE));
-
- const MBSCodec latin9_codec("[EMAIL PROTECTED]");
- const MBSCodec iso7_codec("el_GR.iso88597");
-
-
- // TEST STRINGS
-
- // CAE
- // c, a` e', + zero + last character (e') again
- // in latin1, latin2 and UCS: 231, 224, 233
- wchar_t wide_cae_[] = { 0xe7, 0xe0, 0xe9, 0, 0xe9 };
- wstring wide_cae(wide_cae_, 5);
-
- // 195, 167, 195, 160, 195, 169
- char utf8_cae_[] = { 0xc3, 0xa7, 0xc3, 0xa0, 0xc3, 0xa9, 0, 0xc3, 0xa9 };
- string utf8_cae(utf8_cae_, 9);
- char latin1or2_cae_[] = { 0xe7, 0xe0, 0xe9, 0, 0xe9 };
- string latin1or2_cae(latin1or2_cae_, 5);
-
- // PBK
- // phi beta kappa + zero + last character (kappa) again
- wchar_t wide_pbk_[] = { 0x03c6, 0x03b2, 0x03ba, 0, 0x03ba };
- wstring wide_pbk(wide_pbk_, 5);
-
- char utf8_pbk_[] = { 0xcf, 0x86, 0xce, 0xb2, 0xce, 0xba, 0, 0xce, 0xba };
- string utf8_pbk(utf8_pbk_, 9);
- char iso7_pbk_[] = { 0xf6, 0xe2, 0xea, 0, 0xea};
- string iso7_pbk(iso7_pbk_, 5);
-
-
- // ENCODE
-
- string utf8s(utf8_codec.encode(wide_cae));
- string latin9s(latin9_codec.encode(wide_cae));
-
- string iso7s;
- try { // testing CodecException
- iso7s = iso7_codec.encode(wide_cae);
- std::cerr << "succeeded impossible conversion!" << std::endl;
- CPPUNIT_ASSERT(false);
- } catch (CodecException& ce)
- {
- // std::cerr << "(conversion error expected)" << std::endl;
- }
- iso7s = iso7_codec.encode(wide_pbk);
-
-
- // COMPARE
-
- CPPUNIT_ASSERT(0 == utf8_cae.compare(utf8s));
- CPPUNIT_ASSERT(0 == latin1or2_cae.compare(latin9s));
- CPPUNIT_ASSERT(0 == iso7s.compare(iso7_pbk));
-
- // DECODE BACK AND COMPARE
-
- CPPUNIT_ASSERT(0 == wide_cae.compare(utf8_codec.decode(utf8s)));
- CPPUNIT_ASSERT(0 == wide_cae.compare(latin9_codec.decode(latin9s)));
- CPPUNIT_ASSERT(0 == wide_pbk.compare(iso7_codec.decode(iso7s)));
-
-
- // DUMP to cout (requires terminal, fonts, etc.)
-#if 0
-
-# ifdef __GLIBC__
- // unwire std::wcout from global C locale, so wcout::imbue() does work
- // (undocumented "feature", learned the hard way; thx Paolo Carlini)
- std::ios::sync_with_stdio(false);
-# endif
-
- std::wcout.imbue(std::locale(""));
-
-
- std::wcout << L"orig_cae: " << wide_cae << std::endl;
- std::wcout << L"orig_pbk: " << wide_pbk << std::endl;
-
- std::cout << "cae encoded to UTF8: " << utf8s << std::endl;
- std::cout << "cae encoded to latin9 " << latin9s << std::endl;
- std::cout << "pbk encoded to iso7 " << iso7s << std::endl;
-
- std::wcout << L"wide back from UTF8: " << utf8_codec.decode(utf8s) <<
std::endl;
- std::wcout << L"wide back from latin9: " << latin9_codec.decode(latin9s)
<< std::endl;
- std::wcout << L"wide back from iso7: " << iso7_codec.decode(iso7s) <<
std::endl;
-#endif
-
-}
-
-CppUnit::Test* TestStringCodecs::suite()
-{
- CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestStringCodecs" );
-
- suiteOfTests->addTest(new CppUnit::TestCaller<TestStringCodecs>(
- "encode_decode",
- &TestStringCodecs::encode_decode));
- return suiteOfTests;
-}
-
-
-namespace {
-void dumpchars(std::string s)
-{
- std::cout << "a char string: " ;
- for (std::string::const_iterator i = s.begin(); i < s.end(); i++)
- {
- std::cout << (unsigned int) (unsigned char) *i << "," ;
- }
- std::cout << std::endl;
-}
-}
-
-/*
- * Local Variables:
- * c-file-style: "bsd"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
Index: carob/test/unit/TestStringCodecs.hpp
diff -u carob/test/unit/TestStringCodecs.hpp:1.1
carob/test/unit/TestStringCodecs.hpp:removed
--- carob/test/unit/TestStringCodecs.hpp:1.1 Fri Dec 16 15:57:51 2005
+++ carob/test/unit/TestStringCodecs.hpp Fri Dec 16 16:28:40 2005
@@ -1,46 +0,0 @@
-/*
- * Sequoia: Database clustering technology Copyright 2002-2005
- * Continuent, Inc.
-
- * 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 CAROB_TESTCODECS_H_
-#define CAROB_TESTCODECS_H_
-
-#include <cppunit/TestFixture.h>
-#include <cppunit/TestCase.h>
-
-
-class TestStringCodecs : public CppUnit::TestFixture
-{
-public:
- /** Suite of tests to be run */
- static CppUnit::Test* suite();
-
- void encode_decode();
-
-};
-
-#endif // include only once
-
-/*
- * Local Variables:
- * c-file-style: "bsd"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits