xUnit false positive when comparing null terminated strings

Posted by mr.b on Stack Overflow See other posts from Stack Overflow or by mr.b
Published on 2010-02-12T00:34:47Z Indexed on 2010/05/15 10:14 UTC
Read the original article Hit count: 204

Filed under:
|
|
|

I've come across odd behavior when comparing strings. First assert passes, but I don't think it should.. Second assert fails, as expected...

[Fact]
public void StringTest()
{
    string testString_1 = "My name is Erl. I am a program\0";
    string testString_2 = "My name is Erl. I am a program";

    Assert.Equal<string>(testString_1, testString_2);
    Assert.True(testString_1.Equals(testString_2));
}

Any ideas?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET