mirror of https://github.com/aria2/aria2
2008-01-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added the message to inform users that other help categories are available in -h option. * src/version_usage.cc * src/TagContainer.{h, cc} * test/TagContainerTest.cc * src/TaggedItem.{h, cc} * test/TaggedItemTest.cc * src/HelpItem.hpull/1/head
parent
1a4100cbc9
commit
08a8d8aae2
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2008-01-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Added the message to inform users that other help categories are
|
||||
available in -h option.
|
||||
* src/version_usage.cc
|
||||
* src/TagContainer.{h, cc}
|
||||
* test/TagContainerTest.cc
|
||||
* src/TaggedItem.{h, cc}
|
||||
* test/TaggedItemTest.cc
|
||||
* src/HelpItem.h
|
||||
|
||||
2008-01-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Added Piece::getFirstMissingBlockIndexWithoutLock() and it is called
|
||||
|
|
|
@ -61,6 +61,11 @@ public:
|
|||
_availableValues = availableValues;
|
||||
}
|
||||
|
||||
const string& getAvailableValues() const
|
||||
{
|
||||
return _availableValues;
|
||||
}
|
||||
|
||||
friend ostream& operator<<(ostream& o, const HelpItem& helpItem);
|
||||
|
||||
friend ostream& operator<<(ostream& o, const HelpItemHandle& helpItem);
|
||||
|
|
|
@ -95,6 +95,16 @@ TaggedItems TagContainer::nameMatchForward(const string& name) const
|
|||
return for_each(_taggedItems.begin(), _taggedItems.end(), NameMatchForward(name)).getResult();
|
||||
}
|
||||
|
||||
TaggedItemHandle TagContainer::nameMatch(const string& name) const
|
||||
{
|
||||
TaggedItems::const_iterator itr = find(_taggedItems.begin(), _taggedItems.end(), TaggedItemHandle(new TaggedItem(name)));
|
||||
if(itr == _taggedItems.end()) {
|
||||
return 0;
|
||||
} else {
|
||||
return *itr;
|
||||
}
|
||||
}
|
||||
|
||||
const TaggedItems& TagContainer::getAllItems() const
|
||||
{
|
||||
return _taggedItems;
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
|
||||
TaggedItems nameMatchForward(const string& name) const;
|
||||
|
||||
TaggedItemHandle nameMatch(const string& name) const;
|
||||
|
||||
const TaggedItems& getAllItems() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -65,3 +65,8 @@ bool TaggedItem::operator<(const TaggedItem& item) const
|
|||
{
|
||||
return _name < item._name;
|
||||
}
|
||||
|
||||
bool TaggedItem::operator==(const TaggedItem& item) const
|
||||
{
|
||||
return _name == item._name;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
class TaggedItem;
|
||||
typedef SharedHandle<TaggedItem> TaggedItemHandle;
|
||||
|
||||
class TaggedItem {
|
||||
private:
|
||||
string _name;
|
||||
|
@ -62,8 +65,9 @@ public:
|
|||
}
|
||||
|
||||
bool operator<(const TaggedItem& item) const;
|
||||
|
||||
bool operator==(const TaggedItem& item) const;
|
||||
};
|
||||
|
||||
typedef SharedHandle<TaggedItem> TaggedItemHandle;
|
||||
typedef deque<TaggedItemHandle> TaggedItems;
|
||||
#endif // _D_TAGGED_ITEM_H_
|
||||
|
|
|
@ -106,6 +106,9 @@ void showUsage(const string& category) {
|
|||
printf(_("Printing all options."));
|
||||
} else {
|
||||
printf(_("Printing options tagged with '%s'."), category.c_str());
|
||||
cout << "\n";
|
||||
printf(_("See -h option to know other command-line options(%s)."),
|
||||
HelpItemHandle(tc->nameMatch("help"))->getAvailableValues().c_str());
|
||||
}
|
||||
cout << "\n";
|
||||
cout << _("Options:") << endl;
|
||||
|
@ -120,7 +123,7 @@ void showUsage(const string& category) {
|
|||
} else {
|
||||
printf(_("No help category or option name matching with '%s'."), category.c_str());
|
||||
cout << "\n";
|
||||
cout << HelpItemHandle(tc->nameMatchForward("help").front()) << "\n";
|
||||
cout << HelpItemHandle(tc->nameMatch("help")) << "\n";
|
||||
}
|
||||
}
|
||||
if(category == TAG_BASIC) {
|
||||
|
|
|
@ -8,13 +8,14 @@ class TagContainerTest:public CppUnit::TestFixture {
|
|||
|
||||
CPPUNIT_TEST_SUITE(TagContainerTest);
|
||||
CPPUNIT_TEST(testSearch);
|
||||
CPPUNIT_TEST(testNameMatch);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp() {}
|
||||
|
||||
void testSearch();
|
||||
void testNameMatch();
|
||||
};
|
||||
|
||||
|
||||
|
@ -47,3 +48,23 @@ void TagContainerTest::testSearch()
|
|||
CPPUNIT_ASSERT_EQUAL(string("foo"), res[0]->toTagString());
|
||||
}
|
||||
}
|
||||
|
||||
void TagContainerTest::testNameMatch()
|
||||
{
|
||||
TaggedItemHandle items[] = {
|
||||
new TaggedItem("alpha"),
|
||||
new TaggedItem("bravo"),
|
||||
new TaggedItem("charlie"),
|
||||
new TaggedItem("bravo")
|
||||
};
|
||||
items[1]->addTag("foo");
|
||||
TagContainer tc(TaggedItems(&items[0], &items[3]));
|
||||
{
|
||||
TaggedItemHandle item = tc.nameMatch("bravo");
|
||||
CPPUNIT_ASSERT_EQUAL(string("bravo"), item->getName());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo"), item->toTagString());
|
||||
}
|
||||
{
|
||||
CPPUNIT_ASSERT(tc.nameMatch("delta").isNull());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class TaggedItemTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST_SUITE(TaggedItemTest);
|
||||
CPPUNIT_TEST(testHasTag);
|
||||
CPPUNIT_TEST(testToTagString);
|
||||
CPPUNIT_TEST(testOperatorEqual);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
|
@ -14,6 +15,7 @@ public:
|
|||
|
||||
void testHasTag();
|
||||
void testToTagString();
|
||||
void testOperatorEqual();
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,3 +39,14 @@ void TaggedItemTest::testToTagString()
|
|||
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo,bar"), item.toTagString());
|
||||
}
|
||||
|
||||
void TaggedItemTest::testOperatorEqual()
|
||||
{
|
||||
TaggedItem none("");
|
||||
TaggedItem foo("foo");
|
||||
TaggedItem foo2("foo");
|
||||
TaggedItem bar("bar");
|
||||
CPPUNIT_ASSERT(!(none == foo));
|
||||
CPPUNIT_ASSERT(!(bar == foo));
|
||||
CPPUNIT_ASSERT(foo == foo);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue