mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Expressions
- Fixed some compiler warnings. - Added DOM detection of primitives: int, double, string. - Began implementation of DOM task access. - Implemented support for .startswith, .endswith, .word and .noword. - Removed obsolete subst.t.cpp.
This commit is contained in:
parent
199bb85d88
commit
2ab24fa08b
8 changed files with 119 additions and 191 deletions
|
@ -8,8 +8,8 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
|
||||
set (test_SRCS arguments.t att.t autocomplete.t color.t config.t date.t
|
||||
directory.t dom.t duration.t file.t filt.t i18n.t json.t lexer.t
|
||||
list.t nibbler.t path.t record.t rx.t seq.t subst.t t.benchmark.t
|
||||
t.t taskmod.t tdb.t tdb2.t text.t uri.t util.t variant.t view.t
|
||||
list.t nibbler.t path.t record.t rx.t seq.t t.benchmark.t t.t
|
||||
taskmod.t tdb.t tdb2.t text.t uri.t util.t variant.t view.t
|
||||
json_test)
|
||||
|
||||
add_custom_target (test ./run_all DEPENDS ${test_SRCS}
|
||||
|
|
151
test/subst.t.cpp
151
test/subst.t.cpp
|
@ -1,151 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <Context.h>
|
||||
#include <Task.h>
|
||||
#include <Subst.h>
|
||||
#include <test.h>
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (18);
|
||||
|
||||
Task task;
|
||||
task.set ("description", "one two three four");
|
||||
|
||||
context.config.set ("search.case.sensitive", "yes");
|
||||
|
||||
Subst s;
|
||||
t.ok (s.valid ("/a/b/"), "valid /a/b/");
|
||||
t.ok (s.valid ("/two/TWO/"), "valid /two/TWO/");
|
||||
t.ok (s.valid ("/e /E /g"), "valid /e /E /g");
|
||||
t.ok (s.valid ("/from/to/g"), "valid /from/to/g");
|
||||
t.ok (s.valid ("/long string//"), "valid /long string//");
|
||||
t.ok (s.valid ("//fail/"), "valid //fail/");
|
||||
|
||||
bool good = true;
|
||||
try { s.parse ("/a/b/x"); } catch (...) { good = false; }
|
||||
t.notok (good, "failed /a/b/x");
|
||||
|
||||
good = true;
|
||||
try { s.parse ("//to/"); } catch (...) { good = false; }
|
||||
t.notok (good, "failed //to/");
|
||||
|
||||
good = true;
|
||||
try { s.parse ("/two/TWO/"); } catch (...) { good = false; }
|
||||
t.ok (good, "parsed /two/TWO/");
|
||||
if (good)
|
||||
{
|
||||
std::string description = task.get ("description");
|
||||
std::vector <Att> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
s.apply (description, annotations);
|
||||
t.is (description, "one TWO three four", "single word subst");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/two/TWO/'");
|
||||
}
|
||||
|
||||
good = true;
|
||||
try { s.parse ("/e /E /g"); } catch (...) { good = false; }
|
||||
t.ok (good, "parsed /e /E /g");
|
||||
if (good)
|
||||
{
|
||||
std::string description = task.get ("description");
|
||||
std::vector <Att> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
s.apply (description, annotations);
|
||||
t.is (description, "onE two threE four", "multiple word subst");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/e /E /g'");
|
||||
}
|
||||
|
||||
// Now repeat the last two tests with a case-insensitive setting.
|
||||
context.config.set ("search.case.sensitive", "no");
|
||||
good = true;
|
||||
try { s.parse ("/tWo/TWO/"); } catch (...) { good = false; }
|
||||
t.ok (good, "parsed /tWo/TWO/ (rc.search.case.sensitive=no)");
|
||||
if (good)
|
||||
{
|
||||
std::string description = task.get ("description");
|
||||
std::vector <Att> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
s.apply (description, annotations);
|
||||
t.is (description, "one TWO three four", "single word subst (rc.search.case.sensitive=no)");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/tWo/TWO/' (rc.search.case.sensitive=no)");
|
||||
}
|
||||
|
||||
good = true;
|
||||
try { s.parse ("/E /E /g"); } catch (...) { good = false; }
|
||||
t.ok (good, "parsed /E /E /g (rc.search.case.sensitive=no)");
|
||||
if (good)
|
||||
{
|
||||
std::string description = task.get ("description");
|
||||
std::vector <Att> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
s.apply (description, annotations);
|
||||
t.is (description, "onE two threE four", "multiple word subst (rc.search.case.sensitive=no)");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/E /E /g' (rc.search.case.sensitive=no)");
|
||||
}
|
||||
|
||||
context.config.set ("search.case.sensitive", "yes");
|
||||
good = true;
|
||||
try { s.parse ("/from/to/g"); } catch (...) { good = false; }
|
||||
t.ok (good, "parsed /from/to/g");
|
||||
if (good)
|
||||
{
|
||||
std::string description = task.get ("description");
|
||||
std::vector <Att> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
s.apply (description, annotations);
|
||||
t.is (description, "one two three four", "multiple word subst mismatch");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/from/to/g'");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -38,8 +38,9 @@ void get (std::vector <Task>& pending, std::vector <Task>& completed)
|
|||
TDB tdb;
|
||||
tdb.location (".");
|
||||
tdb.lock ();
|
||||
tdb.loadPending (pending, context.filter);
|
||||
tdb.loadCompleted (completed, context.filter);
|
||||
Filter filter;
|
||||
tdb.loadPending (pending, filter);
|
||||
tdb.loadCompleted (completed, filter);
|
||||
tdb.unlock ();
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@ int main (int argc, char** argv)
|
|||
completed.clear ();
|
||||
|
||||
tdb.lock ();
|
||||
tdb.load (all, context.filter);
|
||||
tdb.load (all, filter);
|
||||
all[0].set ("name", "value2");
|
||||
tdb.update (all[0]); // P1 C0 N0 M1
|
||||
tdb.commit (); // P1 C0 N0 M0
|
||||
|
@ -117,7 +118,7 @@ int main (int argc, char** argv)
|
|||
all.clear ();
|
||||
|
||||
tdb.lock ();
|
||||
tdb.loadPending (all, context.filter);
|
||||
tdb.loadPending (all, filter);
|
||||
all[0].setStatus (Task::completed);
|
||||
tdb.update (all[0]); // P1 C0 N0 M1
|
||||
Task t2 ("[foo:\"bar\" status:\"pending\"]");
|
||||
|
|
|
@ -38,8 +38,9 @@ void get (std::vector <Task>& pending, std::vector <Task>& completed)
|
|||
TDB tdb;
|
||||
tdb.location (".");
|
||||
tdb.lock ();
|
||||
tdb.loadPending (pending, context.filter);
|
||||
tdb.loadCompleted (completed, context.filter);
|
||||
Filter filter;
|
||||
tdb.loadPending (pending, filter);
|
||||
tdb.loadCompleted (completed, filter);
|
||||
tdb.unlock ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue