-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for libdnf5::utils::[is_glob_pattern | is_file_pattern]
Includes C++, Perl, Python and Ruby tests.
- Loading branch information
Showing
6 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright Contributors to the libdnf project. | ||
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
Libdnf is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
Libdnf is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "test_patterns.hpp" | ||
|
||
#include <libdnf5/utils/patterns.hpp> | ||
|
||
using namespace libdnf5::utils; | ||
|
||
CPPUNIT_TEST_SUITE_REGISTRATION(UtilsPatternsTest); | ||
|
||
|
||
void UtilsPatternsTest::test_is_file_pattern() { | ||
CPPUNIT_ASSERT(!is_file_pattern("")); | ||
CPPUNIT_ASSERT(!is_file_pattern("no_file_pattern")); | ||
CPPUNIT_ASSERT(!is_file_pattern("no_file/pattern")); | ||
CPPUNIT_ASSERT(is_file_pattern("/pattern")); | ||
CPPUNIT_ASSERT(is_file_pattern("*/pattern")); | ||
} | ||
|
||
|
||
void UtilsPatternsTest::test_is_glob_pattern() { | ||
CPPUNIT_ASSERT(!is_glob_pattern("")); | ||
CPPUNIT_ASSERT(!is_glob_pattern("no_glob_pattern")); | ||
CPPUNIT_ASSERT(is_glob_pattern("glob*_pattern")); | ||
CPPUNIT_ASSERT(is_glob_pattern("glob[sdf]_pattern")); | ||
CPPUNIT_ASSERT(is_glob_pattern("glob?_pattern")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright Contributors to the libdnf project. | ||
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
Libdnf is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
Libdnf is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef LIBDNF5_TEST_UTILS_PATTERNS_HPP | ||
#define LIBDNF5_TEST_UTILS_PATTERNS_HPP | ||
|
||
#include <cppunit/TestCase.h> | ||
#include <cppunit/extensions/HelperMacros.h> | ||
|
||
class UtilsPatternsTest : public CppUnit::TestCase { | ||
CPPUNIT_TEST_SUITE(UtilsPatternsTest); | ||
CPPUNIT_TEST(test_is_file_pattern); | ||
CPPUNIT_TEST(test_is_glob_pattern); | ||
CPPUNIT_TEST_SUITE_END(); | ||
|
||
public: | ||
void test_is_file_pattern(); | ||
void test_is_glob_pattern(); | ||
}; | ||
|
||
#endif // LIBDNF5_TEST_UTILS_PATTERNS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright Contributors to the libdnf project. | ||
# | ||
# This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
# | ||
# Libdnf is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Libdnf is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
use libdnf5::utils; | ||
|
||
{ | ||
ok(!libdnf5::utils::is_file_pattern(''), 'is_file_pattern ""'); | ||
ok(!libdnf5::utils::is_file_pattern('no_file_pattern'), 'is_file_pattern "no_file_pattern"'); | ||
ok(!libdnf5::utils::is_file_pattern('no_file/pattern'), 'is_file_pattern "no_file/pattern"'); | ||
ok(libdnf5::utils::is_file_pattern('/pattern') == 1, 'is_file_pattern "/pattern"'); | ||
ok(libdnf5::utils::is_file_pattern('*/pattern') == 1, 'is_file_pattern "*/pattern"'); | ||
} | ||
|
||
{ | ||
ok(!libdnf5::utils::is_glob_pattern(''), 'is_glob_pattern ""'); | ||
ok(!libdnf5::utils::is_glob_pattern('no_glob_pattern'), 'is_glob_pattern "no_glob_pattern"'); | ||
ok(libdnf5::utils::is_glob_pattern('glob*_pattern'), 'is_glob_pattern "glob*_pattern"'); | ||
ok(libdnf5::utils::is_glob_pattern('glob[sdf]_pattern') == 1, 'is_glob_pattern "glob[sdf]_pattern"'); | ||
ok(libdnf5::utils::is_glob_pattern('glob?_pattern') == 1, 'is_glob_pattern "glob?_pattern"'); | ||
} | ||
|
||
done_testing() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright Contributors to the libdnf project. | ||
# | ||
# This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
# | ||
# Libdnf is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Libdnf is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import unittest | ||
|
||
import libdnf5.utils | ||
|
||
|
||
class TestIsXPattern(unittest.TestCase): | ||
def test_is_file_pattern(self): | ||
self.assertFalse(libdnf5.utils.is_file_pattern('')) | ||
self.assertFalse(libdnf5.utils.is_file_pattern('no_file_pattern')) | ||
self.assertFalse(libdnf5.utils.is_file_pattern('no_file/pattern')) | ||
self.assertTrue(libdnf5.utils.is_file_pattern('/pattern')) | ||
self.assertTrue(libdnf5.utils.is_file_pattern('*/pattern')) | ||
|
||
def test_is_glob_pattern(self): | ||
self.assertFalse(libdnf5.utils.is_glob_pattern('')) | ||
self.assertFalse(libdnf5.utils.is_glob_pattern('no_glob_pattern')) | ||
self.assertTrue(libdnf5.utils.is_glob_pattern('glob*_pattern')) | ||
self.assertTrue(libdnf5.utils.is_glob_pattern('glob[sdf]_pattern')) | ||
self.assertTrue(libdnf5.utils.is_glob_pattern('glob?_pattern')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright Contributors to the libdnf project. | ||
# | ||
# This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
# | ||
# Libdnf is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Libdnf is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
require 'test/unit' | ||
include Test::Unit::Assertions | ||
|
||
require 'libdnf5/utils' | ||
|
||
class TestIsXPattern < Test::Unit::TestCase | ||
def test_is_file_pattern() | ||
assert(!Utils::is_file_pattern('')) | ||
assert(!Utils::is_file_pattern('no_file_pattern')) | ||
assert(!Utils::is_file_pattern('no_file/pattern')) | ||
assert(Utils::is_file_pattern('/pattern')) | ||
assert(Utils::is_file_pattern('*/pattern')) | ||
end | ||
|
||
def test_is_glob_pattern() | ||
assert(!Utils::is_glob_pattern('')) | ||
assert(!Utils::is_glob_pattern('no_glob_pattern')) | ||
assert(Utils::is_glob_pattern('glob*_pattern')) | ||
assert(Utils::is_glob_pattern('glob[sdf]_pattern')) | ||
assert(Utils::is_glob_pattern('glob?_pattern')) | ||
end | ||
end |