Prechádzať zdrojové kódy

2008-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Fixed compile error when configured with --disable-metalink.
	Also moved test/DownloadHandlerFactoryTest.cc to SRC in 
Makefile.am.
	* test/FeatureConfigTest.cc
	* test/DownloadHandlerFactoryTest.cc
Tatsuhiro Tsujikawa 17 rokov pred
rodič
commit
bf58b49d87
3 zmenil súbory, kde vykonal 42 pridanie a 17 odobranie
  1. 7 0
      ChangeLog
  2. 9 0
      test/DownloadHandlerFactoryTest.cc
  3. 26 17
      test/FeatureConfigTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2008-05-20  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Fixed compile error when configured with --disable-metalink.
+	Also moved test/DownloadHandlerFactoryTest.cc to SRC in Makefile.am.
+	* test/FeatureConfigTest.cc
+	* test/DownloadHandlerFactoryTest.cc
+
 2008-05-20  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed compile error when configured with --without-gnutls

+ 9 - 0
test/DownloadHandlerFactoryTest.cc

@@ -11,8 +11,10 @@ namespace aria2 {
 class DownloadHandlerFactoryTest:public CppUnit::TestFixture {
 
   CPPUNIT_TEST_SUITE(DownloadHandlerFactoryTest);
+#ifdef ENABLE_METALINK
   CPPUNIT_TEST(testGetMetalinkPreDownloadHandler_extension);
   CPPUNIT_TEST(testGetMetalinkPreDownloadHandler_contentType);
+#endif // ENABLE_METALINK
   CPPUNIT_TEST(testGetBtPreDownloadHandler_extension);
   CPPUNIT_TEST(testGetBtPreDownloadHandler_contentType);
   CPPUNIT_TEST_SUITE_END();
@@ -21,8 +23,11 @@ private:
 public:
   void setUp() {}
 
+#ifdef ENABLE_METALINK
   void testGetMetalinkPreDownloadHandler_extension();
   void testGetMetalinkPreDownloadHandler_contentType();
+#endif // ENABLE_METALINK
+
   void testGetBtPreDownloadHandler_extension();
   void testGetBtPreDownloadHandler_contentType();
 };
@@ -30,6 +35,8 @@ public:
 
 CPPUNIT_TEST_SUITE_REGISTRATION( DownloadHandlerFactoryTest );
 
+#ifdef ENABLE_METALINK
+
 void DownloadHandlerFactoryTest::testGetMetalinkPreDownloadHandler_extension()
 {
   Option op;
@@ -63,6 +70,8 @@ void DownloadHandlerFactoryTest::testGetMetalinkPreDownloadHandler_contentType()
   CPPUNIT_ASSERT(!handler->canHandle(&rg));
 }
 
+#endif // ENABLE_METALINK
+
 void DownloadHandlerFactoryTest::testGetBtPreDownloadHandler_extension()
 {
   Option op;

+ 26 - 17
test/FeatureConfigTest.cc

@@ -1,4 +1,8 @@
 #include "FeatureConfig.h"
+#include "a2functional.h"
+#include "array_fun.h"
+#include "Util.h"
+#include <algorithm>
 #include <cppunit/extensions/HelperMacros.h>
 
 namespace aria2 {
@@ -44,33 +48,38 @@ void FeatureConfigTest::testIsSupported() {
 }
 
 void FeatureConfigTest::testFeatureSummary() {
-  CPPUNIT_ASSERT_EQUAL(
+  const std::string features[] = {
+
 #ifdef ENABLE_ASYNC_DNS
-		       std::string("Async DNS, ")
-#else
-		       std::string()
+    "Async DNS",
 #endif // ENABLE_ASYNC_DNS
+
 #ifdef ENABLE_BITTORRENT
-		       +std::string("BitTorrent, ")
-#else
-		       +std::string()
+    "BitTorrent",
 #endif // ENABLE_BITTORRENT
+
 #ifdef ENABLE_SSL
-		       +std::string("HTTPS, ")
-#else
-		       +std::string()
+    "HTTPS",
 #endif // ENABLE_SSL
+
 #ifdef ENABLE_MESSAGE_DIGEST
-		       +std::string("Message Digest, ")
-#else
-		       +std::string()
+    "Message Digest",
 #endif // ENABLE_MESSAGE_DIGEST
+
 #ifdef ENABLE_METALINK
-		       +std::string("Metalink")
-#else
-		       +std::string()
+    "Metalink",
 #endif // ENABLE_METALINK
-		       ,
+
+  };
+
+  std::string featuresString;
+  const std::string delim(", ");
+  std::for_each(&features[0], &features[arrayLength(features)],
+		StringAppend(featuresString, delim));
+  // USE Util::trimSelf(featureString);
+  featuresString = Util::trim(featuresString, delim);
+  
+  CPPUNIT_ASSERT_EQUAL(featuresString,
 		       FeatureConfig::getInstance()->featureSummary());
 }