OSDN Git Service

add Kita::unescape
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Tue, 27 Jan 2004 15:50:01 +0000 (15:50 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Tue, 27 Jan 2004 15:50:01 +0000 (15:50 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@854 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/libkita/kita_misc.cpp
kita/src/libkita/kita_misc.h
kita/src/libkita/tests/Makefile.am
kita/src/libkita/tests/misctest.cpp [new file with mode: 0644]
kita/src/libkita/tests/misctest.h [new file with mode: 0644]
kita/src/libkita/tests/test_libkita.cpp

index 1b77997..50b8d25 100644 (file)
@@ -120,3 +120,9 @@ QString Kita::httpToK2ch( const QString& httpURL )
 
     return url.url();
 }
+
+QString Kita::unescape( const QString& str )
+{
+    QString ret = str;
+    return ret.replace( "&lt;", "<" ).replace( "&gt;", ">" ).replace( "&amp;", "&" );
+}
index 1c75a55..de05757 100644 (file)
@@ -27,6 +27,7 @@ namespace Kita
     QString subjectToBoard( const QString& subjectURL );
     QString datToCache( const QString& datURL );
     QString httpToK2ch( const QString& httpURL );
+    QString unescape( const QString& str );
 };
 
 #endif
index ad9b3ec..5af35e7 100644 (file)
@@ -4,5 +4,5 @@ check_PROGRAMS = test_libkita
 
 KDE_CXXFLAGS = $(USE_EXCEPTIONS)
 test_libkita_LDADD = $(top_builddir)/kita/src/libkita/libkita.la -lkio -lqt-mt -lcppunit
-test_libkita_SOURCES = test_libkita.cpp k2ch_articlefiletest.cpp urlconverttest.cpp commenttest.cpp threadtest.cpp boardtest.cpp
-noinst_HEADERS = k2ch_articlefiletest.h urlconverttest.h commenttest.h threadtest.h boardtest.h
+test_libkita_SOURCES = test_libkita.cpp k2ch_articlefiletest.cpp urlconverttest.cpp commenttest.cpp threadtest.cpp boardtest.cpp misctest.cpp
+noinst_HEADERS = k2ch_articlefiletest.h urlconverttest.h commenttest.h threadtest.h boardtest.h misctest.h
diff --git a/kita/src/libkita/tests/misctest.cpp b/kita/src/libkita/tests/misctest.cpp
new file mode 100644 (file)
index 0000000..fb082e9
--- /dev/null
@@ -0,0 +1,25 @@
+/***************************************************************************
+*   Copyright (C) 2003 by Hideki Ikemoto                                  *
+*   ikemo@wakaba.jp                                                       *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+***************************************************************************/
+
+#include "misctest.h"
+
+void MiscTest::setUp()
+{}
+
+void MiscTest::tearDown()
+{}
+
+void MiscTest::testUnEscape()
+{
+    CPPUNIT_ASSERT_EQUAL( QString( "&" ), Kita::unescape( "&amp;" ) );
+    CPPUNIT_ASSERT_EQUAL( QString( "<" ), Kita::unescape( "&lt;" ) );
+    CPPUNIT_ASSERT_EQUAL( QString( ">" ), Kita::unescape( "&gt;" ) );
+    CPPUNIT_ASSERT_EQUAL( QString( "&lt;" ), Kita::unescape( "&amp;lt;" ) );
+}
diff --git a/kita/src/libkita/tests/misctest.h b/kita/src/libkita/tests/misctest.h
new file mode 100644 (file)
index 0000000..d0f62bb
--- /dev/null
@@ -0,0 +1,33 @@
+/***************************************************************************
+*   Copyright (C) 2003 by Hideki Ikemoto                                  *
+*   ikemo@wakaba.jp                                                       *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+***************************************************************************/
+
+#ifndef MISCTEST_H
+#define MISCTEST_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include "../kita_misc.h"
+
+/**
+@author Hideki Ikemoto
+*/
+class MiscTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( MiscTest );
+    CPPUNIT_TEST( testUnEscape );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void testUnEscape();
+};
+
+#endif
index 5d1f2e5..9207d12 100644 (file)
@@ -16,6 +16,7 @@
 #include "commenttest.h"
 #include "threadtest.h"
 #include "boardtest.h"
+#include "misctest.h"
 
 int main( int argc, char* argv[] )
 {
@@ -26,6 +27,7 @@ int main( int argc, char* argv[] )
   runner.addTest( CommentTest::suite() );
   runner.addTest( ThreadTest::suite() );
   runner.addTest( BoardTest::suite() );
+  runner.addTest( MiscTest::suite() );
   runner.run( "" );
   return 0;
 }