android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / TestFileUtil.cpp
blob54525cb8d7ebf797af041398833e6fa624f7a928
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "OS/FileUtil.hpp"
24 #include "TestUtil.hpp"
26 #include <string.h>
28 class TestingFileVisitor: public File::Visitor
30 private:
31 bool recursive;
32 bool filtered;
34 public:
35 TestingFileVisitor(bool _recursive, bool _filtered) :
36 recursive(_recursive), filtered(_filtered) {}
38 void
39 Visit(const TCHAR* path, const TCHAR* filename)
41 if (!_tcscmp(filename, _T("a.txt"))) {
42 ok(true, "a.txt");
43 } else if (!_tcscmp(filename, _T("b.txt"))) {
44 ok(true, "b.txt");
45 } else if (!_tcscmp(filename, _T("c.tx"))) {
46 ok(!filtered, "c.tx");
47 } else if (!_tcscmp(filename, _T("d.txt"))) {
48 ok(recursive, "d.txt");
49 } else {
50 ok(false, "unexpected file");
55 int main(int argc, char **argv)
57 plan_tests(17);
59 ok1(Directory::Exists(_T("test/data/file_visitor_test")));
60 ok1(File::Exists(_T("test/data/file_visitor_test/a.txt")));
61 ok1(File::Exists(_T("test/data/file_visitor_test/b.txt")));
62 ok1(File::Exists(_T("test/data/file_visitor_test/c.tx")));
63 ok1(File::Exists(_T("test/data/file_visitor_test/subfolder/d.txt")));
65 TestingFileVisitor fv1(false, false);
66 Directory::VisitFiles(_T("test/data/file_visitor_test"), fv1, false);
68 TestingFileVisitor fv2(true, false);
69 Directory::VisitFiles(_T("test/data/file_visitor_test"), fv2, true);
71 TestingFileVisitor fv3(false, true);
72 Directory::VisitSpecificFiles(_T("test/data/file_visitor_test"),
73 _T("*.txt"), fv3, false);
75 TestingFileVisitor fv4(true, true);
76 Directory::VisitSpecificFiles(_T("test/data/file_visitor_test"),
77 _T("*.txt"), fv4, true);
79 return exit_status();