-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathwildcard_test.cpp
37 lines (30 loc) · 1.1 KB
/
wildcard_test.cpp
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
// Copyright (c) 2010, The Toft Authors.
// All rights reserved.
//
// Author: CHEN Feng <[email protected]>
#include "toft/text/wildcard.h"
#include "thirdparty/gtest/gtest.h"
namespace toft {
TEST(Wildcard, Default)
{
EXPECT_TRUE(Wildcard::Match("*.c", "a.c"));
EXPECT_FALSE(Wildcard::Match("*.c", "a.cpp"));
EXPECT_TRUE(Wildcard::Match("*.cpp", "a.cpp"));
EXPECT_TRUE(Wildcard::Match("*_test.cpp", "_test.cpp"));
EXPECT_TRUE(Wildcard::Match("lib*.a", "libc.a"));
EXPECT_TRUE(Wildcard::Match("lib?.a", "libm.a"));
EXPECT_FALSE(Wildcard::Match("lib?.a", "librt.a"));
}
TEST(Wildcard, FileNameOnly)
{
EXPECT_TRUE(Wildcard::Match("*.c", "a.c", Wildcard::MATCH_FILE_NAME_ONLY));
EXPECT_FALSE(Wildcard::Match("*.c", "dir/a.c", Wildcard::MATCH_FILE_NAME_ONLY));
EXPECT_TRUE(Wildcard::Match("*.c", "dir/a.c"));
}
TEST(Wildcard, IgnoreCase)
{
EXPECT_TRUE(Wildcard::Match("*.c", "a.c", Wildcard::IGNORE_CASE));
EXPECT_TRUE(Wildcard::Match("*.c", "a.C", Wildcard::IGNORE_CASE));
EXPECT_FALSE(Wildcard::Match("*.c", "a.d", Wildcard::IGNORE_CASE));
}
} // namespace toft