"Fossies" - the Fresh Open Source Software Archive 
Member "TeXmacs-2.1.2-src/tests/System/Classes/url_test.cpp" (5 May 2022, 2358 Bytes) of package /linux/misc/TeXmacs-2.1.2-src.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "url_test.cpp":
2.1.1_vs_2.1.2.
1
2 /******************************************************************************
3 * MODULE : url_test.cpp
4 * COPYRIGHT : (C) 2019-2021 Darcy Shen
5 *******************************************************************************
6 * This software falls under the GNU general public license version 3 or later.
7 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
8 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
9 ******************************************************************************/
10
11 #include "file.hpp"
12
13 #include <QtTest/QtTest>
14
15 class TestURL: public QObject {
16 Q_OBJECT
17
18 public:
19 url tmfs_1= url_system ("tmfs://git/help");
20 url http_1= url_system ("http://texmacs.org");
21 url https_1= url_system ("https://ustc.edu.cn");
22 url root_tmp= url ("/tmp");
23 url root_no_such_tmp= url ("/no_such_tmp");
24
25 private slots:
26 void test_exists ();
27 void test_suffix ();
28
29 // predicates
30 void test_is_rooted_tmfs ();
31 void test_is_rooted_web ();
32
33 // operations
34 void test_descends();
35 };
36
37 void TestURL::test_exists () {
38 // two cases: root directory
39 // TODO: Windows compatibility
40 QVERIFY (exists (root_tmp));
41 QVERIFY (!exists (root_no_such_tmp));
42 }
43
44 void TestURL::test_suffix () {
45 // empty suffix should work
46 url no_suffix= url ("/a/b/c/d/no_suffix");
47 QCOMPARE (suffix (no_suffix), string (""));
48 url no_suffix2= url ("/a/b.c/d/no_suffix");
49 QCOMPARE (suffix (no_suffix2), string (""));
50
51 // normal suffix should work
52 url png= url ("/a/b/c/d.png");
53 QCOMPARE (suffix (png), string ("png"));
54 url png2= url ("/a/b.c/d.png");
55 QCOMPARE (suffix (png2), string ("png"));
56 }
57
58
59 void TestURL::test_is_rooted_tmfs () {
60 QVERIFY (is_rooted_tmfs (tmfs_1));
61 QVERIFY (!is_rooted_tmfs (http_1));
62 QVERIFY (!is_rooted_tmfs (https_1));
63 QVERIFY (!is_rooted_tmfs (root_tmp));
64 }
65
66 void TestURL::test_is_rooted_web () {
67 QVERIFY (is_rooted_web (http_1));
68 QVERIFY (is_rooted_web (https_1));
69 QVERIFY (!is_rooted_web (root_tmp));
70 QVERIFY (!is_rooted_web (tmfs_1));
71 }
72
73
74 void TestURL::test_descends () {
75 QVERIFY (descends (url_system ("/tmp/a.txt"), root_tmp));
76 QVERIFY (descends (url_system ("$TEXMACS_PATH/doc/main/man-manual.en.tm"),
77 url_system ("$TEXMACS_PATH")));
78 QVERIFY (!descends (root_no_such_tmp, root_tmp));
79 }
80
81 QTEST_MAIN(TestURL)
82 #include "url_test.moc"