Enhancement - related to, but not fixing bug #293

- Added new attribute modifiers 'word' and 'noword' which find the existence
  of whole words, or prove the non-existence of whole words.  If a task has
  the description "Pay the bill", then "description.word:the" will match, but
  "description.word:th" will not.  For partial word matches, there is still
  "description.contains:th".
- Added unit tests for the text.cpp functions.
- Added unit tests including the new modifiers in filters.
- Added unit tests to parse the new modifiers.
- Modified man page.
- Modified the Context::autoFilter processing to use the new modifiers for
  +tag and -tag filtering.
- Added a support email to an error message, while looking at the filter code.
- Added new modifiers to the help report.
- Modified a utf8.t unit test to include an alphanumeric tag, rather than a
  smiley face.
This commit is contained in:
Paul Beckingham
2009-12-07 01:35:47 -05:00
parent d019126086
commit 7acef0c9fd
12 changed files with 189 additions and 10 deletions

View File

@@ -33,7 +33,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (95);
UnitTest t (97);
Att a;
t.notok (a.valid ("name"), "Att::valid name -> fail");
@@ -146,6 +146,14 @@ int main (int argc, char** argv)
try {a6.mod ("endswith");} catch (...) {good = false;}
t.ok (good, "Att::mod (endswith)");
good = true;
try {a6.mod ("word");} catch (...) {good = false;}
t.ok (good, "Att::mod (word)");
good = true;
try {a6.mod ("noword");} catch (...) {good = false;}
t.ok (good, "Att::mod (noword)");
good = true;
try {a6.mod ("fartwizzle");} catch (...) {good = false;}
t.notok (good, "Att::mod (fartwizzle)");

View File

@@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest test (14);
UnitTest test (20);
// Create a filter consisting of two Att criteria.
Filter f;
@@ -66,6 +66,7 @@ int main (int argc, char** argv)
// Modifiers.
Task mods;
mods.set ("name", "value");
mods.set ("description", "hello, world.");
Att a ("name", "is", "value");
f.clear ();
@@ -124,6 +125,42 @@ int main (int argc, char** argv)
"below"
*/
a = Att ("description", "word", "hello");
f.clear ();
f.push_back (a);
test.ok (f.pass (mods), "description:hello, world. -> description.word:hello = match");
// TODO test inverse.
a = Att ("description", "word", "world");
f.clear ();
f.push_back (a);
test.ok (f.pass (mods), "description:hello, world. -> description.word:world = match");
// TODO test inverse.
a = Att ("description", "word", "pig");
f.clear ();
f.push_back (a);
test.notok (f.pass (mods), "description:hello, world. -> description.word:pig = no match");
// TODO test inverse.
a = Att ("description", "noword", "hello");
f.clear ();
f.push_back (a);
test.notok (f.pass (mods), "description:hello, world. -> description.noword:hello = no match");
// TODO test inverse.
a = Att ("description", "noword", "world");
f.clear ();
f.push_back (a);
test.notok (f.pass (mods), "description:hello, world. -> description.noword:world = no match");
// TODO test inverse.
a = Att ("description", "noword", "pig");
f.clear ();
f.push_back (a);
test.ok (f.pass (mods), "description:hello, world. -> description.noword:pig = match");
// TODO test inverse.
return 0;
}

View File

@@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (117);
UnitTest t (147);
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width)
std::string text = "This is a test of the line wrapping code.";
@@ -267,6 +267,44 @@ int main (int argc, char** argv)
t.notok (noVerticalSpace ("a\rb"), "noVerticalSpace 'a\\rb' -> false");
t.notok (noVerticalSpace ("a\fb"), "noVerticalSpace 'a\\fb' -> false");
text = "Hello, world.";
// 0123456789012
// s e s e
// bool isWordStart (const std::string&, std::string::size_type);
t.notok (isWordStart ("", 0), "isWordStart (\"\", 0) -> false");
t.ok (isWordStart ("foo", 0), "isWordStart (\"foo\", 0) -> true");
t.ok (isWordStart (text, 0), "isWordStart (\"Hello, world.\", 0) -> true");
t.notok (isWordStart (text, 1), "isWordStart (\"Hello, world.\", 1) -> false");
t.notok (isWordStart (text, 2), "isWordStart (\"Hello, world.\", 2) -> false");
t.notok (isWordStart (text, 3), "isWordStart (\"Hello, world.\", 3) -> false");
t.notok (isWordStart (text, 4), "isWordStart (\"Hello, world.\", 4) -> false");
t.notok (isWordStart (text, 5), "isWordStart (\"Hello, world.\", 5) -> false");
t.notok (isWordStart (text, 6), "isWordStart (\"Hello, world.\", 6) -> false");
t.ok (isWordStart (text, 7), "isWordStart (\"Hello, world.\", 7) -> true");
t.notok (isWordStart (text, 8), "isWordStart (\"Hello, world.\", 8) -> false");
t.notok (isWordStart (text, 9), "isWordStart (\"Hello, world.\", 9) -> false");
t.notok (isWordStart (text, 10), "isWordStart (\"Hello, world.\", 10) -> false");
t.notok (isWordStart (text, 11), "isWordStart (\"Hello, world.\", 11) -> false");
t.notok (isWordStart (text, 12), "isWordStart (\"Hello, world.\", 12) -> false");
// bool isWordEnd (const std::string&, std::string::size_type);
t.notok (isWordEnd ("", 0), "isWordEnd (\"\", 0) -> false");
t.ok (isWordEnd ("foo", 2), "isWordEnd (\"foo\", 2) -> true");
t.notok (isWordEnd (text, 0), "isWordEnd (\"Hello, world.\", 0) -> false");
t.notok (isWordEnd (text, 1), "isWordEnd (\"Hello, world.\", 1) -> false");
t.notok (isWordEnd (text, 2), "isWordEnd (\"Hello, world.\", 2) -> false");
t.notok (isWordEnd (text, 3), "isWordEnd (\"Hello, world.\", 3) -> false");
t.ok (isWordEnd (text, 4), "isWordEnd (\"Hello, world.\", 4) -> true");
t.notok (isWordEnd (text, 5), "isWordEnd (\"Hello, world.\", 5) -> false");
t.notok (isWordEnd (text, 6), "isWordEnd (\"Hello, world.\", 6) -> false");
t.notok (isWordEnd (text, 7), "isWordEnd (\"Hello, world.\", 7) -> false");
t.notok (isWordEnd (text, 8), "isWordEnd (\"Hello, world.\", 8) -> false");
t.notok (isWordEnd (text, 9), "isWordEnd (\"Hello, world.\", 9) -> false");
t.notok (isWordEnd (text, 10), "isWordEnd (\"Hello, world.\", 10) -> false");
t.ok (isWordEnd (text, 11), "isWordEnd (\"Hello, world.\", 11) -> true");
t.notok (isWordEnd (text, 12), "isWordEnd (\"Hello, world.\", 12) -> false");
return 0;
}

View File

@@ -65,8 +65,8 @@ qx{../task rc:utf8.rc add project:Çirçös utf8 in project};
$output = qx{../task rc:utf8.rc ls project:Çirçös};
like ($output, qr/Çirçös.+utf8 in project/, 'utf8 in project works');
qx{../task rc:utf8.rc add utf8 in tag +};
$output = qx{../task rc:utf8.rc ls +};
qx{../task rc:utf8.rc add utf8 in tag +Zwölf};
$output = qx{../task rc:utf8.rc ls +Zwölf};
like ($output, qr/utf8 in tag/, 'utf8 in tag works');
# Cleanup.