summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-09 10:06:53 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-09 10:06:53 +0000
commit2d522cf6b7be0a4e58d2111ed9f939d6e3019582 (patch)
tree336e44735aa3ac545bbf127fdaf61115f33bbed9 /test
parentc7fbedfa0aba7bd23f101d6823cb46348745c363 (diff)
2007-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added -j command-line option. * src/OptionHandlerFactory.cc (createOptionHandlers) * src/main.cc * src/ByteArrayDiskWriter.h, src/ByteArrayDiskWriter.cc Rewritten using stringstream. * src/TrackerUpdateCommand.h, src/TrackerUpdateCommand.cc Rewritten using stringstream.
Diffstat (limited to 'test')
-rw-r--r--test/ByteArrayDiskWriterTest.cc66
-rw-r--r--test/Makefile.am1
-rw-r--r--test/Makefile.in6
3 files changed, 72 insertions, 1 deletions
diff --git a/test/ByteArrayDiskWriterTest.cc b/test/ByteArrayDiskWriterTest.cc
new file mode 100644
index 00000000..ff90db61
--- /dev/null
+++ b/test/ByteArrayDiskWriterTest.cc
@@ -0,0 +1,66 @@
+#include "ByteArrayDiskWriter.h"
+#include <string>
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace std;
+
+class ByteArrayDiskWriterTest:public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE(ByteArrayDiskWriterTest);
+ CPPUNIT_TEST(testWriteAndRead);
+ CPPUNIT_TEST(testWriteAndRead2);
+ CPPUNIT_TEST_SUITE_END();
+private:
+
+public:
+ void setUp() {
+ }
+
+ void testWriteAndRead();
+ void testWriteAndRead2();
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( ByteArrayDiskWriterTest );
+
+void ByteArrayDiskWriterTest::testWriteAndRead() {
+ ByteArrayDiskWriter bw;
+
+ string msg1 = "Hello world!";
+ bw.writeData(msg1.c_str(), msg1.size(), 0);
+
+ char buf[100];
+ int32_t c = bw.readData(buf, sizeof(buf), 0);
+ buf[c] = '\0';
+
+ CPPUNIT_ASSERT_EQUAL(msg1, string(buf));
+
+ // second call
+ memset(buf, '\0', sizeof(buf));
+
+ c = bw.readData(buf, sizeof(buf), 0);
+ buf[c] = '\0';
+
+ CPPUNIT_ASSERT_EQUAL(msg1, string(buf));
+}
+
+void ByteArrayDiskWriterTest::testWriteAndRead2() {
+ ByteArrayDiskWriter bw;
+
+ string msg1 = "Hello world!";
+ bw.writeData(msg1.c_str(), msg1.size(), 16);
+
+ char buf[100];
+ int32_t c = bw.readData(buf, sizeof(buf), 16);
+ buf[c] = '\0';
+
+ CPPUNIT_ASSERT_EQUAL(msg1, string(buf));
+
+ // second call
+ memset(buf, '\0', sizeof(buf));
+
+ c = bw.readData(buf, sizeof(buf), 16);
+ buf[c] = '\0';
+
+ CPPUNIT_ASSERT_EQUAL(msg1, string(buf));
+}
diff --git a/test/Makefile.am b/test/Makefile.am
index 95ed3f99..b78ea426 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,7 @@
TESTS = aria2c
check_PROGRAMS = $(TESTS)
aria2c_SOURCES = AllTest.cc\
+ ByteArrayDiskWriterTest.cc\
RequestGroupManTest.cc\
IteratableChecksumValidatorTest.cc\
IteratableChunkChecksumValidatorTest.cc\
diff --git a/test/Makefile.in b/test/Makefile.in
index 9f41f7a5..b3c2ae62 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -57,7 +57,9 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__EXEEXT_1 = aria2c$(EXEEXT)
-am_aria2c_OBJECTS = AllTest.$(OBJEXT) RequestGroupManTest.$(OBJEXT) \
+am_aria2c_OBJECTS = AllTest.$(OBJEXT) \
+ ByteArrayDiskWriterTest.$(OBJEXT) \
+ RequestGroupManTest.$(OBJEXT) \
IteratableChecksumValidatorTest.$(OBJEXT) \
IteratableChunkChecksumValidatorTest.$(OBJEXT) \
UriFileListParserTest.$(OBJEXT) PeerTest.$(OBJEXT) \
@@ -265,6 +267,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
TESTS = aria2c
aria2c_SOURCES = AllTest.cc\
+ ByteArrayDiskWriterTest.cc\
RequestGroupManTest.cc\
IteratableChecksumValidatorTest.cc\
IteratableChunkChecksumValidatorTest.cc\
@@ -423,6 +426,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRequestMessageTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSuggestPieceMessageTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessageTest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ByteArrayDiskWriterTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkChecksumValidatorTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncodingTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConsoleFileAllocationMonitorTest.Po@am__quote@