2 * Name : test_directory
3 * Author : Chris Koeritz
5 * Tests the directory object out to see if it scans properly.
7 * Copyright (c) 2001-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
15 #include <basis/functions.h>
16 #include <basis/guards.h>
17 #include <structures/string_array.h>
18 #include <application/hoople_main.h>
19 #include <loggers/critical_events.h>
20 #include <loggers/program_wide_logger.h>
21 #include <filesystem/directory.h>
22 #include <filesystem/filename.h>
23 #include <structures/static_memory_gremlin.h>
24 #include <textual/string_manipulation.h>
25 #include <unit_test/unit_base.h>
27 using namespace application;
28 using namespace basis;
29 using namespace mathematics;
30 using namespace filesystem;
31 using namespace loggers;
32 using namespace structures;
33 using namespace textual;
34 using namespace timely;
35 using namespace unit_test;
39 class test_directory : public virtual unit_base, public virtual application_shell
42 test_directory() : application_shell() {}
43 DEFINE_CLASS_NAME("test_directory");
49 int test_directory::execute()
53 astring path = "/tmp"; // default path.
55 path = "c:/"; // default path for windoze.
57 if (application::_global_argc >= 2)
58 path = application::_global_argv[1];
60 astring pattern = "*";
61 if (application::_global_argc >= 3)
62 pattern = application::_global_argv[2];
64 // log(astring("Scanning directory named \"") + path + "\"");
65 // log(astring("Using pattern-match \"") + pattern + "\"");
67 directory dir(path, pattern.s());
68 ASSERT_TRUE(dir.good(), "the current directory should be readable");
69 // log(path + " contained these files:");
71 for (int i = 0; i < dir.files().length(); i++) {
72 names += dir.files()[i] + " ";
75 string_manipulation::split_lines(names, split, 4);
77 // log(path + " contained these directories:");
79 for (int i = 0; i < dir.directories().length(); i++) {
80 names += dir.directories()[i] + " ";
82 string_manipulation::split_lines(names, split, 4);
85 //hmmm: the above test proves zilch.
86 // it needs to do this differently.
87 // instead of relying on someone else's folder, pick and make our own.
88 // then fill it with some known stuff.
89 // verify then that the read form is identical!
95 return final_report();
98 HOOPLE_MAIN(test_directory, )