From 652f47a7bce97d375305af811d0cd4769f270d48 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 11 May 2011 14:56:04 +0200 Subject: [PATCH] Make unit test for imap modified utf7 optional --- CMakeLists.txt | 16 ++++++++++--- libi2ncommon.spec | 5 ++++ test/CMakeLists.txt | 3 ++ test/stringfunc.cpp | 20 +---------------- test/stringfunc_imaputf7.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 test/stringfunc_imaputf7.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cf7e34f..bcf303e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/libi2ncommon.spec b/libi2ncommon.spec index 7460fbc..f90008f 100644 --- a/libi2ncommon.spec +++ b/libi2ncommon.spec @@ -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 ../ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc3ba69..2fd6fdb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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}) diff --git a/test/stringfunc.cpp b/test/stringfunc.cpp index f363bb2..f1404a6 100644 --- a/test/stringfunc.cpp +++ b/test/stringfunc.cpp @@ -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 index 0000000..37ba023 --- /dev/null +++ b/test/stringfunc_imaputf7.cpp @@ -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 + +#define BOOST_TEST_DYN_LINK +#include + +#include + +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() -- 1.7.1