mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-09 20:29:11 +00:00
Convert TreeDictionaryTests to xUnit
This commit is contained in:
parent
8e5e86e61a
commit
4d37b75f95
1 changed files with 106 additions and 98 deletions
|
@ -1,18 +1,26 @@
|
||||||
using NUnit.Framework;
|
|
||||||
using Ryujinx.Common.Collections;
|
using Ryujinx.Common.Collections;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace Ryujinx.Tests.Collections
|
namespace Ryujinx.Tests.Collections
|
||||||
{
|
{
|
||||||
class TreeDictionaryTests
|
public class TreeDictionaryTests
|
||||||
{
|
{
|
||||||
[Test]
|
private readonly ITestOutputHelper _testOutputHelper;
|
||||||
|
|
||||||
|
public TreeDictionaryTests(ITestOutputHelper testOutputHelper)
|
||||||
|
{
|
||||||
|
_testOutputHelper = testOutputHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public void EnsureAddIntegrity()
|
public void EnsureAddIntegrity()
|
||||||
{
|
{
|
||||||
TreeDictionary<int, int> dictionary = new();
|
TreeDictionary<int, int> dictionary = new();
|
||||||
|
|
||||||
Assert.AreEqual(dictionary.Count, 0);
|
Assert.Equal(0, dictionary.Count);
|
||||||
|
|
||||||
dictionary.Add(2, 7);
|
dictionary.Add(2, 7);
|
||||||
dictionary.Add(1, 4);
|
dictionary.Add(1, 4);
|
||||||
|
@ -22,7 +30,7 @@ namespace Ryujinx.Tests.Collections
|
||||||
dictionary.Add(11, 2);
|
dictionary.Add(11, 2);
|
||||||
dictionary.Add(5, 2);
|
dictionary.Add(5, 2);
|
||||||
|
|
||||||
Assert.AreEqual(dictionary.Count, 7);
|
Assert.Equal(7, dictionary.Count);
|
||||||
|
|
||||||
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
||||||
|
|
||||||
|
@ -36,22 +44,22 @@ namespace Ryujinx.Tests.Collections
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Assert.AreEqual(list.Count, dictionary.Count);
|
Assert.Equal(list.Count, dictionary.Count);
|
||||||
Assert.AreEqual(list[0].Key, 2);
|
Assert.Equal(2, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 1);
|
Assert.Equal(1, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 4);
|
Assert.Equal(4, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 3);
|
Assert.Equal(3, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 10);
|
Assert.Equal(10, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 5);
|
Assert.Equal(5, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 11);
|
Assert.Equal(11, list[6].Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Fact]
|
||||||
public void EnsureRemoveIntegrity()
|
public void EnsureRemoveIntegrity()
|
||||||
{
|
{
|
||||||
TreeDictionary<int, int> dictionary = new();
|
TreeDictionary<int, int> dictionary = new();
|
||||||
|
|
||||||
Assert.AreEqual(dictionary.Count, 0);
|
Assert.Equal(0, dictionary.Count);
|
||||||
|
|
||||||
dictionary.Add(2, 7);
|
dictionary.Add(2, 7);
|
||||||
dictionary.Add(1, 4);
|
dictionary.Add(1, 4);
|
||||||
|
@ -66,7 +74,7 @@ namespace Ryujinx.Tests.Collections
|
||||||
dictionary.Add(13, 2);
|
dictionary.Add(13, 2);
|
||||||
dictionary.Add(24, 2);
|
dictionary.Add(24, 2);
|
||||||
dictionary.Add(6, 2);
|
dictionary.Add(6, 2);
|
||||||
Assert.AreEqual(dictionary.Count, 13);
|
Assert.Equal(13, dictionary.Count);
|
||||||
|
|
||||||
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
||||||
|
|
||||||
|
@ -82,22 +90,22 @@ namespace Ryujinx.Tests.Collections
|
||||||
|
|
||||||
foreach (KeyValuePair<int, int> node in list)
|
foreach (KeyValuePair<int, int> node in list)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{node.Key} -> {node.Value}");
|
_testOutputHelper.WriteLine($"{node.Key} -> {node.Value}");
|
||||||
}
|
}
|
||||||
Assert.AreEqual(list.Count, dictionary.Count);
|
Assert.Equal(list.Count, dictionary.Count);
|
||||||
Assert.AreEqual(list[0].Key, 4);
|
Assert.Equal(4, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 2);
|
Assert.Equal(2, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 10);
|
Assert.Equal(10, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 1);
|
Assert.Equal(1, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 3);
|
Assert.Equal(3, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 7);
|
Assert.Equal(7, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 13);
|
Assert.Equal(13, list[6].Key);
|
||||||
Assert.AreEqual(list[7].Key, 5);
|
Assert.Equal(5, list[7].Key);
|
||||||
Assert.AreEqual(list[8].Key, 9);
|
Assert.Equal(9, list[8].Key);
|
||||||
Assert.AreEqual(list[9].Key, 11);
|
Assert.Equal(11, list[9].Key);
|
||||||
Assert.AreEqual(list[10].Key, 24);
|
Assert.Equal(24, list[10].Key);
|
||||||
Assert.AreEqual(list[11].Key, 6);
|
Assert.Equal(6, list[11].Key);
|
||||||
Assert.AreEqual(list[12].Key, 8);
|
Assert.Equal(8, list[12].Key);
|
||||||
|
|
||||||
list.Clear();
|
list.Clear();
|
||||||
|
|
||||||
|
@ -116,20 +124,20 @@ namespace Ryujinx.Tests.Collections
|
||||||
list = dictionary.AsLevelOrderList();
|
list = dictionary.AsLevelOrderList();
|
||||||
foreach (KeyValuePair<int, int> node in list)
|
foreach (KeyValuePair<int, int> node in list)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{node.Key} -> {node.Value}");
|
_testOutputHelper.WriteLine($"{node.Key} -> {node.Value}");
|
||||||
}
|
}
|
||||||
Assert.AreEqual(list[0].Key, 4);
|
Assert.Equal(4, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 2);
|
Assert.Equal(2, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 10);
|
Assert.Equal(10, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 1);
|
Assert.Equal(1, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 3);
|
Assert.Equal(3, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 6);
|
Assert.Equal(6, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 13);
|
Assert.Equal(13, list[6].Key);
|
||||||
Assert.AreEqual(list[7].Key, 5);
|
Assert.Equal(5, list[7].Key);
|
||||||
Assert.AreEqual(list[8].Key, 9);
|
Assert.Equal(9, list[8].Key);
|
||||||
Assert.AreEqual(list[9].Key, 11);
|
Assert.Equal(11, list[9].Key);
|
||||||
Assert.AreEqual(list[10].Key, 24);
|
Assert.Equal(24, list[10].Key);
|
||||||
Assert.AreEqual(list[11].Key, 8);
|
Assert.Equal(8, list[11].Key);
|
||||||
|
|
||||||
list.Clear();
|
list.Clear();
|
||||||
|
|
||||||
|
@ -147,27 +155,27 @@ namespace Ryujinx.Tests.Collections
|
||||||
*/
|
*/
|
||||||
foreach (KeyValuePair<int, int> node in list)
|
foreach (KeyValuePair<int, int> node in list)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{node.Key} -> {node.Value}");
|
_testOutputHelper.WriteLine($"{node.Key} -> {node.Value}");
|
||||||
}
|
}
|
||||||
Assert.AreEqual(list[0].Key, 4);
|
Assert.Equal(4, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 2);
|
Assert.Equal(2, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 9);
|
Assert.Equal(9, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 1);
|
Assert.Equal(1, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 3);
|
Assert.Equal(3, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 6);
|
Assert.Equal(6, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 13);
|
Assert.Equal(13, list[6].Key);
|
||||||
Assert.AreEqual(list[7].Key, 5);
|
Assert.Equal(5, list[7].Key);
|
||||||
Assert.AreEqual(list[8].Key, 8);
|
Assert.Equal(8, list[8].Key);
|
||||||
Assert.AreEqual(list[9].Key, 11);
|
Assert.Equal(11, list[9].Key);
|
||||||
Assert.AreEqual(list[10].Key, 24);
|
Assert.Equal(24, list[10].Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Fact]
|
||||||
public void EnsureOverwriteIntegrity()
|
public void EnsureOverwriteIntegrity()
|
||||||
{
|
{
|
||||||
TreeDictionary<int, int> dictionary = new();
|
TreeDictionary<int, int> dictionary = new();
|
||||||
|
|
||||||
Assert.AreEqual(dictionary.Count, 0);
|
Assert.Equal(0, dictionary.Count);
|
||||||
|
|
||||||
dictionary.Add(2, 7);
|
dictionary.Add(2, 7);
|
||||||
dictionary.Add(1, 4);
|
dictionary.Add(1, 4);
|
||||||
|
@ -182,7 +190,7 @@ namespace Ryujinx.Tests.Collections
|
||||||
dictionary.Add(13, 2);
|
dictionary.Add(13, 2);
|
||||||
dictionary.Add(24, 2);
|
dictionary.Add(24, 2);
|
||||||
dictionary.Add(6, 2);
|
dictionary.Add(6, 2);
|
||||||
Assert.AreEqual(dictionary.Count, 13);
|
Assert.Equal(13, dictionary.Count);
|
||||||
|
|
||||||
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
List<KeyValuePair<int, int>> list = dictionary.AsLevelOrderList();
|
||||||
|
|
||||||
|
@ -201,44 +209,44 @@ namespace Ryujinx.Tests.Collections
|
||||||
* 6 8
|
* 6 8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Assert.AreEqual(list.Count, dictionary.Count);
|
Assert.Equal(list.Count, dictionary.Count);
|
||||||
Assert.AreEqual(list[0].Key, 4);
|
Assert.Equal(4, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 2);
|
Assert.Equal(2, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 10);
|
Assert.Equal(10, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 1);
|
Assert.Equal(1, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 3);
|
Assert.Equal(3, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 7);
|
Assert.Equal(7, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 13);
|
Assert.Equal(13, list[6].Key);
|
||||||
Assert.AreEqual(list[7].Key, 5);
|
Assert.Equal(5, list[7].Key);
|
||||||
Assert.AreEqual(list[8].Key, 9);
|
Assert.Equal(9, list[8].Key);
|
||||||
Assert.AreEqual(list[9].Key, 11);
|
Assert.Equal(11, list[9].Key);
|
||||||
Assert.AreEqual(list[10].Key, 24);
|
Assert.Equal(24, list[10].Key);
|
||||||
Assert.AreEqual(list[11].Key, 6);
|
Assert.Equal(6, list[11].Key);
|
||||||
Assert.AreEqual(list[12].Key, 8);
|
Assert.Equal(8, list[12].Key);
|
||||||
|
|
||||||
Assert.AreEqual(list[4].Value, 2);
|
Assert.Equal(2, list[4].Value);
|
||||||
|
|
||||||
dictionary.Add(3, 4);
|
dictionary.Add(3, 4);
|
||||||
|
|
||||||
list = dictionary.AsLevelOrderList();
|
list = dictionary.AsLevelOrderList();
|
||||||
|
|
||||||
Assert.AreEqual(list[4].Value, 4);
|
Assert.Equal(4, list[4].Value);
|
||||||
|
|
||||||
|
|
||||||
// Assure that none of the nodes locations have been modified.
|
// Assure that none of the nodes locations have been modified.
|
||||||
Assert.AreEqual(list[0].Key, 4);
|
Assert.Equal(4, list[0].Key);
|
||||||
Assert.AreEqual(list[1].Key, 2);
|
Assert.Equal(2, list[1].Key);
|
||||||
Assert.AreEqual(list[2].Key, 10);
|
Assert.Equal(10, list[2].Key);
|
||||||
Assert.AreEqual(list[3].Key, 1);
|
Assert.Equal(1, list[3].Key);
|
||||||
Assert.AreEqual(list[4].Key, 3);
|
Assert.Equal(3, list[4].Key);
|
||||||
Assert.AreEqual(list[5].Key, 7);
|
Assert.Equal(7, list[5].Key);
|
||||||
Assert.AreEqual(list[6].Key, 13);
|
Assert.Equal(13, list[6].Key);
|
||||||
Assert.AreEqual(list[7].Key, 5);
|
Assert.Equal(5, list[7].Key);
|
||||||
Assert.AreEqual(list[8].Key, 9);
|
Assert.Equal(9, list[8].Key);
|
||||||
Assert.AreEqual(list[9].Key, 11);
|
Assert.Equal(11, list[9].Key);
|
||||||
Assert.AreEqual(list[10].Key, 24);
|
Assert.Equal(24, list[10].Key);
|
||||||
Assert.AreEqual(list[11].Key, 6);
|
Assert.Equal(6, list[11].Key);
|
||||||
Assert.AreEqual(list[12].Key, 8);
|
Assert.Equal(8, list[12].Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue