/***************************************************************************
- * 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. *
- ***************************************************************************/
+* 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 KITAKITA_MISC_H
#define KITAKITA_MISC_H
#include <qstring.h>
-namespace Kita {
+namespace Kita
+{
-/**
- * @author Hideki Ikemoto
- */
+ /**
+ * @author Hideki Ikemoto
+ */
- QString datToBoard( const QString& datURL );
- QString datToThread( const QString& datURL );
- QString threadToDat( const QString& threadURL );
- QString boardToSubject( const QString& boardURL );
- QString subjectToBoard( const QString& subjectURL );
- QString datToCache( const QString& datURL );
+ QString datToBoard( const QString& datURL );
+ QString datToThread( const QString& datURL );
+ QString threadToDat( const QString& threadURL );
+ QString boardToSubject( const QString& boardURL );
+ QString subjectToBoard( const QString& subjectURL );
+ QString datToCache( const QString& datURL );
+ QString httpToK2ch( const QString& httpURL );
};
-
#endif
/***************************************************************************
- * 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. *
- ***************************************************************************/
+* 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 "urlconverttest.h"
void URLConvertTest::setUp()
{
- m_datURL = "http://pc.2ch.net/linux/dat/1022744633.dat";
- m_datURL_k2ch = "k2ch://pc.2ch.net/linux/dat/1022744633.dat";
- m_threadURL = "http://pc.2ch.net/test/read.cgi/linux/1022744633/";
- m_threadURL_k2ch = "k2ch://pc.2ch.net/test/read.cgi/linux/1022744633/";
- m_threadURL2 = "http://pc.2ch.net/test/read.cgi/linux/1022744633";
- m_threadURL2_k2ch = "k2ch://pc.2ch.net/test/read.cgi/linux/1022744633";
- m_subjectURL = "http://pc.2ch.net/linux/subject.txt";
- m_subjectURL_k2ch = "k2ch://pc.2ch.net/linux/subject.txt";
- m_boardURL = "http://pc.2ch.net/linux/";
- m_boardURL_k2ch = "k2ch://pc.2ch.net/linux/";
- m_boardURL2 = "http://pc.2ch.net/linux";
- m_boardURL2_k2ch = "k2ch://pc.2ch.net/linux";
+ m_datURL = "http://pc.2ch.net/linux/dat/1022744633.dat";
+ m_datURL_k2ch = "k2ch://pc.2ch.net/linux/dat/1022744633.dat";
+ m_threadURL = "http://pc.2ch.net/test/read.cgi/linux/1022744633/";
+ m_threadURL_k2ch = "k2ch://pc.2ch.net/test/read.cgi/linux/1022744633/";
+ m_threadURL2 = "http://pc.2ch.net/test/read.cgi/linux/1022744633";
+ m_threadURL2_k2ch = "k2ch://pc.2ch.net/test/read.cgi/linux/1022744633";
+ m_subjectURL = "http://pc.2ch.net/linux/subject.txt";
+ m_subjectURL_k2ch = "k2ch://pc.2ch.net/linux/subject.txt";
+ m_boardURL = "http://pc.2ch.net/linux/";
+ m_boardURL_k2ch = "k2ch://pc.2ch.net/linux/";
+ m_boardURL2 = "http://pc.2ch.net/linux";
+ m_boardURL2_k2ch = "k2ch://pc.2ch.net/linux";
- // relative path.
- m_cachePath = QString( "pc.2ch.net/linux/1022744633.dat" );
+ // relative path.
+ m_cachePath = QString( "pc.2ch.net/linux/1022744633.dat" );
}
void URLConvertTest::tearDown()
-{
-}
+{}
void URLConvertTest::testDatToThread()
{
- CPPUNIT_ASSERT_EQUAL( m_threadURL, Kita::datToThread( m_datURL ) );
- CPPUNIT_ASSERT_EQUAL( m_threadURL_k2ch, Kita::datToThread( m_datURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_threadURL, Kita::datToThread( m_datURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_threadURL_k2ch, Kita::datToThread( m_datURL_k2ch ) );
}
void URLConvertTest::testThreadToDat()
{
- CPPUNIT_ASSERT_EQUAL( m_datURL, Kita::threadToDat( m_threadURL ) );
- CPPUNIT_ASSERT_EQUAL( m_datURL_k2ch, Kita::threadToDat( m_threadURL_k2ch ) );
- CPPUNIT_ASSERT_EQUAL( m_datURL, Kita::threadToDat( m_threadURL2 ) );
- CPPUNIT_ASSERT_EQUAL( m_datURL_k2ch, Kita::threadToDat( m_threadURL2_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_datURL, Kita::threadToDat( m_threadURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_datURL_k2ch, Kita::threadToDat( m_threadURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_datURL, Kita::threadToDat( m_threadURL2 ) );
+ CPPUNIT_ASSERT_EQUAL( m_datURL_k2ch, Kita::threadToDat( m_threadURL2_k2ch ) );
}
void URLConvertTest::testBoardToSubject()
{
- CPPUNIT_ASSERT_EQUAL( m_subjectURL, Kita::boardToSubject( m_boardURL ) );
- CPPUNIT_ASSERT_EQUAL( m_subjectURL_k2ch,
- Kita::boardToSubject( m_boardURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_subjectURL, Kita::boardToSubject( m_boardURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_subjectURL_k2ch,
+ Kita::boardToSubject( m_boardURL_k2ch ) );
}
void URLConvertTest::testSubjectToBoard()
{
- CPPUNIT_ASSERT_EQUAL( m_boardURL, Kita::subjectToBoard( m_subjectURL ) );
- CPPUNIT_ASSERT_EQUAL( m_boardURL_k2ch, Kita::subjectToBoard( m_subjectURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL, Kita::subjectToBoard( m_subjectURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL_k2ch, Kita::subjectToBoard( m_subjectURL_k2ch ) );
}
void URLConvertTest::testDatToCache()
{
- CPPUNIT_ASSERT_EQUAL( m_cachePath, Kita::datToCache( m_datURL ) );
- CPPUNIT_ASSERT_EQUAL( m_cachePath, Kita::datToCache( m_datURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_cachePath, Kita::datToCache( m_datURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_cachePath, Kita::datToCache( m_datURL_k2ch ) );
}
void URLConvertTest::testDatToBoard()
{
- CPPUNIT_ASSERT_EQUAL( m_boardURL, Kita::datToBoard( m_datURL ) );
- CPPUNIT_ASSERT_EQUAL( m_boardURL_k2ch, Kita::datToBoard( m_datURL_k2ch ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL, Kita::datToBoard( m_datURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL_k2ch, Kita::datToBoard( m_datURL_k2ch ) );
+}
+
+void URLConvertTest::testHttpToK2ch()
+{
+ CPPUNIT_ASSERT_EQUAL( m_datURL_k2ch, Kita::httpToK2ch( m_datURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_threadURL_k2ch, Kita::httpToK2ch( m_threadURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_threadURL2_k2ch, Kita::httpToK2ch( m_threadURL2 ) );
+ CPPUNIT_ASSERT_EQUAL( m_subjectURL_k2ch, Kita::httpToK2ch( m_subjectURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL_k2ch, Kita::httpToK2ch( m_boardURL ) );
+ CPPUNIT_ASSERT_EQUAL( m_boardURL2_k2ch, Kita::httpToK2ch( m_boardURL2 ) );
}
/***************************************************************************
- * 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. *
- ***************************************************************************/
+* 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 URLCONVERTTEST_H
#define URLCONVERTTEST_H
/**
@author Hideki Ikemoto
*/
-class URLConvertTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE( URLConvertTest );
- CPPUNIT_TEST( testDatToThread );
- CPPUNIT_TEST( testThreadToDat );
- CPPUNIT_TEST( testBoardToSubject );
- CPPUNIT_TEST( testSubjectToBoard );
- CPPUNIT_TEST( testDatToCache );
- CPPUNIT_TEST( testDatToBoard );
- CPPUNIT_TEST_SUITE_END();
+class URLConvertTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( URLConvertTest );
+ CPPUNIT_TEST( testDatToThread );
+ CPPUNIT_TEST( testThreadToDat );
+ CPPUNIT_TEST( testBoardToSubject );
+ CPPUNIT_TEST( testSubjectToBoard );
+ CPPUNIT_TEST( testDatToCache );
+ CPPUNIT_TEST( testDatToBoard );
+ CPPUNIT_TEST( testHttpToK2ch );
+ CPPUNIT_TEST_SUITE_END();
- QString m_datURL;
- QString m_datURL_k2ch;
- QString m_threadURL;
- QString m_threadURL_k2ch;
- QString m_threadURL2;
- QString m_threadURL2_k2ch;
- QString m_subjectURL;
- QString m_subjectURL_k2ch;
- QString m_boardURL;
- QString m_boardURL_k2ch;
- QString m_boardURL2;
- QString m_boardURL2_k2ch;
- QString m_cachePath;
- QString m_cachePath_k2ch;
+ QString m_datURL;
+ QString m_datURL_k2ch;
+ QString m_threadURL;
+ QString m_threadURL_k2ch;
+ QString m_threadURL2;
+ QString m_threadURL2_k2ch;
+ QString m_subjectURL;
+ QString m_subjectURL_k2ch;
+ QString m_boardURL;
+ QString m_boardURL_k2ch;
+ QString m_boardURL2;
+ QString m_boardURL2_k2ch;
+ QString m_cachePath;
+ QString m_cachePath_k2ch;
public:
- void setUp();
- void tearDown();
+ void setUp();
+ void tearDown();
- void testDatToThread();
- void testThreadToDat();
- void testBoardToSubject();
- void testSubjectToBoard();
- void testDatToCache();
- void testDatToBoard();
+ void testDatToThread();
+ void testThreadToDat();
+ void testBoardToSubject();
+ void testSubjectToBoard();
+ void testDatToCache();
+ void testDatToBoard();
+ void testHttpToK2ch();
};
#endif