Browse Source

add failing unit test to "Conversions"

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
5a13a6f649
  1. 22
      ICSharpCode.Decompiler/Tests/TestCases/Conversions.cs

22
ICSharpCode.Decompiler/Tests/TestCases/Conversions.cs

@ -107,6 +107,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases @@ -107,6 +107,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases
{
RunTest(checkForOverflow: false);
RunTest(checkForOverflow: true);
Console.WriteLine(ReadZeroTerminatedString("Hello World!".Length));
}
static void RunTest(bool checkForOverflow)
@ -133,5 +135,25 @@ namespace ICSharpCode.Decompiler.Tests.TestCases @@ -133,5 +135,25 @@ namespace ICSharpCode.Decompiler.Tests.TestCases
return (UInt64)c;
}
}
static string ReadZeroTerminatedString (int length)
{
int read = 0;
var buffer = new char [length];
var bytes = ReadBytes (length);
while (read < length) {
var current = bytes [read];
if (current == 0)
break;
buffer [read++] = (char) current;
}
return new string (buffer, 0, read);
}
static byte[] ReadBytes(int length) {
return System.Text.Encoding.ASCII.GetBytes("Hello World!");
}
}
}

Loading…
Cancel
Save