mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- All objects now use the same convention for naming members. The consistency is a good thing.
This commit is contained in:
parent
fb6dc5058f
commit
dab06f8672
53 changed files with 1347 additions and 1349 deletions
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
@ -24,7 +24,6 @@ rx.t
|
|||
sensor.t
|
||||
seq.t
|
||||
subst.t
|
||||
t.benchmark.t
|
||||
t.t
|
||||
t2.t
|
||||
taskmod.t
|
||||
|
|
|
@ -8,8 +8,8 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
|
||||
set (test_SRCS att.t autocomplete.t color.t config.t date.t directory.t dom.t
|
||||
duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t
|
||||
t.benchmark.t t.t t2.t taskmod.t tdb.t tdb2.t text.t uri.t util.t
|
||||
view.t json_test)
|
||||
t.t t2.t taskmod.t tdb.t tdb2.t text.t uri.t util.t view.t
|
||||
json_test)
|
||||
|
||||
add_custom_target (test ./run_all DEPENDS ${test_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
|
||||
|
|
|
@ -41,20 +41,20 @@ int main (int argc, char** argv)
|
|||
Directory d0 (Path ("/tmp"));
|
||||
Directory d1 (File ("/tmp"));
|
||||
Directory d2 (File (Path ("/tmp")));
|
||||
t.is (d0.data, d1.data, "Directory(std::string) == Directory (File&)");
|
||||
t.is (d0.data, d2.data, "Directory(std::string) == Directory (File (Path &))");
|
||||
t.is (d1.data, d2.data, "Directory(File&)) == Directory (File (Path &))");
|
||||
t.is (d0._data, d1._data, "Directory(std::string) == Directory (File&)");
|
||||
t.is (d0._data, d2._data, "Directory(std::string) == Directory (File (Path &))");
|
||||
t.is (d1._data, d2._data, "Directory(File&)) == Directory (File (Path &))");
|
||||
|
||||
// Directory (const Directory&);
|
||||
Directory d3 (d2);
|
||||
t.is (d3.data, "/tmp", "Directory (Directory&)");
|
||||
t.is (d3._data, "/tmp", "Directory (Directory&)");
|
||||
|
||||
// Directory (const std::string&);
|
||||
Directory d4 ("/tmp/test_directory");
|
||||
|
||||
// Directory& operator= (const Directory&);
|
||||
Directory d5 = d4;
|
||||
t.is (d5.data, "/tmp/test_directory", "Directory::operator=");
|
||||
t.is (d5._data, "/tmp/test_directory", "Directory::operator=");
|
||||
|
||||
// operator (std::string) const;
|
||||
t.is ((std::string) d3, "/tmp", "Directory::operator (std::string) const");
|
||||
|
@ -63,11 +63,11 @@ int main (int argc, char** argv)
|
|||
t.ok (d5.create (), "Directory::create /tmp/test_directory");
|
||||
t.ok (d5.exists (), "Directory::exists /tmp/test_directory");
|
||||
|
||||
Directory d6 (d5.data + "/dir");
|
||||
Directory d6 (d5._data + "/dir");
|
||||
t.ok (d6.create (), "Directory::create /tmp/test_directory/dir");
|
||||
|
||||
File::create (d5.data + "/f0");
|
||||
File::create (d6.data + "/f1");
|
||||
File::create (d5._data + "/f0");
|
||||
File::create (d6._data + "/f1");
|
||||
|
||||
// std::vector <std::string> list ();
|
||||
std::vector <std::string> files = d5.list ();
|
||||
|
@ -84,8 +84,8 @@ int main (int argc, char** argv)
|
|||
t.is (files[1], "/tmp/test_directory/f0", "file is /tmp/test_directory/f0");
|
||||
|
||||
// virtual bool remove ();
|
||||
t.ok (File::remove (d5.data + "/f0"), "File::remove /tmp/test_directory/f0");
|
||||
t.ok (File::remove (d6.data + "/f1"), "File::remove /tmp/test_directory/dir/f1");
|
||||
t.ok (File::remove (d5._data + "/f0"), "File::remove /tmp/test_directory/f0");
|
||||
t.ok (File::remove (d6._data + "/f1"), "File::remove /tmp/test_directory/dir/f1");
|
||||
|
||||
t.ok (d6.remove (), "Directory::remove /tmp/test_directory/dir");
|
||||
t.notok (d6.exists (), "Directory::exists /tmp/test_directory/dir - no");
|
||||
|
@ -96,10 +96,10 @@ int main (int argc, char** argv)
|
|||
// bool remove (const std::string&);
|
||||
Directory d7 ("/tmp/to_be_removed");
|
||||
t.ok (d7.create (), "Directory::create /tmp/to_be_removed");
|
||||
File::create (d7.data + "/f0");
|
||||
Directory d8 (d7.data + "/another");
|
||||
File::create (d7._data + "/f0");
|
||||
Directory d8 (d7._data + "/another");
|
||||
t.ok (d8.create (), "Directory::create /tmp/to_be_removed/another");
|
||||
File::create (d8.data + "/f1");
|
||||
File::create (d8._data + "/f1");
|
||||
t.ok (d7.remove (), "Directory::remove /tmp/to_be_removed");
|
||||
t.notok (d7.exists (), "Directory /tmp/to_be_removed gone");
|
||||
|
||||
|
|
|
@ -37,22 +37,22 @@ int main (int argc, char** argv)
|
|||
|
||||
// Path ();
|
||||
Path p0;
|
||||
t.ok (p0.data == "", "Path::Path");
|
||||
t.ok (p0._data == "", "Path::Path");
|
||||
|
||||
// Path (const Path&);
|
||||
Path p1 = Path ("foo");
|
||||
t.ok (p1.data == "foo", "Path::operator=");
|
||||
t.ok (p1._data == "foo", "Path::operator=");
|
||||
|
||||
// Path (const std::string&);
|
||||
Path p2 ("~");
|
||||
t.ok (p2.data != "~", "~ expanded to " + p2.data);
|
||||
t.ok (p2._data != "~", "~ expanded to " + p2._data);
|
||||
|
||||
Path p3 ("/tmp");
|
||||
t.ok (p3.data == "/tmp", "/tmp -> /tmp");
|
||||
t.ok (p3._data == "/tmp", "/tmp -> /tmp");
|
||||
|
||||
// Path& operator= (const Path&);
|
||||
Path p3_copy (p3);
|
||||
t.is (p3.data, p3_copy.data, "Path::Path (Path&)");
|
||||
t.is (p3._data, p3_copy._data, "Path::Path (Path&)");
|
||||
|
||||
// operator (std::string) const;
|
||||
t.is ((std::string) p3, "/tmp", "Path::operator (std::string) const");
|
||||
|
|
|
@ -39,41 +39,41 @@ int main (int argc, char** argv)
|
|||
|
||||
Uri uri1 ("asfd://user@host/folder/");
|
||||
uri1.parse ();
|
||||
t.is (uri1.user, "user", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1.host, "host", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1.port, "", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1.path, "folder/", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1.protocol, "asfd", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1._user, "user", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1._host, "host", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1._port, "", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1._path, "folder/", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.is (uri1._protocol, "asfd", "Uri::parse() : asdf://user@host/folder/");
|
||||
t.ok (uri1.append ("file.test"), "Uri::append() to path");
|
||||
t.is (uri1.path, "folder/file.test", "Uri::append() ok");
|
||||
t.is (uri1._path, "folder/file.test", "Uri::append() ok");
|
||||
|
||||
Uri uri2 ("user@host:folder/file.test");
|
||||
uri2.parse ();
|
||||
t.is (uri2.user, "user", "Uri::parse() : user@host:folder/file.test");
|
||||
t.is (uri2.host, "host", "Uri::parse() : user@host:folder/file.test");
|
||||
t.is (uri2.port, "", "Uri::parse() : user@host/folder/file.test");
|
||||
t.is (uri2.path, "folder/file.test", "Uri::parse() : user@host/folder/file.test");
|
||||
t.is (uri2.protocol, "ssh", "Uri::parse() : user@host/folder/file.test");
|
||||
t.is (uri2._user, "user", "Uri::parse() : user@host:folder/file.test");
|
||||
t.is (uri2._host, "host", "Uri::parse() : user@host:folder/file.test");
|
||||
t.is (uri2._port, "", "Uri::parse() : user@host/folder/file.test");
|
||||
t.is (uri2._path, "folder/file.test", "Uri::parse() : user@host/folder/file.test");
|
||||
t.is (uri2._protocol, "ssh", "Uri::parse() : user@host/folder/file.test");
|
||||
t.notok (uri2.append ("test.dat"), "Uri::append() to file");
|
||||
|
||||
Uri uri3 ("rsync://hostname.abc.de:1234//abs/path");
|
||||
uri3.parse ();
|
||||
t.is (uri3.user, "", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3.host, "hostname.abc.de", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3.port, "1234", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3.path, "/abs/path", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3.protocol, "rsync", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3._user, "", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3._host, "hostname.abc.de", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3._port, "1234", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3._path, "/abs/path", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
t.is (uri3._protocol, "rsync", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
|
||||
|
||||
Uri uri4 ("hostname:");
|
||||
uri4.parse ();
|
||||
t.is (uri4.user, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4.host, "hostname", "Uri::parse() : hostname:");
|
||||
t.is (uri4.port, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4.path, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4.protocol, "ssh", "Uri::parse() : hostname:");
|
||||
t.is (uri4._user, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4._host, "hostname", "Uri::parse() : hostname:");
|
||||
t.is (uri4._port, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4._path, "", "Uri::parse() : hostname:");
|
||||
t.is (uri4._protocol, "ssh", "Uri::parse() : hostname:");
|
||||
t.notok (uri4.is_local (), "Uri::is_local() : hostname:");
|
||||
t.ok (uri4.append ("file.test"), "Uri::append() : hostname:");
|
||||
t.is (uri4.path, "file.test","Uri::append() : ok");
|
||||
t.is (uri4._path, "file.test","Uri::append() : ok");
|
||||
|
||||
context.config.set ("merge.default.uri", "../folder/");
|
||||
context.config.set ("push.test.uri", "/home/user/.task/");
|
||||
|
@ -81,53 +81,52 @@ int main (int argc, char** argv)
|
|||
Uri uri5 ("", "merge");
|
||||
t.ok (uri5.is_local (), "Uri::is_local() : ../server/");
|
||||
uri5.parse ();
|
||||
t.is (uri5.path, "../folder/", "Uri::expand() default");
|
||||
t.is (uri5._path, "../folder/", "Uri::expand() default");
|
||||
|
||||
Uri uri6 ("test", "push");
|
||||
t.ok (uri6.is_local(), "Uri::is_local() : /home/user/.task/");
|
||||
uri6.parse ();
|
||||
t.is (uri6.path, "/home/user/.task/", "Uri::expand() test");
|
||||
t.is (uri6._path, "/home/user/.task/", "Uri::expand() test");
|
||||
|
||||
Uri uri7 ("ftp://'user@name'@host:321/path/to/x");
|
||||
uri7.parse ();
|
||||
t.is (uri7.user, "user@name", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7.host, "host", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7.port, "321", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7.path, "path/to/x", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7.protocol, "ftp", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7._user, "user@name", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7._host, "host", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7._port, "321", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7._path, "path/to/x", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
t.is (uri7._protocol, "ftp", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
|
||||
|
||||
Uri uri8 ("http://'us/er@n:ame'@host/path/to/x");
|
||||
uri8.parse ();
|
||||
t.is (uri8.user, "us/er@n:ame", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8.host, "host", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8.port, "", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8.path, "path/to/x", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8.protocol, "http", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8._user, "us/er@n:ame", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8._host, "host", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8._port, "", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8._path, "path/to/x", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
t.is (uri8._protocol, "http", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
|
||||
|
||||
Uri uri9 ("'user@name'@host:path/to/x");
|
||||
uri9.parse ();
|
||||
t.is (uri9.user, "user@name", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9.host, "host", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9.port, "", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9.path, "path/to/x", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9._user, "user@name", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9._host, "host", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9._port, "", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
t.is (uri9._path, "path/to/x", "Uri::parse() : 'user@name'@host:path/to/x");
|
||||
|
||||
// bug #668
|
||||
Uri uri10 ("user.name@host.com:undo.data");
|
||||
uri10.parse ();
|
||||
t.is (uri10.user, "user.name", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10.host, "host.com", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10.port, "", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10.path, "undo.data", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10.protocol, "ssh", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10._user, "user.name", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10._host, "host.com", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10._port, "", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10._path, "undo.data", "Uri::parse() : user.name@host.com:undo.data");
|
||||
t.is (uri10._protocol, "ssh", "Uri::parse() : user.name@host.com:undo.data");
|
||||
|
||||
Uri uri11 ("ssh://user.name@host.com/undo.data");
|
||||
uri11.parse ();
|
||||
t.is (uri11.user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11.host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11.port, "", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11.path, "/undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11.protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
|
||||
t.is (uri11._user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11._host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11._port, "", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11._path, "/undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
t.is (uri11._protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue