Skip to content

String.Should().Be() output displays incorrect actual value #1223

@ghost

Description

Description

The output for failed string.Should().Be() shows the incorrect actual value when the value contains JSON strings ending with }}}}.

Complete minimal example reproducing the issue

string expect = "{\"a\":{\"b\":1}}";
string actual = "{\"a\":{\"b\":1}}}}";
actual.Should().Be(expect);

Expected behavior:

FluentAssertions.Execution.AssertionFailedException: Expected actual to be
"{"a":{"b":1}}" with a length of 13, but
"{"a":{"b":1}}}}" has a length of 15, differs near "}}" (index 13).

Actual behavior:

FluentAssertions.Execution.AssertionFailedException: Expected actual to be
"{"a":{"b":1}}" with a length of 13, but
"{"a":{"b":1}}" has a length of 15, differs near "}}" (index 13).

Versions

Fluent Assertions 5.10.0 Targetting .Net Core 2.0/2.1/2.2/3.0/3.1
Fluent Assertions 5.10.0 Targetting .Net Framework 4.7.2 (not tried others)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions