com.wallstop-studios.unity-helpers 2.0.0-rc79.3 → 2.0.0-rc79.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +5 -1
- package/.github/workflows/npm-publish.yml +2 -2
- package/Runtime/Core/Extension/IReadonlyListExtensions.cs +1 -1
- package/Runtime/Core/Extension/IReadonlyListExtensions.cs.meta +1 -1
- package/Runtime/Core/Extension/StringExtensions.cs +1 -1
- package/Runtime/Core/Helper/StringInList.cs +3 -21
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +157 -49
- package/Runtime/Utils/Buffers.cs +118 -2
- package/Runtime/Utils/SevenZip/Common/CRC.cs +9 -0
- package/Runtime/Utils/SevenZip/Common/InBuffer.cs +15 -2
- package/Runtime/Utils/SevenZip/Common/OutBuffer.cs +7 -2
- package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs +50 -0
- package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs +26 -0
- package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs +27 -0
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs +9 -0
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs +80 -17
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs +265 -30
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs +9 -0
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs +13 -1
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs +11 -4
- package/Tests/Runtime/Core/Threading/SingleThreadedThreadPoolTests.cs +54 -0
- package/Tests/Runtime/Core/Threading/SingleThreadedThreadPoolTests.cs.meta +3 -0
- package/Tests/Runtime/Core/Threading.meta +3 -0
- package/Tests/Runtime/Core.meta +3 -0
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +1 -1
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +1 -1
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +1 -1
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +1 -1
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +1 -1
- package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/EnumExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/IReadonlyListExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/IReadonlyListExtensionTests.cs.meta +1 -1
- package/Tests/Runtime/Extensions/LoggingExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs +1 -1
- package/Tests/Runtime/Extensions/StringExtensionTests.cs +1 -1
- package/Tests/Runtime/Helper/ObjectHelperTests.cs +1 -1
- package/Tests/Runtime/Helper/WallMathTests.cs +1 -1
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +1 -2
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +1 -1
- package/Tests/Runtime/Random/RandomTestBase.cs +2 -2
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +1 -1
- package/Tests/Runtime/Utils/BuffersTests.cs +55 -0
- package/Tests/Runtime/Utils/BuffersTests.cs.meta +3 -0
- package/package.json +3 -1
|
@@ -38,7 +38,9 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
38
38
|
public void FlushData()
|
|
39
39
|
{
|
|
40
40
|
for (int i = 0; i < 5; i++)
|
|
41
|
+
{
|
|
41
42
|
ShiftLow();
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
public void FlushStream()
|
|
@@ -84,7 +86,10 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
84
86
|
{
|
|
85
87
|
Range >>= 1;
|
|
86
88
|
if (((v >> i) & 1) == 1)
|
|
89
|
+
{
|
|
87
90
|
Low += Range;
|
|
91
|
+
}
|
|
92
|
+
|
|
88
93
|
if (Range < kTopValue)
|
|
89
94
|
{
|
|
90
95
|
Range <<= 8;
|
|
@@ -97,7 +102,9 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
97
102
|
{
|
|
98
103
|
uint newBound = (Range >> numTotalBits) * size0;
|
|
99
104
|
if (symbol == 0)
|
|
105
|
+
{
|
|
100
106
|
Range = newBound;
|
|
107
|
+
}
|
|
101
108
|
else
|
|
102
109
|
{
|
|
103
110
|
Low += newBound;
|
|
@@ -134,7 +141,9 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
134
141
|
Code = 0;
|
|
135
142
|
Range = 0xFFFFFFFF;
|
|
136
143
|
for (int i = 0; i < 5; i++)
|
|
144
|
+
{
|
|
137
145
|
Code = (Code << 8) | (byte)Stream.ReadByte();
|
|
146
|
+
}
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
public void ReleaseStream()
|
|
@@ -20,9 +20,13 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
20
20
|
public void UpdateModel(uint symbol)
|
|
21
21
|
{
|
|
22
22
|
if (symbol == 0)
|
|
23
|
+
{
|
|
23
24
|
Prob += (kBitModelTotal - Prob) >> kNumMoveBits;
|
|
25
|
+
}
|
|
24
26
|
else
|
|
27
|
+
{
|
|
25
28
|
Prob -= (Prob) >> kNumMoveBits;
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
public void Encode(Encoder encoder, uint symbol)
|
|
@@ -48,7 +52,9 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
private static UInt32[] ProbPrices = new UInt32[
|
|
55
|
+
private static readonly UInt32[] ProbPrices = new UInt32[
|
|
56
|
+
kBitModelTotal >> kNumMoveReducingBits
|
|
57
|
+
];
|
|
52
58
|
|
|
53
59
|
static BitEncoder()
|
|
54
60
|
{
|
|
@@ -58,9 +64,11 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
58
64
|
UInt32 start = (UInt32)1 << (kNumBits - i - 1);
|
|
59
65
|
UInt32 end = (UInt32)1 << (kNumBits - i);
|
|
60
66
|
for (UInt32 j = start; j < end; j++)
|
|
67
|
+
{
|
|
61
68
|
ProbPrices[j] =
|
|
62
69
|
((UInt32)i << kNumBitPriceShiftBits)
|
|
63
70
|
+ (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1));
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -94,9 +102,13 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
94
102
|
public void UpdateModel(int numMoveBits, uint symbol)
|
|
95
103
|
{
|
|
96
104
|
if (symbol == 0)
|
|
105
|
+
{
|
|
97
106
|
Prob += (kBitModelTotal - Prob) >> numMoveBits;
|
|
107
|
+
}
|
|
98
108
|
else
|
|
109
|
+
{
|
|
99
110
|
Prob -= (Prob) >> numMoveBits;
|
|
111
|
+
}
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
public void Init()
|
|
@@ -4,8 +4,8 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
4
4
|
{
|
|
5
5
|
struct BitTreeEncoder
|
|
6
6
|
{
|
|
7
|
-
BitEncoder[] Models;
|
|
8
|
-
int NumBitLevels;
|
|
7
|
+
readonly BitEncoder[] Models;
|
|
8
|
+
readonly int NumBitLevels;
|
|
9
9
|
|
|
10
10
|
public BitTreeEncoder(int numBitLevels)
|
|
11
11
|
{
|
|
@@ -16,7 +16,9 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
16
16
|
public void Init()
|
|
17
17
|
{
|
|
18
18
|
for (uint i = 1; i < (1 << NumBitLevels); i++)
|
|
19
|
+
{
|
|
19
20
|
Models[i].Init();
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
public void Encode(Encoder rangeEncoder, UInt32 symbol)
|
|
@@ -111,8 +113,8 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
111
113
|
|
|
112
114
|
struct BitTreeDecoder
|
|
113
115
|
{
|
|
114
|
-
BitDecoder[] Models;
|
|
115
|
-
int NumBitLevels;
|
|
116
|
+
readonly BitDecoder[] Models;
|
|
117
|
+
readonly int NumBitLevels;
|
|
116
118
|
|
|
117
119
|
public BitTreeDecoder(int numBitLevels)
|
|
118
120
|
{
|
|
@@ -123,14 +125,19 @@ namespace SevenZip.Compression.RangeCoder
|
|
|
123
125
|
public void Init()
|
|
124
126
|
{
|
|
125
127
|
for (uint i = 1; i < (1 << NumBitLevels); i++)
|
|
128
|
+
{
|
|
126
129
|
Models[i].Init();
|
|
130
|
+
}
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
public uint Decode(RangeCoder.Decoder rangeDecoder)
|
|
130
134
|
{
|
|
131
135
|
uint m = 1;
|
|
132
136
|
for (int bitIndex = NumBitLevels; bitIndex > 0; bitIndex--)
|
|
137
|
+
{
|
|
133
138
|
m = (m << 1) + Models[m].Decode(rangeDecoder);
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
return m - ((uint)1 << NumBitLevels);
|
|
135
142
|
}
|
|
136
143
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Tests.Core.Threading
|
|
2
|
+
{
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using NUnit.Framework;
|
|
6
|
+
using UnityEngine.TestTools;
|
|
7
|
+
using WallstopStudios.UnityHelpers.Core.Threading;
|
|
8
|
+
|
|
9
|
+
public sealed class SingleThreadedThreadPoolTests
|
|
10
|
+
{
|
|
11
|
+
[Test]
|
|
12
|
+
public void Disposal()
|
|
13
|
+
{
|
|
14
|
+
using SingleThreadedThreadPool threadPool = new();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[UnityTest]
|
|
18
|
+
public IEnumerator StuffHappening()
|
|
19
|
+
{
|
|
20
|
+
bool thingHappened = false;
|
|
21
|
+
using SingleThreadedThreadPool threadPool = new();
|
|
22
|
+
for (int i = 0; i < 100; ++i)
|
|
23
|
+
{
|
|
24
|
+
thingHappened = false;
|
|
25
|
+
threadPool.Enqueue(() => thingHappened = true);
|
|
26
|
+
while (!thingHappened)
|
|
27
|
+
{
|
|
28
|
+
yield return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[UnityTest]
|
|
34
|
+
public IEnumerator Ordering()
|
|
35
|
+
{
|
|
36
|
+
List<int> received = new();
|
|
37
|
+
using SingleThreadedThreadPool threadPool = new();
|
|
38
|
+
for (int i = 0; i < 100; ++i)
|
|
39
|
+
{
|
|
40
|
+
int localValue = i;
|
|
41
|
+
threadPool.Enqueue(() => received.Add(localValue));
|
|
42
|
+
}
|
|
43
|
+
while (received.Count < 100)
|
|
44
|
+
{
|
|
45
|
+
yield return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (int i = 0; i < 100; ++i)
|
|
49
|
+
{
|
|
50
|
+
Assert.AreEqual(i, received[i]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class BalancedKDTreeTests : SpatialTreeTests<KDTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -3,8 +3,8 @@ namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
|
3
3
|
using System;
|
|
4
4
|
using System.Collections.Generic;
|
|
5
5
|
using System.Linq;
|
|
6
|
-
using Core.DataStructure;
|
|
7
6
|
using NUnit.Framework;
|
|
7
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
8
8
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
9
9
|
|
|
10
10
|
public sealed class CyclicBufferTests
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class QuadTreeTests : SpatialTreeTests<QuadTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -2,8 +2,8 @@ namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
4
|
using System.Linq;
|
|
5
|
-
using Core.DataStructure;
|
|
6
5
|
using NUnit.Framework;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
7
7
|
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
8
8
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
9
9
|
using Vector2 = UnityEngine.Vector2;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class UnbalancedKDTreeTests : SpatialTreeTests<KDTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -2,8 +2,8 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
4
|
using System.Linq;
|
|
5
|
-
using Core.Extension;
|
|
6
5
|
using NUnit.Framework;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
7
7
|
|
|
8
8
|
public sealed class DictionaryExtensionTests
|
|
9
9
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
2
2
|
{
|
|
3
|
-
using Core.Extension;
|
|
4
3
|
using NUnit.Framework;
|
|
5
4
|
using UnityEngine.TestTools.Constraints;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
6
6
|
using Is = NUnit.Framework.Is;
|
|
7
7
|
|
|
8
8
|
public sealed class EnumExtensionTests
|
|
@@ -3,8 +3,8 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
3
3
|
using System;
|
|
4
4
|
using System.Collections.Generic;
|
|
5
5
|
using System.Linq;
|
|
6
|
-
using Core.Extension;
|
|
7
6
|
using NUnit.Framework;
|
|
7
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
8
8
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
9
9
|
|
|
10
10
|
public sealed class IListExtensionTests
|
|
@@ -3,9 +3,9 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
3
3
|
using System;
|
|
4
4
|
using System.Collections.Generic;
|
|
5
5
|
using System.Linq;
|
|
6
|
-
using Core.Extension;
|
|
7
6
|
using NUnit.Framework;
|
|
8
7
|
using UnityEngine;
|
|
8
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
9
9
|
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
10
10
|
using WallstopStudios.UnityHelpers.Core.Helper.Logging;
|
|
11
11
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.Extension;
|
|
5
4
|
using NUnit.Framework;
|
|
6
5
|
using UnityEngine;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
7
7
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
8
8
|
|
|
9
9
|
public sealed class RandomExtensionTests
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Helper
|
|
2
2
|
{
|
|
3
3
|
using System.Collections;
|
|
4
|
-
using Core.Helper;
|
|
5
4
|
using JetBrains.Annotations;
|
|
6
5
|
using NUnit.Framework;
|
|
7
6
|
using UnityEngine;
|
|
8
7
|
using UnityEngine.TestTools;
|
|
8
|
+
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
9
9
|
|
|
10
10
|
[UsedImplicitly]
|
|
11
11
|
public sealed class ObjectHelperComponent : MonoBehaviour { }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Helper
|
|
2
2
|
{
|
|
3
|
-
using Core.Extension;
|
|
4
3
|
using NUnit.Framework;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
6
6
|
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
7
7
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class KDTreePerformanceTests : SpatialTreePerformanceTest<KDTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class QuadTreePerformanceTests : SpatialTreePerformanceTest<QuadTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -4,12 +4,11 @@ namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
|
4
4
|
using System.Collections;
|
|
5
5
|
using System.Collections.Generic;
|
|
6
6
|
using System.Diagnostics;
|
|
7
|
-
using System.Linq;
|
|
8
7
|
using System.Threading.Tasks;
|
|
9
|
-
using Core.DataStructure;
|
|
10
8
|
using NUnit.Framework;
|
|
11
9
|
using UnityEngine;
|
|
12
10
|
using UnityEngine.TestTools;
|
|
11
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
13
12
|
|
|
14
13
|
public abstract class SpatialTreePerformanceTest<TTree>
|
|
15
14
|
where TTree : ISpatialTree<Vector2>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
2
2
|
{
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
-
using Core.DataStructure;
|
|
5
4
|
using UnityEngine;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
6
6
|
|
|
7
7
|
public sealed class UnbalancedKDTreeTests : SpatialTreePerformanceTest<KDTree<Vector2>>
|
|
8
8
|
{
|
|
@@ -4,9 +4,9 @@ namespace WallstopStudios.UnityHelpers.Tests.Random
|
|
|
4
4
|
using System.Collections.Generic;
|
|
5
5
|
using System.Linq;
|
|
6
6
|
using System.Runtime.CompilerServices;
|
|
7
|
-
using Core.DataStructure.Adapters;
|
|
8
|
-
using Core.Extension;
|
|
9
7
|
using NUnit.Framework;
|
|
8
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure.Adapters;
|
|
9
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
10
10
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
11
11
|
using WallstopStudios.UnityHelpers.Core.Serialization;
|
|
12
12
|
|
|
@@ -5,9 +5,9 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
5
5
|
using System.Linq;
|
|
6
6
|
using System.Runtime.Serialization;
|
|
7
7
|
using System.Text.Json.Serialization;
|
|
8
|
-
using Core.Extension;
|
|
9
8
|
using NUnit.Framework;
|
|
10
9
|
using UnityEngine;
|
|
10
|
+
using WallstopStudios.UnityHelpers.Core.Extension;
|
|
11
11
|
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
12
12
|
using WallstopStudios.UnityHelpers.Core.Random;
|
|
13
13
|
using WallstopStudios.UnityHelpers.Core.Serialization;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Tests.Utils
|
|
2
|
+
{
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using NUnit.Framework;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.Random;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Utils;
|
|
7
|
+
|
|
8
|
+
public sealed class BuffersTests
|
|
9
|
+
{
|
|
10
|
+
[Test]
|
|
11
|
+
public void GenericPoolListTests()
|
|
12
|
+
{
|
|
13
|
+
{
|
|
14
|
+
using PooledResource<List<int>> firstList = WallstopGenericPool<List<int>>.Get();
|
|
15
|
+
using PooledResource<List<int>> secondList = WallstopGenericPool<List<int>>.Get();
|
|
16
|
+
Assert.AreNotEqual(firstList, secondList);
|
|
17
|
+
firstList.resource.Add(1);
|
|
18
|
+
Assert.AreEqual(1, firstList.resource.Count);
|
|
19
|
+
Assert.AreEqual(0, secondList.resource.Count);
|
|
20
|
+
secondList.resource.Add(2);
|
|
21
|
+
Assert.AreEqual(1, firstList.resource.Count);
|
|
22
|
+
Assert.AreEqual(1, secondList.resource.Count);
|
|
23
|
+
}
|
|
24
|
+
{
|
|
25
|
+
// Ensure cleared
|
|
26
|
+
using PooledResource<List<int>> firstList = WallstopGenericPool<List<int>>.Get();
|
|
27
|
+
Assert.AreEqual(0, firstList.resource.Count);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[Test]
|
|
32
|
+
public void ArrayPoolSizeTests()
|
|
33
|
+
{
|
|
34
|
+
for (int i = 0; i < 100; ++i)
|
|
35
|
+
{
|
|
36
|
+
using PooledResource<int[]> resource = WallstopArrayPool<int>.Get(i);
|
|
37
|
+
Assert.AreEqual(i, resource.resource.Length);
|
|
38
|
+
for (int j = 0; j < i; ++j)
|
|
39
|
+
{
|
|
40
|
+
resource.resource[j] = PRNG.Instance.Next();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (int i = 0; i < 100; ++i)
|
|
45
|
+
{
|
|
46
|
+
using PooledResource<int[]> resource = WallstopArrayPool<int>.Get(i);
|
|
47
|
+
Assert.AreEqual(i, resource.resource.Length);
|
|
48
|
+
for (int j = 0; j < i; ++j)
|
|
49
|
+
{
|
|
50
|
+
Assert.AreEqual(0, resource.resource[j]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
package/package.json
CHANGED