Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INFO() does not print message when starting with newline #1455

Closed
an-ky opened this issue Nov 23, 2018 · 2 comments
Closed

INFO() does not print message when starting with newline #1455

an-ky opened this issue Nov 23, 2018 · 2 comments
Labels

Comments

@an-ky
Copy link

an-ky commented Nov 23, 2018

Description

When using INFO() to record messages, strings starting with newline are not printed on console.
I didn't see anything about this mentioned in the docs, is this a bug or by design?

Steps to reproduce

#include <catch.hpp>

TEST_CASE("INFO surprise")
{
  SECTION("without newline")
  {
    INFO("Message without newline");
    REQUIRE(false);
  }

  SECTION("with newline")
  {
    INFO("\nMessage with newline");
    REQUIRE(false);
  }
}

Output

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
base_test.exe is a Catch v2.4.2 host application.
Run with -? for options

-------------------------------------------------------------------------------
INFO surprise
  without newline
-------------------------------------------------------------------------------
D:\Projekte\monalysis\modules\base\tests\scope_exit_test.cpp(15)
...............................................................................

D:\Projekte\monalysis\modules\base\tests\scope_exit_test.cpp(18): FAILED:
  REQUIRE( false )
with message:
  Message without newline

-------------------------------------------------------------------------------
INFO surprise
  with newline
-------------------------------------------------------------------------------
D:\Projekte\monalysis\modules\base\tests\scope_exit_test.cpp(21)
...............................................................................

D:\Projekte\monalysis\modules\base\tests\scope_exit_test.cpp(24): FAILED:
  REQUIRE( false )
with message:


===============================================================================
test cases: 1 | 1 failed
assertions: 2 | 2 failed

I'd expect that the message Message with newline also be printed.

Extra information

  • Catch version: v2.4.2
  • Operating System: Windows10 x64
  • Compiler+version: Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27023.1 for x64
@an-ky an-ky changed the title INFO() gives surprise result when string starts with newline INFO() does not print message when starting with newline Nov 23, 2018
@horenmar
Copy link
Member

That is very much a (weird) bug.

@horenmar horenmar added the Bug label Nov 23, 2018
@horenmar
Copy link
Member

horenmar commented Nov 29, 2018

After further investigations, this happens only for the Console (default) reporter.


The problem is in TextFlow's Column::iterator::calcLength that sees the "\n" and decides that means that the message must end there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants