Skip to content

feat: pretty printing#387

Merged
benthevining merged 30 commits intomainfrom
pretty-printing
Feb 27, 2026
Merged

feat: pretty printing#387
benthevining merged 30 commits intomainfrom
pretty-printing

Conversation

@benthevining
Copy link
Owner

@benthevining benthevining commented Oct 16, 2025

  • Unit test to compare result of TextTable::to_string() vs TextTable::print()
  • "pretty mode" UCI option to enable/disable color output during search
  • Search callbacks need a "search started" callback
  • Use colors in pretty printer
  • Option to control notation format of PV in pretty mode (UCI, Algebraic)

@benthevining benthevining linked an issue Oct 16, 2025 that may be closed by this pull request
using chess::util::strings::TextTable;

namespace {
[[nodiscard]] auto get_printed_string(const TextTable& table) -> std::string

Check notice

Code scanning / CodeQL

Unused static function

Static function get_printed_string is unreachable ([CATCH2_INTERNAL_TEST_0](1) must be removed at the same time) Static function get_printed_string is unreachable ([autoRegistrar1](2) must be removed at the same time)

Copilot Autofix

AI 4 months ago

To fix the problem, both the function get_printed_string and the associated test case TEST_CASE("TextTable - to_string() should give same result as print()", TAGS) should be removed from the file tests/unit/libchess/util/TextTable.cpp. This involves removing the entire anonymous namespace containing get_printed_string, and the body of the test case itself. No imports or helper methods are needed as the file will otherwise remain unchanged.


Suggested changeset 1
tests/unit/libchess/util/TextTable.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/unit/libchess/util/TextTable.cpp b/tests/unit/libchess/util/TextTable.cpp
--- a/tests/unit/libchess/util/TextTable.cpp
+++ b/tests/unit/libchess/util/TextTable.cpp
@@ -21,44 +21,6 @@
 
 using chess::util::strings::TextTable;
 
-namespace {
-[[nodiscard]] auto get_printed_string(const TextTable& table) -> std::string
-{
-    std::string result;
 
-    auto appendToString = [&result](const std::string_view toAdd) {
-        result.append(toAdd);
-    };
 
-    table.print(
-        appendToString, appendToString, appendToString,
-        [&result] { result.append(1uz, '\n'); });
 
-    return result;
-}
-} // namespace
-
-TEST_CASE("TextTable - to_string() should give same result as print()", TAGS)
-{
-    TextTable table;
-
-    table.append_column("Option")
-        .append_column("Type")
-        .append_column("Notes")
-        .append_column("Default");
-
-    table.new_row()
-        .append_column("Option 1")
-        .append_column("Integer")
-        .append_column("Comments")
-        .append_column("0");
-
-    table.new_row()
-        .append_column("Option 2")
-        .append_column("String")
-        .append_column("More comments")
-        .append_column("foo");
-
-    REQUIRE(
-        get_printed_string(table) == table.to_string());
-}
EOF
@@ -21,44 +21,6 @@

using chess::util::strings::TextTable;

namespace {
[[nodiscard]] auto get_printed_string(const TextTable& table) -> std::string
{
std::string result;

auto appendToString = [&result](const std::string_view toAdd) {
result.append(toAdd);
};

table.print(
appendToString, appendToString, appendToString,
[&result] { result.append(1uz, '\n'); });

return result;
}
} // namespace

TEST_CASE("TextTable - to_string() should give same result as print()", TAGS)
{
TextTable table;

table.append_column("Option")
.append_column("Type")
.append_column("Notes")
.append_column("Default");

table.new_row()
.append_column("Option 1")
.append_column("Integer")
.append_column("Comments")
.append_column("0");

table.new_row()
.append_column("Option 2")
.append_column("String")
.append_column("More comments")
.append_column("foo");

REQUIRE(
get_printed_string(table) == table.to_string());
}
Copilot is powered by AI and may make mistakes. Always verify output.
}
} // namespace

TEST_CASE("TextTable - to_string() should give same result as print()", TAGS)

Check notice

Code scanning / CodeQL

Unused static function

Static function CATCH2_INTERNAL_TEST_0 is unreachable ([autoRegistrar1](1) must be removed at the same time)

Copilot Autofix

AI 4 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@benthevining benthevining moved this to In progress in ben-bot Feb 27, 2026
@benthevining benthevining added this to the UCI engine milestone Feb 27, 2026
@benthevining benthevining added the enhancement New feature or request label Feb 27, 2026
@benthevining benthevining merged commit ec9e6f7 into main Feb 27, 2026
4 of 17 checks passed
@benthevining benthevining deleted the pretty-printing branch February 27, 2026 18:37
@github-project-automation github-project-automation bot moved this from In progress to Done in ben-bot Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/XXL

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Pretty printing mode

1 participant