提交 abaeff6a 编写于 作者: J Jared Parsons

Merge pull request #6916 from TyOverby/6744-no-copy-fuzz

Don't copy a massive byte-array for fuzz testing
......@@ -61,6 +61,7 @@
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CodeAnalysisRuleSet>..\..\..\..\..\build\TestProjectRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<CodeAnalysisRuleSet>..\..\..\..\..\build\TestProjectRules.ruleset</CodeAnalysisRuleSet>
......@@ -102,7 +103,7 @@
<Compile Include="Parsing\CrefParsingTests.cs" />
<Compile Include="Parsing\DeclarationParsingTests.cs" />
<Compile Include="Parsing\ExpressionParsingTests.cs" />
<Compile Include="Parsing\FuzzTesting.cs" />
<Compile Include="Parsing\ParserRegressionTests.cs" />
<Compile Include="Parsing\ScriptParsingTests.cs" />
<Compile Include="Parsing\LambdaParameterParsingTests.cs" />
<Compile Include="Parsing\NameAttributeValueParsingTests.cs" />
......@@ -171,4 +172,4 @@
<Import Project="..\..\..\..\..\build\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\..\..\build\Targets\Roslyn.Toolsets.Xunit.targets" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -9,7 +9,7 @@
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Parsing
{
public class FuzzTesting : CSharpTestBase
public class ParserRegressionTests : CSharpTestBase
{
[WorkItem(540005, "DevDiv")]
[Fact]
......@@ -83,16 +83,24 @@ public void c024928()
[Fact]
public void TestBinary()
{
// use a fixed seed so the test is reproducible
// Apparently this fixed seed exposed a bug at some point
var random = new System.Random(12345);
const int n = 40 * 1000 * 1000; // 40 million "character"s
var builder = new StringBuilder(n + 10);
for (int i = 0; i < n; i++)
// 40 million "character"s
const int n = 40 * 1000 * 1000;
var str = new string(' ', n);
unsafe
{
builder.Append((char)random.Next(0xffff));
fixed(char* chars = str)
{
for(int i = 0; i < n; i++)
{
chars[i] = (char)random.Next(char.MaxValue);
}
}
}
var source = builder.ToString();
var tree = CSharpSyntaxTree.ParseText(source);
var tree = CSharpSyntaxTree.ParseText(str);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册