Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you use Assert.ReplaceNullChars(string input)?

Why would you use the following?

Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ReplaceNullChars(string input)

I have searched but can't find any cases of anyone really using this. Even MSDN is not helpful. All I can find out about it is:

ReplaceNullChars – Replaces Null characters in a string \0 with \\0

This doesn't sound all that useful to me and I'm suprised it's there in the Assert class.

like image 899
Buh Buh Avatar asked Apr 18 '11 10:04

Buh Buh


1 Answers

It’s probably so that you can print a string containing null chars for better diagnostics, since printing a string which contains a null char usually doesn’t result in anything meaningful (it will usually be truncated in the output).

However, a better method would have been Assert.EscapeNonprintableChars – i.e. replace not only \0 but all non-printable characters.

like image 123
Konrad Rudolph Avatar answered Sep 28 '22 11:09

Konrad Rudolph