OSDN Git Service

Kita::CommentList class added.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 24 Mar 2004 16:03:22 +0000 (16:03 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 24 Mar 2004 16:03:22 +0000 (16:03 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@945 56b19765-1e22-0410-a548-a0f45d66c51a

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

index 493d65e..e1a8b07 100644 (file)
 
 using namespace Kita;
 
+CommentList::CommentList( const QString& str )
+{
+    QStringList lines = QStringList::split( "\n", str );
+    for ( QStringList::iterator it = lines.begin(); it != lines.end(); ++it ) {
+        QString line = ( *it );
+        if ( line.isEmpty() ) {
+            continue;
+        }
+        Kita::Comment comment( line );
+        m_list << comment;
+    }
+}
+
+CommentList::~CommentList()
+{}
+
 Comment::Comment() : m_isValid( false )
 {}
 
index 0ed421a..445ad74 100644 (file)
 
 #include <qstring.h>
 #include <qdatetime.h>
+#include <qvaluelist.h>
 
 namespace Kita
 {
+    class Comment;
+    
+    class CommentList
+    {
+        QValueList<Kita::Comment> m_list;
+    public:
+        CommentList( const QString& str );
+        ~CommentList();
+        size_t size() { return m_list.size(); }
+    };
+
     class Comment
     {
         QString m_name;
index a934563..f4ebf57 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 misctest.cpp favoritethreadstest.cpp favoriteboardstest.cpp
-noinst_HEADERS = k2ch_articlefiletest.h urlconverttest.h commenttest.h threadtest.h boardtest.h misctest.h favoritethreadstest.h favoriteboardstest.h
+test_libkita_SOURCES = test_libkita.cpp k2ch_articlefiletest.cpp urlconverttest.cpp commenttest.cpp threadtest.cpp boardtest.cpp misctest.cpp favoritethreadstest.cpp favoriteboardstest.cpp commentlisttest.cpp
+noinst_HEADERS = k2ch_articlefiletest.h urlconverttest.h commenttest.h threadtest.h boardtest.h misctest.h favoritethreadstest.h favoriteboardstest.h commentlisttest.h
diff --git a/kita/src/libkita/tests/commentlisttest.cpp b/kita/src/libkita/tests/commentlisttest.cpp
new file mode 100644 (file)
index 0000000..602c04d
--- /dev/null
@@ -0,0 +1,30 @@
+/***************************************************************************
+*   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 "commentlisttest.h"
+
+using namespace Kita;
+
+void CommentListTest::setUp()
+{
+    m_2ch = new CommentList( "name<>mail<>03/11/03 00:39 ID:abcdefgh<>comment<>subject\n"
+                             "name2<>mail2<>04/12/04 00:40 ID:ijklmnop<>comment2<>\n" );
+}
+
+void CommentListTest::tearDown()
+{
+    delete m_2ch;
+}
+
+void CommentListTest::testName()
+{
+    CPPUNIT_ASSERT_EQUAL( (size_t)2, m_2ch->size() );
+//    CPPUNIT_ASSERT_EQUAL( QString( "name" ), m_2ch[ 0 ] ->getName() );
+//    CPPUNIT_ASSERT_EQUAL( QString( "name2" ), m_2ch[ 1 ] ->getName() );
+}
diff --git a/kita/src/libkita/tests/commentlisttest.h b/kita/src/libkita/tests/commentlisttest.h
new file mode 100644 (file)
index 0000000..91fd5c1
--- /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 COMMENTLISTTEST_H
+#define COMMENTLISTTEST_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include "../comment.h"
+
+/**
+@author Hideki Ikemoto
+*/
+class CommentListTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( CommentListTest );
+    CPPUNIT_TEST( testName );
+    CPPUNIT_TEST_SUITE_END();
+
+    Kita::CommentList *m_2ch;
+public:
+    void setUp();
+    void tearDown();
+
+    void testName();
+};
+
+#endif
index 9a161cd..64eb3ec 100644 (file)
@@ -19,6 +19,7 @@
 #include "misctest.h"
 #include "favoritethreadstest.h"
 #include "favoriteboardstest.h"
+#include "commentlisttest.h"
 
 int main( int argc, char* argv[] )
 {
@@ -32,6 +33,7 @@ int main( int argc, char* argv[] )
   runner.addTest( MiscTest::suite() );
   runner.addTest( FavoriteThreadsTest::suite() );
   runner.addTest( FavoriteBoardsTest::suite() );
+  runner.addTest( CommentListTest::suite() );
   runner.run( "" );
   return 0;
 }