feisty meow concerns codebase
2.140
test_directory.cpp
Go to the documentation of this file.
1
/*
2
* Name : test_directory
3
* Author : Chris Koeritz
4
* Purpose:
5
* Tests the directory object out to see if it scans properly.
6
**
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 *
13
*/
14
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
>
26
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
;
36
38
39
class
test_directory :
public
virtual
unit_base
,
public
virtual
application_shell
40
{
41
public
:
42
test_directory() :
application_shell
() {}
43
DEFINE_CLASS_NAME
(
"test_directory"
);
44
int
execute();
45
};
46
48
49
int
test_directory::execute()
50
{
51
FUNCDEF
(
"execute"
);
52
{
53
astring
path
=
"/tmp"
;
// default path.
54
#ifdef __WIN32__
55
path
=
"c:/"
;
// default path for windoze.
56
#endif
57
if
(
application::_global_argc
>= 2)
58
path
=
application::_global_argv
[1];
59
60
astring
pattern =
"*"
;
61
if
(
application::_global_argc
>= 3)
62
pattern =
application::_global_argv
[2];
63
64
// log(astring("Scanning directory named \"") + path + "\"");
65
// log(astring("Using pattern-match \"") + pattern + "\"");
66
67
directory
dir(
path
, pattern.
s
());
68
ASSERT_TRUE
(dir.good(),
"the current directory should be readable"
);
69
// log(path + " contained these files:");
70
astring
names;
71
for
(
int
i = 0; i < dir.files().length(); i++) {
72
names += dir.files()[i] +
" "
;
73
}
74
astring
split;
75
string_manipulation::split_lines
(names, split, 4);
76
// log(split);
77
// log(path + " contained these directories:");
78
names =
""
;
79
for
(
int
i = 0; i < dir.directories().length(); i++) {
80
names += dir.directories()[i] +
" "
;
81
}
82
string_manipulation::split_lines
(names, split, 4);
83
// log(split);
84
}
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!
90
91
92
93
//more tests!
94
95
return
final_report();
96
}
97
98
HOOPLE_MAIN
(test_directory, )
99
application::application_shell
The application_shell is a base object for console programs.
Definition:
application_shell.h:33
basis::astring
Provides a dynamically resizable ASCII character string.
Definition:
astring.h:35
basis::astring::s
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
Definition:
astring.h:113
filesystem::directory
Implements a scanner that finds all filenames in the directory specified.
Definition:
directory.h:27
unit_test::unit_base
Definition:
unit_base.h:59
critical_events.h
directory.h
DEFINE_CLASS_NAME
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition:
enhance_cpp.h:45
FUNCDEF
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition:
enhance_cpp.h:57
filename.h
functions.h
guards.h
hoople_main.h
Provides macros that implement the 'main' program of an application.
HOOPLE_MAIN
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition:
hoople_main.h:61
application
Implements an application lock to ensure only one is running at once.
Definition:
application_shell.cpp:40
application::_global_argc
int _global_argc
application::_global_argv
char ** _global_argv
basis
The guards collection helps in testing preconditions and reporting errors.
Definition:
array.h:30
eml_to_txt.path
string path
Definition:
eml_to_txt.py:139
filesystem
A platform independent way to obtain the timestamp of a file.
Definition:
byte_filer.cpp:37
loggers
A logger that sends to the console screen using the standard output device.
Definition:
combo_logger.cpp:36
mathematics
An extension to floating point primitives providing approximate equality.
Definition:
averager.h:21
one_line_cert_to_pem.split_lines
None split_lines(str unsplit_line)
Definition:
one_line_cert_to_pem.py:18
structures
A dynamic container class that holds any kind of object via pointers.
Definition:
amorph.h:55
textual
Definition:
byte_formatter.cpp:38
timely
#include <time.h>
Definition:
earth_time.cpp:37
unit_test
Useful support functions for unit testing, especially within hoople.
Definition:
unit_base.cpp:35
program_wide_logger.h
static_memory_gremlin.h
string_array.h
string_manipulation.h
unit_base.h
ASSERT_TRUE
#define ASSERT_TRUE(a, test_name)
Definition:
unit_base.h:46
nucleus
library
tests_filesystem
test_directory.cpp
Generated by
1.9.1