summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/test_app_output.py
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/measurestack/test_app_output.py')
-rw-r--r--build-aux/measurestack/test_app_output.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/build-aux/measurestack/test_app_output.py b/build-aux/measurestack/test_app_output.py
new file mode 100644
index 0000000..4653d4e
--- /dev/null
+++ b/build-aux/measurestack/test_app_output.py
@@ -0,0 +1,52 @@
+# build-aux/measurestack/test_app_output.py - Tests for app_output.py
+#
+# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+# pylint: disable=unused-variable
+
+import contextlib
+import io
+
+from . import analyze, app_output
+
+
+def test_print_group() -> None:
+ result = analyze.AnalyzeResult(
+ groups={
+ "A": analyze.AnalyzeResultGroup(
+ rows={
+ analyze.QName("short"): analyze.AnalyzeResultVal(nstatic=8, cnt=1),
+ analyze.QName(
+ "anamethatisnttoolongbutisnttooshort"
+ ): analyze.AnalyzeResultVal(nstatic=9, cnt=2),
+ }
+ ),
+ "B": analyze.AnalyzeResultGroup(rows={}),
+ },
+ missing=set(),
+ dynamic=set(),
+ included_funcs=set(),
+ )
+
+ def location_xform(loc: analyze.QName) -> str:
+ return str(loc)
+
+ stdout = io.StringIO()
+ with contextlib.redirect_stdout(stdout):
+ print()
+ app_output.print_group(result, location_xform, "A")
+ app_output.print_group(result, location_xform, "B")
+ assert (
+ stdout.getvalue()
+ == """
+= A =============================== ==
+anamethatisnttoolongbutisnttooshort 9 * 2
+short 8
+----------------------------------- --
+Total 26
+Maximum 9
+=================================== ==
+= B (empty) =
+"""
+ )