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 )
{}
#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;
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
--- /dev/null
+/***************************************************************************
+* 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() );
+}
--- /dev/null
+/***************************************************************************
+* 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
#include "misctest.h"
#include "favoritethreadstest.h"
#include "favoriteboardstest.h"
+#include "commentlisttest.h"
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;
}