Release me
[asdcplib.git] / src / path-test.cpp
index 0c5f9692a05311b02dfda5f030ec9b443ee81330..f3cb131b7aa6c4ef72e895099cb2afa8cddd2d14 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -60,6 +60,10 @@ main(int argc, const char** argv)
 
   string Path_4 = ComponentsToPath(PathList_3);
   string Path_5 = PathMakeAbsolute(Path_4);
+
+  fprintf(stderr, "PathMakeAbsolute in: %s\n", Path_4.c_str());
+  fprintf(stderr, "PathMakeAbsolute out: %s\n", Path_5.c_str());
+
   string Path_6 = ComponentsToAbsolutePath(PathList_3);
   assert(Path_3 == Path_6);
   assert(PathsAreEquivalent(Path_3, Path_6));
@@ -84,6 +88,20 @@ main(int argc, const char** argv)
   assert(PathSetExtension("foo.bar", "") == "foo");
   assert(PathSetExtension(Path_3, "xml") == "baz.xml");
 
+  string Path_7 = "//tmp///////fooo";
+
+  PathCompList_t PathList_7;
+  PathToComponents(Path_7, PathList_7);
+  for ( PathCompList_t::const_iterator i = PathList_7.begin(); i != PathList_7.end(); i++ )
+    fprintf(stderr, "xx: \"%s\"\n", i->c_str());
+  assert(PathsAreEquivalent(PathMakeLocal(PathMakeCanonical(Path_7), "/tmp"), "fooo"));
+
+  string Path_8 = "tmp/foo/bar/ack";
+  CreateDirectoriesInPath(Path_8);
+  assert(PathExists(Path_8));
+  DeletePath(Path_8);
+  assert(!PathExists(Path_8));
+
   PathList_t InList, OutList;
   InList.push_back("tmp");
   InList.push_back("Darwin");
@@ -93,8 +111,15 @@ main(int argc, const char** argv)
   FindInPaths(PathMatchAny(), InList, OutList);
   PathList_t::iterator pi;
 
-  for ( pi = OutList.begin(); pi != OutList.end(); pi++ )
-    cerr << *pi << endl;
+  if ( false )
+    {
+      for ( pi = OutList.begin(); pi != OutList.end(); pi++ )
+       cerr << *pi << endl;
+    }
+  else
+    {
+      cerr << OutList.size() << ( ( OutList.size() == 1 ) ? " file" : " files" ) << endl;
+    }
 
   cerr << "----------------------------------" << endl;
   OutList.clear();
@@ -112,6 +137,12 @@ main(int argc, const char** argv)
 
   cerr << "----------------------------------" << endl;
 
+  fsize_t free_space, total_space;
+  FreeSpaceForPath("/", free_space, total_space);
+  cerr << "Free space: " << free_space << endl;
+  cerr << "Total space: " << total_space << endl;
+  cerr << "Used space: " << ( (total_space - free_space ) / float(total_space) ) << endl;
+
   cerr << "OK" << endl;
 
   return 0;