mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Task Data Parsing
- Improved the handling when parsing blank lines and empty task in the data, so that instead of the message: Taskwarrior no longer supports file format 1, originally used between 27 November 2006 and 31 December 2007. We now see: Unrecognized Taskwarrior file format or blank line in data. - Merged t2.t.cpp into t.t.cpp.
This commit is contained in:
parent
603843821b
commit
bb58b796fd
8 changed files with 73 additions and 125 deletions
|
@ -1676,10 +1676,10 @@ int Task::determineVersion (const std::string& line)
|
|||
// X [tags] [attributes] description\n
|
||||
//
|
||||
// Scan for the first character being either the bracket or X.
|
||||
else if (line.find ("X [") == 0 ||
|
||||
line.find ("uuid") == std::string::npos ||
|
||||
(line[0] == '[' &&
|
||||
line.substr (line.length () - 1, 1) != "]"))
|
||||
else if (line.find ("X [") == 0 ||
|
||||
(line[0] == '[' &&
|
||||
line.substr (line.length () - 1, 1) != "]" &&
|
||||
line.length () > 3))
|
||||
return 1;
|
||||
|
||||
// Version 5?
|
||||
|
|
|
@ -839,7 +839,7 @@
|
|||
#define STRING_TASK_NO_FF1 "Taskwarrior no longer supports file format 1, originally used between 27 November 2006 and 31 December 2007."
|
||||
#define STRING_TASK_NO_FF2 "Taskwarrior no longer supports file format 2, originally used between 1 January 2008 and 12 April 2009."
|
||||
#define STRING_TASK_NO_FF3 "Taskwarrior no longer supports file format 3, originally used between 23 March 2009 and 16 May 2009."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized Taskwarrior file format."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized Taskwarrior file format or blank line in data."
|
||||
#define STRING_TASK_DEPEND_ITSELF "A task cannot be dependent on itself."
|
||||
#define STRING_TASK_DEPEND_MISS_CREA "Could not create a dependency on task {1} - not found."
|
||||
#define STRING_TASK_DEPEND_MISS_DEL "Could not delete a dependency on task {1} - not found."
|
||||
|
|
|
@ -841,7 +841,7 @@
|
|||
#define STRING_TASK_NO_FF1 "Taskwarrior no longer supports file format 1, originally used between 27 November 2006 and 31 December 2007."
|
||||
#define STRING_TASK_NO_FF2 "Taskwarrior no longer supports file format 2, originally used between 1 January 2008 and 12 April 2009."
|
||||
#define STRING_TASK_NO_FF3 "Taskwarrior no longer supports file format 3, originally used between 23 March 2009 and 16 May 2009."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized taskwarrior file format."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized Taskwarrior file format or blank line in data."
|
||||
#define STRING_TASK_DEPEND_ITSELF "A task cannot be dependent on itself."
|
||||
#define STRING_TASK_DEPEND_MISS_CREA "Could not create a dependency on task {1} - not found."
|
||||
#define STRING_TASK_DEPEND_MISS_DEL "Could not delete a dependency on task {1} - not found."
|
||||
|
|
|
@ -841,7 +841,7 @@
|
|||
#define STRING_TASK_NO_FF1 "Taskwarrior no longer supports file format 1, originally used between 27 November 2006 and 31 December 2007."
|
||||
#define STRING_TASK_NO_FF2 "Taskwarrior no longer supports file format 2, originally used between 1 January 2008 and 12 April 2009."
|
||||
#define STRING_TASK_NO_FF3 "Taskwarrior no longer supports file format 3, originally used between 23 March 2009 and 16 May 2009."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized taskwarrior file format."
|
||||
#define STRING_TASK_PARSE_UNREC_FF "Unrecognized Taskwarrior file format or blank line in data."
|
||||
#define STRING_TASK_DEPEND_ITSELF "A task cannot be dependent on itself."
|
||||
#define STRING_TASK_DEPEND_MISS_CREA "Could not create a dependency on task {1} - not found."
|
||||
#define STRING_TASK_DEPEND_MISS_DEL "Could not delete a dependency on task {1} - not found."
|
||||
|
|
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
@ -20,7 +20,6 @@ msg.t
|
|||
nibbler.t
|
||||
rx.t
|
||||
t.t
|
||||
t2.t
|
||||
t3.t
|
||||
taskmod.t
|
||||
tdb2.t
|
||||
|
|
|
@ -10,7 +10,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
${TASK_INCLUDE_DIRS})
|
||||
|
||||
set (test_SRCS autocomplete.t col.t color.t config.t fs.t i18n.t json.t list.t
|
||||
msg.t nibbler.t rx.t t.t t2.t t3.t tdb2.t text.t utf8.t util.t
|
||||
msg.t nibbler.t rx.t t.t t3.t tdb2.t text.t utf8.t util.t
|
||||
view.t json_test lexer.t iso8601d.t iso8601p.t eval.t dates.t
|
||||
variant_add.t variant_and.t variant_cast.t variant_divide.t
|
||||
variant_equal.t variant_exp.t variant_gt.t variant_gte.t
|
||||
|
|
70
test/t.t.cpp
70
test/t.t.cpp
|
@ -34,7 +34,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest test (23);
|
||||
UnitTest test (40);
|
||||
|
||||
// Ensure environment has no influence.
|
||||
unsetenv ("TASKDATA");
|
||||
|
@ -151,11 +151,71 @@ TODO Task::decode
|
|||
left.set ("one", "1.0");
|
||||
test.notok (left == right, "left == right -> false");
|
||||
|
||||
// Task::validate
|
||||
Task bad ("[entry:1000000001 start:1000000000]");
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Task task;
|
||||
|
||||
// (blank)
|
||||
good = true;
|
||||
try { bad.validate (); } catch (...) { good = false; }
|
||||
test.notok (good, "Task::validate entry <= start");
|
||||
try {task = Task ("");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.notok (good, "Task::Task ('')");
|
||||
|
||||
// []
|
||||
good = true;
|
||||
try {task = Task ("[]");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.notok (good, "Task::Task ('[]')");
|
||||
|
||||
// [name:"value"]
|
||||
good = true;
|
||||
try {task = Task ("[name:\"value\"]");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('[name:\"value\"]')");
|
||||
test.is (task.get ("name"), "value", "name=value");
|
||||
|
||||
// [name:"one two"]
|
||||
good = true;
|
||||
try {task = Task ("[name:\"one two\"]");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('[name:\"one two\"]')");
|
||||
test.is (task.get ("name"), "one two", "name=one two");
|
||||
|
||||
// [one:two three:four]
|
||||
good = true;
|
||||
try {task = Task ("[one:\"two\" three:\"four\"]");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('[one:\"two\" three:\"four\"]')");
|
||||
test.is (task.get ("one"), "two", "one=two");
|
||||
test.is (task.get ("three"), "four", "three=four");
|
||||
|
||||
// Task::set
|
||||
task.clear ();
|
||||
task.set ("name", "value");
|
||||
test.is (task.composeF4 (), "[name:\"value\"]", "Task::set");
|
||||
|
||||
// Task::has
|
||||
test.ok (task.has ("name"), "Task::has");
|
||||
test.notok (task.has ("woof"), "Task::has not");
|
||||
|
||||
// Task::get_int
|
||||
task.set ("one", 1);
|
||||
test.is (task.composeF4 (), "[name:\"value\" one:\"1\"]", "Task::set");
|
||||
test.is (task.get_int ("one"), 1, "Task::get_int");
|
||||
|
||||
// Task::get_ulong
|
||||
task.set ("two", "4294967295");
|
||||
test.is (task.composeF4 (), "[name:\"value\" one:\"1\" two:\"4294967295\"]", "Task::set");
|
||||
test.is ((size_t)task.get_ulong ("two"), (size_t)4294967295UL, "Task::get_ulong");
|
||||
|
||||
// Task::remove
|
||||
task.remove ("one");
|
||||
task.remove ("two");
|
||||
test.is (task.composeF4 (), "[name:\"value\"]", "Task::remove");
|
||||
|
||||
// Task::all
|
||||
test.is (task.size (), (size_t)1, "Task::all size");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
111
test/t2.t.cpp
111
test/t2.t.cpp
|
@ -1,111 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <Task.h>
|
||||
#include <test.h>
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (18);
|
||||
|
||||
// Ensure environment has no influence.
|
||||
unsetenv ("TASKDATA");
|
||||
unsetenv ("TASKRC");
|
||||
|
||||
// (blank)
|
||||
bool good = true;
|
||||
Task task;
|
||||
|
||||
try {task = Task ("");}
|
||||
catch (const std::string& e){t.diag (e); good = false;}
|
||||
t.notok (good, "Task::Task ('')");
|
||||
|
||||
// []
|
||||
good = true;
|
||||
try {task = Task ("[]");}
|
||||
catch (const std::string& e){t.diag (e); good = false;}
|
||||
t.notok (good, "Task::Task ('[]')");
|
||||
|
||||
// [name:"value"]
|
||||
good = true;
|
||||
try {task = Task ("[name:\"value\"]");}
|
||||
catch (const std::string& e){t.diag (e); good = false;}
|
||||
t.ok (good, "Task::Task ('[name:\"value\"]')");
|
||||
t.is (task.get ("name"), "value", "name=value");
|
||||
|
||||
// [name:"one two"]
|
||||
good = true;
|
||||
try {task = Task ("[name:\"one two\"]");}
|
||||
catch (const std::string& e){t.diag (e); good = false;}
|
||||
t.ok (good, "Task::Task ('[name:\"one two\"]')");
|
||||
t.is (task.get ("name"), "one two", "name=one two");
|
||||
|
||||
// [one:two three:four]
|
||||
good = true;
|
||||
try {task = Task ("[one:\"two\" three:\"four\"]");}
|
||||
catch (const std::string& e){t.diag (e); good = false;}
|
||||
t.ok (good, "Task::Task ('[one:\"two\" three:\"four\"]')");
|
||||
t.is (task.get ("one"), "two", "one=two");
|
||||
t.is (task.get ("three"), "four", "three=four");
|
||||
|
||||
// Task::set
|
||||
task.clear ();
|
||||
task.set ("name", "value");
|
||||
t.is (task.composeF4 (), "[name:\"value\"]", "Task::set");
|
||||
|
||||
// Task::has
|
||||
t.ok (task.has ("name"), "Task::has");
|
||||
t.notok (task.has ("woof"), "Task::has not");
|
||||
|
||||
// Task::get_int
|
||||
task.set ("one", 1);
|
||||
t.is (task.composeF4 (), "[name:\"value\" one:\"1\"]", "Task::set");
|
||||
t.is (task.get_int ("one"), 1, "Task::get_int");
|
||||
|
||||
// Task::get_ulong
|
||||
task.set ("two", "4294967295");
|
||||
t.is (task.composeF4 (), "[name:\"value\" one:\"1\" two:\"4294967295\"]", "Task::set");
|
||||
t.is ((size_t)task.get_ulong ("two"), (size_t)4294967295UL, "Task::get_ulong");
|
||||
|
||||
// Task::remove
|
||||
task.remove ("one");
|
||||
task.remove ("two");
|
||||
t.is (task.composeF4 (), "[name:\"value\"]", "Task::remove");
|
||||
|
||||
// Task::all
|
||||
t.is (task.size (), (size_t)1, "Task::all size");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue