diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-07 12:36:33 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-07 12:36:33 +0000 |
| commit | b4f7588ba285a8e33dc07acfa730491285cba18e (patch) | |
| tree | 5f0537dee50b0036fd40c2f13fdb4175d28f8b3e /test/a2functionalTest.cc | |
| parent | dfd40dff54670fd3768811acf1a38be6c88b009f (diff) | |
2007-11-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reflect the download length of in-flight pieces.
It makes the download length readout more precise.
* src/DefaultPieceStorage.{h, cc}
* test/DefaultPieceStorageTest.cc
* src/a2functional.h
* test/a2functionalTest.cc
Lower CPU load when --max-download-limit is used.
There is up and down in speed indicator when enabling
http-pipelining but a download goes well. I think the problem is
that
because http-pipelining is enabled, DownloadCommand is created
for
each segment and in its constructor, PeerStat::downloadStart()
is
called. In PeerStat::downloadStart(), speed calculation object
is
reseted, which makes download speed zero.
* src/DownloadCommand.cc
Rewritten using accumulate.
* src/RequestGroupMan.cc (calculateStat)
Code clearnup.
* src/FtpNegotiationCommand.cc
* src/HttpResponseCommand.cc
Diffstat (limited to 'test/a2functionalTest.cc')
| -rw-r--r-- | test/a2functionalTest.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/a2functionalTest.cc b/test/a2functionalTest.cc new file mode 100644 index 00000000..0a936e82 --- /dev/null +++ b/test/a2functionalTest.cc @@ -0,0 +1,64 @@ +#include "a2functional.h" +#include <string> +#include <numeric> +#include <cppunit/extensions/HelperMacros.h> + +using namespace std; + +class a2functionalTest:public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(a2functionalTest); + CPPUNIT_TEST(testMemFunSh); + CPPUNIT_TEST(testAdopt2nd); + CPPUNIT_TEST_SUITE_END(); +public: + void testMemFunSh(); + void testAdopt2nd(); + + class Greeting { + public: + virtual ~Greeting() {} + + virtual string sayGreeting() = 0; + + virtual string sayGreetingConst() const = 0; + }; + + typedef SharedHandle<Greeting> GreetingHandle; + + class JapaneseGreeting:public Greeting + { + virtual string sayGreeting() + { + return "HAROO WAARUDO"; + } + + virtual string sayGreetingConst() const + { + return "HAROO WAARUDO"; + } + + }; + +}; + + +CPPUNIT_TEST_SUITE_REGISTRATION(a2functionalTest); + +void a2functionalTest::testMemFunSh() +{ + GreetingHandle greeting = new JapaneseGreeting(); + + CPPUNIT_ASSERT_EQUAL(string("HAROO WAARUDO"), mem_fun_sh(&Greeting::sayGreeting)(greeting)); + + CPPUNIT_ASSERT_EQUAL(string("HAROO WAARUDO"), mem_fun_sh(&Greeting::sayGreetingConst)(greeting)); + +} + +void a2functionalTest::testAdopt2nd() +{ + GreetingHandle greeting = new JapaneseGreeting(); + + CPPUNIT_ASSERT_EQUAL(string("A Japanese said:HAROO WAARUDO"), + adopt2nd(plus<string>(), mem_fun_sh(&Greeting::sayGreeting))("A Japanese said:", greeting)); +} |
