Skip to content

Commit eca454a

Browse files
author
LoneWandererProductions
committed
Try my luck with a new unsafe Array implementation.
Sort out my ExtendedSystemObjects test into its own project
1 parent 6ec42dc commit eca454a

21 files changed

Lines changed: 589 additions & 29 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
13+
<PackageReference Include="coverlet.collector" Version="3.2.0" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\ExtendedSystemObjects\ExtendedSystemObjects.csproj" />
18+
<ProjectReference Include="..\Mathematics\Mathematics.csproj" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* COPYRIGHT: See COPYING in the top level directory
3+
* PROJECT: CommonExtendedObjectsTests
4+
* FILE: CommonExtendedObjectsTests/DataItem.cs
5+
* PURPOSE: Basic Object needed for DataList, copy from CommonControls to safe a reference.
6+
* PROGRAMER: Peter Geinitz (Wayfarer)
7+
*/
8+
9+
// ReSharper disable ArrangeBraces_foreach
10+
// ReSharper disable PropertyCanBeMadeInitOnly.Global
11+
12+
using System;
13+
14+
namespace CommonExtendedObjectsTests
15+
{
16+
/// <inheritdoc cref="ObservableObject" />
17+
/// <summary>
18+
/// Data Object
19+
/// </summary>
20+
internal sealed class DataItem
21+
{
22+
/// <summary>
23+
/// The id.
24+
/// </summary>
25+
private int _id;
26+
27+
/// <summary>
28+
/// The name.
29+
/// </summary>
30+
private string _name;
31+
32+
/// <summary>
33+
/// Gets or sets the id.
34+
/// </summary>
35+
internal int Id
36+
{
37+
get => _id;
38+
set
39+
{
40+
if (_id == value)
41+
{
42+
return;
43+
}
44+
45+
_id = value;
46+
}
47+
}
48+
49+
/// <summary>
50+
/// Gets or sets the name.
51+
/// </summary>
52+
internal string Name
53+
{
54+
get => _name;
55+
set
56+
{
57+
if (_name == value)
58+
{
59+
return;
60+
}
61+
62+
_name = value;
63+
}
64+
}
65+
66+
/// <inheritdoc />
67+
/// <summary>
68+
/// Indicates whether the current object is equal to another object of the same type.
69+
/// </summary>
70+
/// <param name="other">An object to compare with this object.</param>
71+
/// <returns>
72+
/// <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise,
73+
/// <see langword="false" />.
74+
/// </returns>
75+
internal bool Equals(DataItem other)
76+
{
77+
if (ReferenceEquals(null, other))
78+
{
79+
return false;
80+
}
81+
82+
if (ReferenceEquals(this, other))
83+
{
84+
return true;
85+
}
86+
87+
return _id == other._id && _name == other._name;
88+
}
89+
90+
/// <inheritdoc />
91+
/// <summary>
92+
/// Determines whether the specified <see cref="object" />, is equal to this instance.
93+
/// </summary>
94+
/// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
95+
/// <returns>
96+
/// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
97+
/// </returns>
98+
public override bool Equals(object obj)
99+
{
100+
return ReferenceEquals(this, obj) || obj is DataItem other && Equals(other);
101+
}
102+
103+
/// <inheritdoc />
104+
/// <summary>
105+
/// Returns a hash code for this instance.
106+
/// </summary>
107+
/// <returns>
108+
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
109+
/// </returns>
110+
public override int GetHashCode()
111+
{
112+
return HashCode.Combine(_id);
113+
}
114+
}
115+
}

CommonLibraryTests/ExtendedSystemObjects.cs renamed to CommonExtendedObjectsTests/ExtendedSystemObjects.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: CommonLibraryTests
4-
* FILE: CommonLibraryTests/ExtendedSystemObjects.cs
3+
* PROJECT: CommonExtendedObjectsTests
4+
* FILE: CommonExtendedObjectsTests/ExtendedSystemObjects.cs
55
* PURPOSE: Tests for ExtendedSystemObjects
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
@@ -18,7 +18,7 @@
1818
using Mathematics;
1919
using Microsoft.VisualStudio.TestTools.UnitTesting;
2020

