Issue#1488: Added tests for new rules.

This commit is contained in:
JHertz5 2025-08-24 22:33:26 +01:00
parent 1e0a3b30eb
commit 989c4b9a7f
7 changed files with 139 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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, [])

View File

View File

@ -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;

View File

@ -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;

View File

@ -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, [])