-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_filename_gtest.cc
More file actions
68 lines (59 loc) · 1.68 KB
/
complete_filename_gtest.cc
File metadata and controls
68 lines (59 loc) · 1.68 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* -*- mode: C++; c-basic-offset: 4; tab-width: 8; -*-
* vi: set shiftwidth=4 tabstop=8:
* :indentSize=4:tabSize=8:
*/
#include "gtest/gtest.h"
#include "complete_filename.h"
TEST(complete_filename, matches_current_directory_for_empty_string)
{
std::string err, path;
auto s = complete_filename(path, err);
ASSERT_GT(s.size(), 10u);
ASSERT_EQ(0u, err.size());
}
TEST(complete_filename, matches_complete_relative_files)
{
std::string err, path;
path = "README.md";
auto s = complete_filename(path, err);
ASSERT_EQ(1u, s.size());
ASSERT_EQ(0u, err.size());
path = "README.m";
s = complete_filename(path, err);
ASSERT_EQ(1u, s.size());
ASSERT_EQ(0u, err.size());
ASSERT_EQ(std::string("README.md"), path);
path = "unix/complete_filename.cc";
s = complete_filename(path, err);
ASSERT_EQ(1u, s.size());
ASSERT_EQ(0u, err.size());
}
TEST(complete_filename, matches_complete_absolute_files)
{
std::string err, path;
path = "/etc/resolv.conf";
auto s = complete_filename(path, err);
ASSERT_EQ(1u, s.size());
ASSERT_EQ(0u, err.size());
}
TEST(complete_filename, matches_absolute_pathnames)
{
std::string err, path;
path = "/etc/passwd";
auto s = complete_filename(path, err);
ASSERT_GE(s.size(), 1u);
ASSERT_EQ(0u, err.size());
path = "/tmp";
s = complete_filename(path, err);
ASSERT_EQ(1u, s.size());
ASSERT_EQ(0u, err.size());
ASSERT_EQ(std::string("/tmp/"), *(s.begin()));
}
TEST(complete_filename, matches_relative_pathnames)
{
std::string err, path;
path = "win/ge";
auto s = complete_filename(path, err);
ASSERT_GT(s.size(), 5u);
ASSERT_EQ(0u, err.size());
}