-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathPathUtilTest.v3
36 lines (31 loc) · 1.17 KB
/
PathUtilTest.v3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2020 Ben L. Titzer. All rights reserved.
// See LICENSE for details of Apache 2.0 license.
def T = UnitTests.register;
def X_ = void(
T("PathUtil:extractName", test_extractName),
()
);
def test_extractName(t: Tester) {
def WE = PathUtil.extractName(_, true);
def NE = PathUtil.extractName(_, false);
// keep the extension
t.assert_string("name.txt", WE("/a/b/c/name.txt"));
t.assert_string("name", WE("/a/b/c/name"));
t.assert_string(".txt", WE("/a/b/c//.txt"));
t.assert_string(".", WE("/a/b/c//."));
t.assert_string("name.ex.ext", WE("name.ex.ext"));
t.assert_string("name.ex.ext.", WE("name.ex.ext."));
t.assert_string(".", WE("."));
t.assert_string("", WE("/"));
t.assert_string("", WE("////"));
// remove the extension
t.assert_string("name", NE("/a/b/c/name.txt"));
t.assert_string("name", NE("/a/b/c/name"));
t.assert_string("", NE("/a/b/c//.txt"));
t.assert_string("", NE("/a/b/c//."));
t.assert_string("name.ex", NE("name.ex.ext"));
t.assert_string("name.ex.ext", NE("name.ex.ext."));
t.assert_string("", NE(""));
t.assert_string("", NE("/"));
t.assert_string("", NE("////"));
}