-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGenericLinksTests.cs
More file actions
57 lines (51 loc) · 2.57 KB
/
GenericLinksTests.cs
File metadata and controls
57 lines (51 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.IO;
using System.Numerics;
using Platform.Data.Doublets.Decorators;
using Xunit;
using Platform.Memory;
using Platform.Data.Doublets.Memory.United.Generic;
namespace Platform.Data.Doublets.Tests
{
public static class GenericLinksTests
{
[Fact]
public static void CRUDTest()
{
Using<byte>(links => links.TestCRUDOperations());
Using<ushort>(links => links.TestCRUDOperations());
Using<uint>(links => links.TestCRUDOperations());
Using<ulong>(links => links.TestCRUDOperations());
}
[Fact]
public static void RawNumbersCRUDTest()
{
Using<byte>(links => links.TestRawNumbersCRUDOperations());
Using<ushort>(links => links.TestRawNumbersCRUDOperations());
Using<uint>(links => links.TestRawNumbersCRUDOperations());
Using<ulong>(links => links.TestRawNumbersCRUDOperations());
}
[Fact]
public static void MultipleRandomCreationsAndDeletionsTest()
{
Using<byte>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(16)); // Cannot use more because current implementation of tree cuts out 5 bits from the address space.
Using<ushort>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
Using<uint>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
Using<ulong>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
}
private static void Using<TLinkAddress>(Action<ILinks<TLinkAddress>> action) where TLinkAddress : IUnsignedNumber<TLinkAddress> , IShiftOperators<TLinkAddress,int,TLinkAddress>, IBitwiseOperators<TLinkAddress,TLinkAddress,TLinkAddress>, IMinMaxValue<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
{
var unitedMemoryLinks = new UnitedMemoryLinks<TLinkAddress>(new HeapResizableDirectMemory());
using (var logFile = File.Open("linksLogger.txt", FileMode.Create, FileAccess.Write))
{
LoggingDecorator<TLinkAddress> decoratedStorage = new(unitedMemoryLinks, logFile);
action(decoratedStorage);
}
/*
File.Delete("db.links");
using var ffiLinks = new Ffi.Links<TLinkAddress>("db.links");
action(ffiLinks);
*/
}
}
}