mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-10 14:09:48 +00:00
Add new tests for glob2regex and try to fix the failing one
glob2regex is not 100% accurate yet, but it works at least for the cases in the accompanying unit test.
This commit is contained in:
parent
05aaaebe0d
commit
217b41ace2
2 changed files with 47 additions and 4 deletions
|
@ -26,4 +26,39 @@ TEST(glob2regex, convert) {
|
|||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string glob = "*.jp*g";
|
||||
const std::string expected_regex = "[^/]*\\.jp[^/]*g$";
|
||||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string glob = "/home/duckz/sample_file.bin";
|
||||
const std::string expected_regex = "/home/duckz/sample_file\\.bin$";
|
||||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string glob = "**/main.{c,h}pp";
|
||||
const std::string expected_regex = ".*/main\\.[ch]pp$";
|
||||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string glob = "photo_???.JPG";
|
||||
const std::string expected_regex = "photo_[^/][^/][^/]\\.JPG$";
|
||||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string glob = "nested_{example,*sample,test}";
|
||||
const std::string expected_regex = "nested_(?:example|[^/]*sample|test)$";
|
||||
const auto auto_regex = g2r::convert(glob);
|
||||
EXPECT_EQ(expected_regex, auto_regex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue