Freeciv21
Develop your civilization from humble roots to a global empire
test_paths.cpp
Go to the documentation of this file.
1 #include "shared.h"
2 
3 #include <QtTest>
4 
8 class test_paths : public QObject {
9  Q_OBJECT
10 
11 private slots:
12  void interpret_tilde();
13  void is_safe_filename();
14  void make_dir();
15 };
16 
21 {
22  QCOMPARE(::interpret_tilde(QLatin1String("~")), QDir::homePath());
23  QCOMPARE(::interpret_tilde(QLatin1String("test")), QLatin1String("test"));
24 }
25 
30 {
31  QCOMPARE(::is_safe_filename(QLatin1String("")), false);
32  QCOMPARE(::is_safe_filename(QLatin1String("abcABC_-._")), true);
33  QCOMPARE(::is_safe_filename(QLatin1String("a/b")), false);
34  QCOMPARE(::is_safe_filename(QLatin1String("..")), false);
35 }
36 
41 {
42  // The main difference between make_dir and QDir()::mkpath is that make_dir
43  // ignores empty paths. We don't check that QDir works as expected.
44  QVERIFY(::make_dir(QLatin1String("")));
45 }
46 
47 QTEST_MAIN(test_paths)
48 #include "test_paths.moc"
Tests functions acting on paths.
Definition: test_paths.cpp:8
void interpret_tilde()
Tests interpret_tilde.
Definition: test_paths.cpp:20
void make_dir()
Tests make_dir.
Definition: test_paths.cpp:40
void is_safe_filename()
Tests is_safe_filename.
Definition: test_paths.cpp:29