Skip to content

Commit

Permalink
Add diagnostics for sporadic failures in a <format> test (#2494)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Jan 22, 2022
1 parent 33007ac commit 1035141
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/std/tests/P0645R10_text_formatting_formatting/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cstdio>
#include <exception>
#include <format>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
Expand Down Expand Up @@ -817,6 +818,18 @@ void test_float_specs() {
assert(format("{:.2000}", value) == expected);

expected = {buffer, to_chars(begin(buffer), end(buffer), value, chars_format::hex, 2000).ptr};

// TRANSITION, extra diagnostics for GH-2449:
if (const string str1 = format("{:.2000a}", value); str1 != expected) {
cerr << "Encountered sporadic failure GH-2449!\n";
cerr << " str1: \"" << str1 << "\"\n";
cerr << "expected: \"" << expected << "\"\n";
cerr << "DO NOT IGNORE/RERUN THIS FAILURE.\n";
cerr << "You must report it to the STL maintainers.\n";
assert(false);
}

// Keep the original assertion, just in case GH-2449 involves very specific codegen:
assert(format("{:.2000a}", value) == expected);

expected = {buffer, to_chars(begin(buffer), end(buffer), value, chars_format::scientific, 2000).ptr};
Expand All @@ -833,6 +846,18 @@ void test_float_specs() {
assert(format("{:.2000}", 1.0) == expected);

expected = {buffer, to_chars(begin(buffer), end(buffer), 1.0, chars_format::hex, 2000).ptr};

// TRANSITION, extra diagnostics for GH-2449:
if (const string str2 = format("{:.2000a}", 1.0); str2 != expected) {
cerr << "Encountered sporadic failure GH-2449!\n";
cerr << " str2: \"" << str2 << "\"\n";
cerr << "expected: \"" << expected << "\"\n";
cerr << "DO NOT IGNORE/RERUN THIS FAILURE.\n";
cerr << "You must report it to the STL maintainers.\n";
assert(false);
}

// Keep the original assertion, just in case GH-2449 involves very specific codegen:
assert(format("{:.2000a}", 1.0) == expected);

expected = {buffer, to_chars(begin(buffer), end(buffer), 1.0, chars_format::scientific, 2000).ptr};
Expand Down

0 comments on commit 1035141

Please sign in to comment.