Skip to content

Commit b9bff58

Browse files
committed
Add test of summary report
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent d9f6a56 commit b9bff58

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/report/__init__.py

Whitespace-only changes.

tests/report/test_summary_report.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (C) 2019-2024 Intel Corporation
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
import logging
5+
import unittest
6+
from io import StringIO
7+
8+
from codebasin.report import summary
9+
10+
11+
class TestSummaryReport(unittest.TestCase):
12+
"""
13+
Test summary report functionality.
14+
"""
15+
16+
def setUp(self):
17+
logging.disable()
18+
19+
def test_output(self):
20+
"""Check summary report output"""
21+
setmap = {
22+
frozenset(["X"]): 1,
23+
frozenset(["Y"]): 2,
24+
frozenset(["X", "Y"]): 3,
25+
frozenset([]): 6,
26+
}
27+
output = StringIO()
28+
summary(setmap, stream=output)
29+
expected = """
30+
Summary
31+
=======
32+
┌────────────────┬───────┬─────────┐
33+
│ Platform Set │ LOC │ % LOC │
34+
├────────────────┼───────┼─────────┤
35+
│ {} │ 6 │ 50.00 │
36+
├────────────────┼───────┼─────────┤
37+
│ {X} │ 1 │ 8.33 │
38+
├────────────────┼───────┼─────────┤
39+
│ {Y} │ 2 │ 16.67 │
40+
├────────────────┼───────┼─────────┤
41+
│ {X, Y} │ 3 │ 25.00 │
42+
└────────────────┴───────┴─────────┘
43+
Code Divergence: 0.50
44+
Code Utilization: 0.38
45+
Unused Code (%): 50.00
46+
Total SLOC: 12
47+
"""
48+
self.assertEqual(expected, output.getvalue())
49+
50+
51+
if __name__ == "__main__":
52+
unittest.main()

0 commit comments

Comments
 (0)