Skip to content

Commit

Permalink
Add test of summary report
Browse files Browse the repository at this point in the history
Signed-off-by: John Pennycook <[email protected]>
  • Loading branch information
Pennycook committed Jan 24, 2025
1 parent d9f6a56 commit b9bff58
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Empty file added tests/report/__init__.py
Empty file.
52 changes: 52 additions & 0 deletions tests/report/test_summary_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (C) 2019-2024 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

import logging
import unittest
from io import StringIO

from codebasin.report import summary


class TestSummaryReport(unittest.TestCase):
"""
Test summary report functionality.
"""

def setUp(self):
logging.disable()

def test_output(self):
"""Check summary report output"""
setmap = {
frozenset(["X"]): 1,
frozenset(["Y"]): 2,
frozenset(["X", "Y"]): 3,
frozenset([]): 6,
}
output = StringIO()
summary(setmap, stream=output)
expected = """
Summary
=======
┌────────────────┬───────┬─────────┐
│ Platform Set │ LOC │ % LOC │
├────────────────┼───────┼─────────┤
│ {} │ 6 │ 50.00 │
├────────────────┼───────┼─────────┤
│ {X} │ 1 │ 8.33 │
├────────────────┼───────┼─────────┤
│ {Y} │ 2 │ 16.67 │
├────────────────┼───────┼─────────┤
│ {X, Y} │ 3 │ 25.00 │
└────────────────┴───────┴─────────┘
Code Divergence: 0.50
Code Utilization: 0.38
Unused Code (%): 50.00
Total SLOC: 12
"""
self.assertEqual(expected, output.getvalue())


if __name__ == "__main__":
unittest.main()

0 comments on commit b9bff58

Please sign in to comment.