diff --git a/tests/array_constraint/rule_100_test_input.fixed.vhd b/tests/array_constraint/rule_100_test_input.fixed.vhd new file mode 100644 index 00000000..0b70d869 --- /dev/null +++ b/tests/array_constraint/rule_100_test_input.fixed.vhd @@ -0,0 +1,10 @@ + +architecture rtl of fifo is + + subtype t_my_array is t_array(open)(t_range); + subtype t_my_array is t_array(open)(t_range); + subtype t_my_array is t_array(open)(t_range); + +begin + +end architecture rtl; diff --git a/tests/array_constraint/rule_100_test_input.vhd b/tests/array_constraint/rule_100_test_input.vhd new file mode 100644 index 00000000..4ea37c09 --- /dev/null +++ b/tests/array_constraint/rule_100_test_input.vhd @@ -0,0 +1,10 @@ + +architecture rtl of fifo is + + subtype t_my_array is t_array (open)(t_range); + subtype t_my_array is t_array (open)(t_range); + subtype t_my_array is t_array(open)(t_range); + +begin + +end architecture rtl; diff --git a/tests/array_constraint/test_rule_100.py b/tests/array_constraint/test_rule_100.py new file mode 100644 index 00000000..c083a3f3 --- /dev/null +++ b/tests/array_constraint/test_rule_100.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import array_constraint + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_100(self): + oRule = array_constraint.rule_100() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "array_constraint") + self.assertEqual(oRule.identifier, "100") + + lExpected = [4, 5] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_100(self): + oRule = array_constraint.rule_100() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/index_constraint/__init__.py b/tests/index_constraint/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/index_constraint/rule_100_test_input.fixed.vhd b/tests/index_constraint/rule_100_test_input.fixed.vhd new file mode 100644 index 00000000..0b70d869 --- /dev/null +++ b/tests/index_constraint/rule_100_test_input.fixed.vhd @@ -0,0 +1,10 @@ + +architecture rtl of fifo is + + subtype t_my_array is t_array(open)(t_range); + subtype t_my_array is t_array(open)(t_range); + subtype t_my_array is t_array(open)(t_range); + +begin + +end architecture rtl; diff --git a/tests/index_constraint/rule_100_test_input.vhd b/tests/index_constraint/rule_100_test_input.vhd new file mode 100644 index 00000000..d646651d --- /dev/null +++ b/tests/index_constraint/rule_100_test_input.vhd @@ -0,0 +1,19 @@ + +entity rule_100_test_input is + port ( + i_data : in signed (15 downto 0); + i_data : in signed (15 downto 0); + i_data : in signed(15 downto 0); + ); +end entity rule_100_test_input; + + +architecture rtl of fifo is + + subtype t_my_array is t_array(open) (t_range); + subtype t_my_array is t_array(open) (t_range); + subtype t_my_array is t_array(open)(t_range); + +begin + +end architecture rtl; diff --git a/tests/index_constraint/test_rule_100.py b/tests/index_constraint/test_rule_100.py new file mode 100644 index 00000000..0aca5faf --- /dev/null +++ b/tests/index_constraint/test_rule_100.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import index_constraint + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) + + +class test_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_100(self): + oRule = index_constraint.rule_100() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "index_constraint") + self.assertEqual(oRule.identifier, "100") + + lExpected = [4, 5, 13, 14] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_100(self): + oRule = index_constraint.rule_100() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, [])