vhdl-style-guide/tests/aggregate/test_rule_500.py

74 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
import os
import unittest
from tests import utils
from vsg import vhdlFile
from vsg.rules import aggregate
sTestDir = os.path.dirname(__file__)
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_500_test_input.vhd"))
lExpected_lower = []
lExpected_lower.append("")
utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_lower.vhd"), lExpected_lower)
lExpected_upper = []
lExpected_upper.append("")
utils.read_file(os.path.join(sTestDir, "rule_500_test_input.fixed_upper.vhd"), lExpected_upper)
class test_aggregate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)
def test_rule_500_lower(self):
oRule = aggregate.rule_500()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "aggregate")
self.assertEqual(oRule.identifier, "500")
lExpected = [78, 81, 84, 92, 96, 98, 100, 101, 105, 106, 113, 117, 119, 121, 122, 127, 131, 133, 135, 136]
oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
def test_rule_500_upper(self):
oRule = aggregate.rule_500()
oRule.case = "upper"
self.assertTrue(oRule)
self.assertEqual(oRule.name, "aggregate")
self.assertEqual(oRule.identifier, "500")
lExpected = [4, 7, 10, 18, 22, 24, 26, 27, 31, 32, 39, 43, 45, 47, 48, 53, 57, 59, 61, 62]
oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
def test_fix_rule_500_lower(self):
oRule = aggregate.rule_500()
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected_lower, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
def test_fix_rule_500_upper(self):
oRule = aggregate.rule_500()
oRule.case = "upper"
oRule.fix(self.oFile)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected_upper, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])