commit
9b5609f8ea
|
@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26228.9
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonDiffPatchDotNet.Roslyn", "JsonDiffPatchDotNet\JsonDiffPatchDotNet.Roslyn.csproj", "{50825AC2-B521-47D9-9A68-DF6689DF61CC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonDiffPatchDotNet.UnitTests.Roslyn", "JsonDiffPatchDotNet.UnitTests\JsonDiffPatchDotNet.UnitTests.Roslyn.csproj", "{A1872054-FB38-422B-A831-D2E530F5C9CC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -15,6 +17,10 @@ Global
|
|||
{50825AC2-B521-47D9-9A68-DF6689DF61CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{50825AC2-B521-47D9-9A68-DF6689DF61CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{50825AC2-B521-47D9-9A68-DF6689DF61CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A1872054-FB38-422B-A831-D2E530F5C9CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A1872054-FB38-422B-A831-D2E530F5C9CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A1872054-FB38-422B-A831-D2E530F5C9CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A1872054-FB38-422B-A831-D2E530F5C9CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@ -257,36 +256,33 @@ namespace JsonDiffPatchDotNet.UnitTests
|
|||
Assert.IsNull(diff);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Diff_EfficientArrayDiffHugeArrays_NoStackOverflow()
|
||||
{
|
||||
const int ARRAY_SIZE = 1000;
|
||||
Func<int, int, JToken> hugeArrayFunc = (startIndex, count) =>
|
||||
{
|
||||
var builder = new StringBuilder("[");
|
||||
foreach (var i in Enumerable.Range(startIndex, count))
|
||||
{
|
||||
builder.Append($"{i},");
|
||||
}
|
||||
builder.Append("]");
|
||||
[Test]
|
||||
public void Diff_EfficientArrayDiffHugeArrays_NoStackOverflow()
|
||||
{
|
||||
const int ARRAY_SIZE = 1000;
|
||||
Func<int, int, JToken> hugeArrayFunc = (startIndex, count) =>
|
||||
{
|
||||
var builder = new StringBuilder("[");
|
||||
foreach (var i in Enumerable.Range(startIndex, count))
|
||||
{
|
||||
builder.Append($"{i},");
|
||||
}
|
||||
builder.Append("]");
|
||||
|
||||
return JToken.Parse(builder.ToString());
|
||||
};
|
||||
return JToken.Parse(builder.ToString());
|
||||
};
|
||||
|
||||
var jdp = new JsonDiffPatch();
|
||||
var left = hugeArrayFunc(0, ARRAY_SIZE);
|
||||
var right = hugeArrayFunc(ARRAY_SIZE / 2, ARRAY_SIZE);
|
||||
var jdp = new JsonDiffPatch();
|
||||
var left = hugeArrayFunc(0, ARRAY_SIZE);
|
||||
var right = hugeArrayFunc(ARRAY_SIZE / 2, ARRAY_SIZE);
|
||||
|
||||
JToken diff = null;
|
||||
var thread = new Thread(() => diff = jdp.Diff(left, right), 128 * 2014);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
JToken diff = jdp.Diff(left, right);
|
||||
var restored = jdp.Patch(left, diff);
|
||||
|
||||
var restored = jdp.Patch(left, diff);
|
||||
Assert.That(JToken.DeepEquals(restored, right));
|
||||
}
|
||||
Assert.That(JToken.DeepEquals(restored, right));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Test]
|
||||
public void Diff_IntStringDiff_ValidPatch()
|
||||
{
|
||||
var jdp = new JsonDiffPatch();
|
||||
|
@ -301,5 +297,5 @@ namespace JsonDiffPatchDotNet.UnitTests
|
|||
Assert.AreEqual(left, array[0]);
|
||||
Assert.AreEqual(right, array[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard1.6</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<OutputTypeEx>library</OutputTypeEx>
|
||||
<StartupObject />
|
||||
<!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 -->
|
||||
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp1.0'">Full</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="NUnit" Version="3.6.1" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JsonDiffPatchDotNet\JsonDiffPatchDotNet.Roslyn.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Tracking for removal https://github.com/Microsoft/vstest/issues/472 -->
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
|
Loading…
Reference in New Issue