From 09e7b47bad7e7310a6f52bdc20e9a9f251e79769 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 02:38:50 +0200 Subject: Adding upstream version 1.33.0. Signed-off-by: Daniel Baumann --- tests/rules/test_octal_values.py | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/rules/test_octal_values.py (limited to 'tests/rules/test_octal_values.py') diff --git a/tests/rules/test_octal_values.py b/tests/rules/test_octal_values.py new file mode 100644 index 0000000..be5b039 --- /dev/null +++ b/tests/rules/test_octal_values.py @@ -0,0 +1,80 @@ +# Copyright (C) 2016 Adrien Vergé +# +# This program 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 3 of the License, or +# (at your option) any later version. +# +# This program 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 this program. If not, see . + +from tests.common import RuleTestCase + + +class OctalValuesTestCase(RuleTestCase): + rule_id = 'octal-values' + + def test_disabled(self): + conf = ('octal-values: disable\n' + 'new-line-at-end-of-file: disable\n' + 'document-start: disable\n') + self.check('user-city: 010', conf) + self.check('user-city: 0o10', conf) + + def test_implicit_octal_values(self): + conf = ('octal-values:\n' + ' forbid-implicit-octal: true\n' + ' forbid-explicit-octal: false\n' + 'new-line-at-end-of-file: disable\n' + 'document-start: disable\n') + self.check('after-tag: !custom_tag 010', conf) + self.check('user-city: 010', conf, problem=(1, 15)) + self.check('user-city: abc', conf) + self.check('user-city: 010,0571', conf) + self.check("user-city: '010'", conf) + self.check('user-city: "010"', conf) + self.check('user-city:\n' + ' - 010', conf, problem=(2, 8)) + self.check('user-city: [010]', conf, problem=(1, 16)) + self.check('user-city: {beijing: 010}', conf, problem=(1, 25)) + self.check('explicit-octal: 0o10', conf) + self.check('not-number: 0abc', conf) + self.check('zero: 0', conf) + self.check('hex-value: 0x10', conf) + self.check('number-values:\n' + ' - 0.10\n' + ' - .01\n' + ' - 0e3\n', conf) + self.check('with-decimal-digits: 012345678', conf) + self.check('with-decimal-digits: 012345679', conf) + + def test_explicit_octal_values(self): + conf = ('octal-values:\n' + ' forbid-implicit-octal: false\n' + ' forbid-explicit-octal: true\n' + 'new-line-at-end-of-file: disable\n' + 'document-start: disable\n') + self.check('user-city: 0o10', conf, problem=(1, 16)) + self.check('user-city: abc', conf) + self.check('user-city: 0o10,0571', conf) + self.check("user-city: '0o10'", conf) + self.check('user-city:\n' + ' - 0o10', conf, problem=(2, 9)) + self.check('user-city: [0o10]', conf, problem=(1, 17)) + self.check('user-city: {beijing: 0o10}', conf, problem=(1, 26)) + self.check('implicit-octal: 010', conf) + self.check('not-number: 0oabc', conf) + self.check('zero: 0', conf) + self.check('hex-value: 0x10', conf) + self.check('number-values:\n' + ' - 0.10\n' + ' - .01\n' + ' - 0e3\n', conf) + self.check('user-city: "010"', conf) + self.check('with-decimal-digits: 0o012345678', conf) + self.check('with-decimal-digits: 0o012345679', conf) -- cgit v1.2.3