Make unit test for imap modified utf7 optional
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 11 May 2011 12:56:04 +0000 (14:56 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 11 May 2011 13:03:23 +0000 (15:03 +0200)
CMakeLists.txt
libi2ncommon.spec
test/CMakeLists.txt
test/stringfunc.cpp
test/stringfunc_imaputf7.cpp [new file with mode: 0644]

index cf7e34f..bcf303e 100644 (file)
@@ -103,6 +103,13 @@ else(BUILD_XMLLIB)
    message(STATUS "NOT building xml library part")
 endif(BUILD_XMLLIB)
 
+option(IMAP_UTF7_SUPPORT "Enable imap modified utf7 support - needs patched libiconv" OFF)
+if (IMAP_UTF7_SUPPORT)
+   message(STATUS "Build imap modified utf7 support")
+else(IMAP_UTF7_SUPPORT)
+   message(STATUS "NOT building imap modified utf7 support")
+endif(IMAP_UTF7_SUPPORT)
+
 # Find external packages
 include(FindPkgConfig)
 
@@ -115,10 +122,11 @@ if (BUILD_XMLLIB)
 endif(BUILD_XMLLIB)
 
 # Find iconv
-pkg_check_modules(ICONV REQUIRED libiconv)
-include_directories($ICONV_INCLUDE_DIRS})
-link_directories(${ICONV_LIBRARY_DIRS})
-
+if (IMAP_UTF7_SUPPORT)
+    pkg_check_modules(ICONV REQUIRED libiconv)
+    include_directories($ICONV_INCLUDE_DIRS})
+    link_directories(${ICONV_LIBRARY_DIRS})
+endif(IMAP_UTF7_SUPPORT)
 
 # pkgconfig output
 set(prefix      ${CMAKE_INSTALL_PREFIX})
index 7460fbc..f90008f 100644 (file)
@@ -1,9 +1,11 @@
 %bcond_with Intra2net
 %bcond_with xmllib
+%bcond_with imap_utf7_support
 
 # Detect Intra2net build environment
 %if %{with Intra2net}
     %define with_xmllib 1
+    %define with_imap_utf7_support 1
 %endif
 
 Summary:   library with functions common in Intra2net programs
@@ -80,6 +82,9 @@ CMAKE_OPTS=""
 %if %{with xmllib}
     CMAKE_OPTS="$CMAKE_OPTS -DBUILD_XMLLIB=ON"
 %endif
+%if %{with imap_utf7_support}
+    CMAKE_OPTS="$CMAKE_OPTS -DIMAP_UTF7_SUPPORT=ON"
+%endif
 
 cmake -DCMAKE_INSTALL_PREFIX="%{prefix}" $CMAKE_OPTS ../
 
index bc3ba69..2fd6fdb 100644 (file)
@@ -18,6 +18,9 @@ SET(cpp_sources
    test_timefunc.cpp
    test_tmpfstream.cpp
 )
+if (IMAP_UTF7_SUPPORT)
+   SET(cpp_sources stringfunc_imaputf7.cpp ${cpp_sources})
+endif (IMAP_UTF7_SUPPORT)
 
 add_executable(test_i2ncommon ${cpp_sources})
 
index f363bb2..f1404a6 100644 (file)
@@ -18,7 +18,7 @@ This exception does not invalidate any other reasons why a work based
 on this file might be covered by the GNU General Public License.
 */
 /***************************************************************************
- *   Copyright (C) 2006 by Intra2net AG                                    *
+ *   Copyright (C) 2006-2011 by Intra2net AG                               *
  *                                                                         *
  ***************************************************************************/
 
@@ -262,24 +262,6 @@ BOOST_AUTO_TEST_CASE(nice_unit_format8)
     BOOST_CHECK_EQUAL(string("8192.0 PB"), output);
 }
 
-
-
-BOOST_AUTO_TEST_CASE(imaputf7_to_utf8)
-{
-    string output = utf7imap_to_utf8("Sp&AOQ-m");
-    BOOST_CHECK_EQUAL(string("Späm"), output);
-}
-
-BOOST_AUTO_TEST_CASE(utf8_to_imaputf7)
-{
-    string output = utf8_to_utf7imap("Späm");
-    BOOST_CHECK_EQUAL(string("Sp&AOQ-m"), output);
-}
-
-/*
-**
-*/
-
 BOOST_AUTO_TEST_CASE(TestTrim)
 {
     std::string s("s1");
diff --git a/test/stringfunc_imaputf7.cpp b/test/stringfunc_imaputf7.cpp
new file mode 100644 (file)
index 0000000..37ba023
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+/***************************************************************************
+ *   Copyright (C) 2011 by Intra2net AG                                    *
+ *                                                                         *
+ ***************************************************************************/
+
+#include <string>
+
+#define BOOST_TEST_DYN_LINK
+#include <boost/test/unit_test.hpp>
+
+#include <stringfunc.hxx>
+
+using namespace std;
+using namespace I2n;
+
+BOOST_AUTO_TEST_SUITE(stringfunc_imaputf7)
+
+BOOST_AUTO_TEST_CASE(imaputf7_to_utf8)
+{
+    string output = utf7imap_to_utf8("Sp&AOQ-m");
+    BOOST_CHECK_EQUAL(string("Späm"), output);
+}
+
+BOOST_AUTO_TEST_CASE(utf8_to_imaputf7)
+{
+    string output = utf8_to_utf7imap("Späm");
+    BOOST_CHECK_EQUAL(string("Sp&AOQ-m"), output);
+}
+
+BOOST_AUTO_TEST_SUITE_END()