21-
namespace CommonLibraryTests
21+
namespace CommonExtendedObjectsTests
2222
{
2323
/// <summary>
2424
/// CommonLibraryTests Extended system objects unit test class.

CommonLibraryTests/ExtendedSystemObjectsSetOperation.cs renamed to CommonExtendedObjectsTests/ExtendedSystemObjectsSetOperation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: CommonLibraryTests
4-
* FILE: CommonLibraryTests/ExtendedSystemObjectsSetOperation.cs
3+
* PROJECT: CommonExtendedObjectsTests
4+
* FILE: CommonExtendedObjectsTests/ExtendedSystemObjectsSetOperation.cs
55
* PURPOSE: Tests for ExtendedSystemObjects, Set Operations
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
@@ -10,7 +10,7 @@
1010
using ExtendedSystemObjects;
1111
using Microsoft.VisualStudio.TestTools.UnitTesting;
1212

13-
namespace CommonLibraryTests
13+
namespace CommonExtendedObjectsTests
1414
{
1515
/// <summary>
1616
/// Test for Base Set Operations
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* COPYRIGHT: See COPYING in the top level directory
3+
* PROJECT: CommonExtendedObjectsTests
4+
* FILE: CommonExtendedObjectsTests/HelperMethods.cs
5+
* PURPOSE: Helper Methods
6+
* PROGRAMER: Peter Geinitz (Wayfarer)
7+
*/
8+
9+
using ExtendedSystemObjects;
10+
using Mathematics;
11+
12+
namespace CommonExtendedObjectsTests
13+
{
14+
/// <summary>
15+
/// The helper methods class.
16+
/// </summary>
17+
internal static class HelperMethods
18+
{
19+
/// <summary>
20+
/// Tests one. Matrix Multiplication
21+
/// </summary>
22+
/// <param name="mOne">The m one.</param>
23+
/// <param name="mTwo">The m two.</param>
24+
/// <returns>Matrix Multiplications</returns>
25+
internal static BaseMatrix MatrixTestOne(BaseMatrix mOne, BaseMatrix mTwo)
26+
{
27+
var h = mOne.Height;
28+
var w = mTwo.Width;
29+
var l = mOne.Width;
30+
var result = new BaseMatrix(h, w);
31+
var spanOne = mOne.Matrix.ToSpan();
32+
var spanTwo = mTwo.Matrix.ToSpan();
33+
var spanResult = result.Matrix.ToSpan();
34+
35+
for (var i = 0; i < h; i++)
36+
{
37+
var iOne = i * l;
38+
39+
for (var j = 0; j < w; j++)
40+
{
41+
var iTwo = j;
42+
43+
double res = 0;
44+
45+
for (var k = 0; k < l; k++, iTwo += w)
46+
{
47+
res += spanOne[iOne + k] * spanTwo[iTwo];
48+
}
49+
50+
spanResult[i * w + j] = res;
51+
}
52+
}
53+
54+
return result;
55+
}
56+
}
57+
}

CommonLibraryTests/ImmutableLookupMapTests.cs renamed to CommonExtendedObjectsTests/ImmutableLookupMapTests.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: CommonLibraryTests
3+
* PROJECT: CommonExtendedObjectsTests
44
* FILE: ImmutableLookupMapTests.cs
55
* PURPOSE: Your file purpose here
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
@@ -12,16 +12,27 @@
1212
using ExtendedSystemObjects;
1313
using Microsoft.VisualStudio.TestTools.UnitTesting;
1414

15-
namespace CommonLibraryTests
15+
namespace CommonExtendedObjectsTests
1616
{
1717
/// <summary>
1818
/// Generic tests for speed.
1919
/// </summary>
2020
[TestClass]
2121
public class PerformanceTests
2222
{
23+
/// <summary>
24+
/// The data
25+
/// </summary>
2326
private Dictionary<int, string> _data;
27+
28+
/// <summary>
29+
/// The immutable lookup map
30+
/// </summary>
2431
private ImmutableLookupMap<int, string> _immutableLookupMap;
32+
33+
/// <summary>
34+
/// The read only dictionary
35+
/// </summary>
2536
private ReadOnlyDictionary<int, string> _readOnlyDictionary;
2637

2738
/// <summary>

0 commit comments

Comments
 (0)