Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
FreePhoenix888 committed Jul 18, 2021
1 parent 51a8c8b commit 595ea9d
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions csharp/Platform.Data.Doublets.Tests/DefaultSequenceAppenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,33 @@ public static ILinks<TLink> CreateLinks<TLink>(string dataDBFilename)
public class ValueCriterionMatcher<TLink> : ICriterionMatcher<TLink>
{
public readonly ILinks<TLink> Links;
public readonly TLink ValueMarker;
public ValueCriterionMatcher(ILinks<TLink> links, TLink valueMarker)
public readonly TLink Marker;
public ValueCriterionMatcher(ILinks<TLink> links, TLink marker)
{
Links = links;
ValueMarker = valueMarker;
Marker = marker;
}

public bool IsMatched(TLink link) => EqualityComparer<TLink>.Default.Equals(Links.GetSource(link), ValueMarker);
public bool IsMatched(TLink link) => EqualityComparer<TLink>.Default.Equals(Links.GetSource(link), Marker);
}

[Fact]
public void AppendArrayBug()
{
ILinks<TLink> links = CreateLinks();
TLink zero = default;
var one = Arithmetic.Increment(zero);
var markerIndex = one;
var markerIndex = Arithmetic.Increment(zero);
var meaningRoot = links.GetOrCreate(markerIndex, markerIndex);
var valueMarker = links.GetOrCreate(meaningRoot, Arithmetic.Increment(ref markerIndex));
var numberMarker = links.GetOrCreate(meaningRoot, Arithmetic.Increment(ref markerIndex));
var arrayMarker = links.GetOrCreate(meaningRoot, Arithmetic.Increment(ref markerIndex));
AddressToRawNumberConverter<TLink> addressToNumberConverter = new();
var numberOneAddress = addressToNumberConverter.Convert(1);
var numberOneLink = links.GetOrCreate(numberMarker, numberOneAddress);
var array = links.GetOrCreate(arrayMarker, numberOneLink);
var arrayValue = links.GetOrCreate(valueMarker, array);
var numberTwoAddress = addressToNumberConverter.Convert(2);
var numberTwoLink = links.GetOrCreate(numberMarker, numberTwoAddress);
var appendant = links.GetOrCreate(valueMarker, numberTwoLink);
var equalityComparer = EqualityComparer<TLink>.Default;
ValueCriterionMatcher<TLink> valueCriterionMatcher = new(links, valueMarker);
var sequence = links.Create();
sequence = links.Update(sequence, meaningRoot, sequence);
var appendant = links.Create();
appendant = links.Update(appendant, meaningRoot, appendant);
ValueCriterionMatcher<TLink> valueCriterionMatcher = new(links, meaningRoot);
DefaultSequenceRightHeightProvider<ulong> defaultSequenceRightHeightProvider = new(links, valueCriterionMatcher);
DefaultSequenceAppender<TLink> defaultSequenceAppender = new(links, new DefaultStack<ulong>(), defaultSequenceRightHeightProvider);
var newArray = defaultSequenceAppender.Append(arrayValue, appendant);
var newArray = defaultSequenceAppender.Append(sequence, appendant);
var output = links.FormatStructure(newArray, link => link.IsFullPoint(), true);
Assert.Equal("(4:(2:1 2) (3:1 3))", output);
}
}
}

0 comments on commit 595ea9d

Please sign in to comment.