开发者

xUnit false positive when comparing null terminated strings

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()
{开发者_JAVA技巧
    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?


This issue has been fixed.

Here: Assert.Equal("foo", "foo\0") does not fail

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