Enhancement - Path integration

- Implemented Path::operator (std::string) const, to provide an
  automatic cast to std::string for any Path, File or Directory.
- Made use of new cast in various code.
- Changed use of spaces in atoi () calls.
- Switched from std::string::data () to std::string::c_str () calls.
This commit is contained in:
Paul Beckingham 2010-01-16 14:42:36 -05:00
parent a6875ced6e
commit e53ba8110b
9 changed files with 35 additions and 18 deletions

View file

@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv)
{
UnitTest t (20);
UnitTest t (21);
// Directory (const File&);
// Directory (const Path&);
@ -55,6 +55,9 @@ int main (int argc, char** argv)
Directory d5 = d4;
t.is (d5.data, "/tmp/test_directory", "Directory::operator=");
// operator (std::string) const;
t.is ((std::string) d3, "/tmp", "Directory::operator (std::string) const");
// virtual bool create ();
t.ok (d5.create (), "Directory::create /tmp/test_directory");
t.ok (d5.exists (), "Directory::exists /tmp/test_directory");

View file

@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv)
{
UnitTest t (5);
UnitTest t (6);
File::write ("/tmp/file.t.txt", "This is a test\n");
File f6 ("/tmp/file.t.txt");
@ -41,6 +41,9 @@ int main (int argc, char** argv)
t.ok (f6.mode () & S_IRUSR, "File::mode /tmp/file.t.txt good");
t.ok (File::remove ("/tmp/file.t.txt"), "File::remove /tmp/file.t.txt good");
// operator (std::string) const;
t.is ((std::string) f6, "/tmp/file.t.txt", "File::operator (std::string) const");
t.ok (File::create ("/tmp/file.t.create"), "File::create /tmp/file.t.create good");
t.ok (File::remove ("/tmp/file.t.create"), "File::remove /tmp/file.t.create good");

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv)
{
UnitTest t (31);
UnitTest t (32);
// Path ();
Path p0;
@ -54,6 +54,9 @@ int main (int argc, char** argv)
Path p3_copy (p3);
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");
// std::string name () const;
Path p4 ("/a/b/c/file.ext");
t.is (p4.name (), "file.ext", "/a/b/c/file.ext name is file.ext");