Fixes some potential memory leaks in unit tests, cleanup
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2b6b3a40ed
commit
4588b2da10
|
@ -7,6 +7,12 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<WarningLevel>6</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors>;NU1605;CA2000</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="libpkmn_lib.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace PkmnLibSharp.Utils
|
|||
}
|
||||
}
|
||||
|
||||
internal IntPtr TakeOwnership()
|
||||
private IntPtr TakeOwnership()
|
||||
{
|
||||
if (!_isOwner)
|
||||
{
|
||||
|
@ -67,17 +67,12 @@ namespace PkmnLibSharp.Utils
|
|||
return ptr;
|
||||
}
|
||||
|
||||
internal void Invalidate()
|
||||
private void Invalidate()
|
||||
{
|
||||
_isInvalidated = true;
|
||||
CacheHandler.RemoveCache(_ptr);
|
||||
}
|
||||
|
||||
~ExternPointer()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors>;NU1605;CA2000</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
|
|
|
@ -9,9 +9,10 @@ namespace PkmnLibRSharpTests.StaticData
|
|||
[Test]
|
||||
public void BasicTests()
|
||||
{
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) },
|
||||
new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0), new[] { "foo", "bar" }, new[] { "set" },
|
||||
new LearnableMoves(), Array.Empty<string>());
|
||||
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
||||
using var moves = new LearnableMoves();
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
||||
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
||||
Assert.AreEqual("foobar", form.Name);
|
||||
Assert.AreEqual(0.2f, form.Height, 0.00001f);
|
||||
Assert.AreEqual(5.8f, form.Weight, 0.00001f);
|
||||
|
@ -22,7 +23,6 @@ namespace PkmnLibRSharpTests.StaticData
|
|||
Assert.AreEqual("foo", form.Abilities[0]);
|
||||
Assert.AreEqual("bar", form.Abilities[1]);
|
||||
Assert.AreEqual("set", form.HiddenAbilities[0]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,9 +19,10 @@ namespace PkmnLibRSharpTests.StaticData.Libraries
|
|||
{
|
||||
using var lib = new SpeciesLibrary(0);
|
||||
Assert.AreEqual(0, lib.Length);
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) },
|
||||
new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0), new[] { "foo", "bar" }, new[] { "set" },
|
||||
new LearnableMoves(), Array.Empty<string>());
|
||||
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
||||
using var moves = new LearnableMoves();
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
||||
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
||||
using var species = new Species(10, "testSpecies", 0.2f, "growth", 120, form, Array.Empty<string>());
|
||||
lib.Add("foobar", species);
|
||||
Assert.AreEqual(1, lib.Length);
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace PkmnLibRSharpTests.StaticData
|
|||
[Values] Statistic decreasedStat
|
||||
)
|
||||
{
|
||||
var nature = new Nature(increasedStat, decreasedStat);
|
||||
using var nature = new Nature(increasedStat, decreasedStat);
|
||||
Assert.AreEqual(increasedStat, nature.IncreasedStat);
|
||||
Assert.AreEqual(decreasedStat, nature.DecreasedStat);
|
||||
if (increasedStat == decreasedStat)
|
||||
|
|
|
@ -9,9 +9,10 @@ namespace PkmnLibRSharpTests.StaticData
|
|||
[Test]
|
||||
public void BasicTests()
|
||||
{
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) },
|
||||
new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0), new[] { "foo", "bar" }, new[] { "set" },
|
||||
new LearnableMoves(), Array.Empty<string>());
|
||||
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
||||
using var moves = new LearnableMoves();
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
||||
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
||||
using var species = new Species(10, "testSpecies", 0.2f, "growth", 120, form, Array.Empty<string>());
|
||||
Assert.AreEqual(10, species.Id);
|
||||
Assert.AreEqual("testSpecies", species.Name);
|
||||
|
|
Loading…
Reference in New Issue