~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to libcore/tests/UtilTests/UtilTests.vala

  • Committer: Jeremy Wootten
  • Date: 2017-05-08 10:39:31 UTC
  • mfrom: (2557 pantheon-files)
  • mto: This revision was merged to the branch mainline in revision 2558.
  • Revision ID: jeremy@elementaryos.org-20170508103931-jkxai92h7pf2yw2r
Merge trunk to r2557

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* Copyright (c) 2017 elementary LLC
 
3
*
 
4
* This program is free software; you can redistribute it and/or
 
5
* modify it under the terms of the GNU General Public
 
6
* License as published by the Free Software Foundation, Inc.,; either
 
7
* version 3 of the License, or (at your option) any later version.
 
8
*
 
9
* This program is distributed in the hope that it will be useful,
 
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
* General Public License for more details.
 
13
*
 
14
* You should have received a copy of the GNU General Public
 
15
* License along with this program; if not, write to the
 
16
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
17
* MA 02110-1335 USA.
 
18
*
 
19
* Authored by: Jeremy Wootten <jeremy@elementaryos.org>
 
20
*/
 
21
 
 
22
 
 
23
void add_file_utils_tests () {
 
24
    /* Sanitize path */
 
25
    Test.add_func ("/FileUtils/sanitize_null_abs_path", () => {
 
26
        assert (PF.FileUtils.sanitize_path (null, null) == "");
 
27
    });
 
28
 
 
29
    Test.add_func ("/FileUtils/sanitize_zero_length_abs_path", () => {
 
30
        assert (PF.FileUtils.sanitize_path ("", null) == "");
 
31
 
 
32
    });
 
33
 
 
34
    Test.add_func ("/FileUtils/sanitize_null_rel_path", () => {
 
35
        string cp = "file://home";
 
36
        assert (PF.FileUtils.sanitize_path (null, cp) == cp);
 
37
    });
 
38
 
 
39
    /* Get file for path */
 
40
    Test.add_func ("/FileUtils/file_for_null_path", () => {
 
41
        /* For some reason using assert_null does not work */
 
42
        assert (PF.FileUtils.get_file_for_path (null) == null);
 
43
    });
 
44
 
 
45
    Test.add_func ("/FileUtils/file_for_zero_length_path", () => {
 
46
        assert (PF.FileUtils.get_file_for_path ("") == null);
 
47
    });
 
48
}
 
49
 
 
50
int main (string[] args) {
 
51
    Test.init (ref args);
 
52
    
 
53
    add_file_utils_tests ();
 
54
    return Test.run ();
 
55
}