-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unbounded memory growth in DoubleArrayConverter (#6412)
* Fix unbounded memory growth in DoubleArrayConverter * Whitespace
- Loading branch information
Showing
2 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Nethermind/Nethermind.Core.Test/Json/DoubleArrayConverterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Text.Json; | ||
using Nethermind.Serialization.Json; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Nethermind.Core.Test.Json; | ||
|
||
[TestFixture] | ||
public class DoubleArrayConverterTests : ConverterTestBase<double[]> | ||
{ | ||
static readonly DoubleArrayConverter converter = new(); | ||
|
||
[Test] | ||
public void Test_roundtrip() | ||
{ | ||
TestConverter(new double[] { -0.5, 0.5, 1.0, 1.5, 2.0, 2.5 }, (a, b) => a.AsSpan().SequenceEqual(b), converter); | ||
TestConverter(new double[] { 1, 1, 1, 1 }, (a, b) => a.AsSpan().SequenceEqual(b), converter); | ||
TestConverter(new double[] { 0, 0, 0, 0 }, (a, b) => a.AsSpan().SequenceEqual(b), converter); | ||
TestConverter(Array.Empty<double>(), (a, b) => a.AsSpan().SequenceEqual(b), converter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters