mirror of
https://github.com/aria2/aria2.git
synced 2025-01-09 03:21:33 +00:00
11907c175d
To handle Segment as SegmentHandle: * src/AbstractCommand.cc (execute): Rewritten. * src/SegmentMan.h: Segment -> SegmentHandle Introducded HttpResponse class, HttpRequest class to improve code extensiveness and make it clear: * src/HttpDownloadCommand.cc: transfer encoders are now managed by HttpResponse class. * src/HttpRequest.h, src/HttpRequest.cc: New class. * src/HttpResponse.h, src/HttpResponse.cc: New class. * src/HttpConnection.cc: Contruction of http request were moved to HttpRequest class. * src/HttpResponseCommand.h, src/HttpResponseCommand.cc: Refactored. * src/HttpRequestCommand.cc (executeInternal): Rewritten. * src/HttpAuthConfig.h: New class. * src/Range.h: New class. To make FtpTunnel{Request, Response}Command and HttpProxy{Request, Response}Command derived from AbstractProxy{Request, Response}Command: * src/FtpTunnelResponseCommand.h, src/FtpTunnelResponseCommand.cc: Derived from AbstractProxyRequestCommand class. * src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc: Derived from AbstractProxyResponseCommand class. * src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc: Derived from AbstractProxyRequestCommand class. * src/HttpProxyResponseCommand.h, src/HttpProxyResponseCommand.cc: Derived from AbstractProxyResponseCommand class. * src/AbstractProxyRequestCommand.h, src/AbstractProxyRequestCommand.cc : New class. * src/AbstractProxyResponseCommand.h, src/AbstractProxyResponseCommand.cc: New class. To add netrc support: * src/Netrc.h, src/Netrc.cc: New class. * src/Util.h, src/Util.cc (split): New function. * src/HttpHeader.cc (getRange): Fixed so that it inspects "Content-Range" header instead of "Range" header. * src/HttpHeader.h (getStatus): Removed. (setStatus): Removed. * src/Segment.h (getPositionToWrite): New function.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#include "SharedHandle.h"
|
|
#include "common.h"
|
|
#include <string>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class SharedHandleTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(SharedHandleTest);
|
|
CPPUNIT_TEST(testSharedHandle);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
static SharedHandle<int> staticHandle;
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
static SharedHandle<int> getInstance() {
|
|
if(staticHandle.isNull()) {
|
|
staticHandle = new int(1);
|
|
}
|
|
return staticHandle;
|
|
}
|
|
|
|
void testSharedHandle();
|
|
};
|
|
|
|
SharedHandle<int> SharedHandleTest::staticHandle = 0;
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( SharedHandleTest );
|
|
|
|
void SharedHandleTest::testSharedHandle() {
|
|
cerr << "xh:" << endl;
|
|
SharedHandle<int> xh = new int(1);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, xh.getRefCount()->totalRefCount);
|
|
CPPUNIT_ASSERT_EQUAL(1, xh.getRefCount()->strongRefCount);
|
|
|
|
cerr << "nullHandle:" << endl;
|
|
SharedHandle<int> nullHandle = 0;
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, nullHandle.getRefCount()->totalRefCount);
|
|
CPPUNIT_ASSERT_EQUAL(1, nullHandle.getRefCount()->strongRefCount);
|
|
|
|
cerr << "staticHandle:" << endl;
|
|
CPPUNIT_ASSERT_EQUAL(1, staticHandle.getRefCount()->totalRefCount);
|
|
CPPUNIT_ASSERT_EQUAL(1, staticHandle.getRefCount()->strongRefCount);
|
|
|
|
SharedHandle<int> localStaticHandle = getInstance();
|
|
|
|
CPPUNIT_ASSERT_EQUAL(2, localStaticHandle.getRefCount()->totalRefCount);
|
|
CPPUNIT_ASSERT_EQUAL(2, localStaticHandle.getRefCount()->strongRefCount);
|
|
}
|