-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding option for unsigned floats in floatpacker
- Loading branch information
1 parent
273c14e
commit dda61e1
Showing
6 changed files
with
136 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Assets/Tests/Runtime/Serialization/Packers/unsignedFloatPackerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Mirage.Serialization; | ||
using NUnit.Framework; | ||
|
||
namespace Mirage.Tests.Runtime.Serialization.Packers | ||
{ | ||
public class UnsignedFloatPackerTests : PackerTestBase | ||
{ | ||
FloatPacker packer; | ||
float max; | ||
float precsion; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
max = 100; | ||
precsion = 1 / 1000f; | ||
packer = new FloatPacker(max, precsion, false); | ||
} | ||
|
||
[Test] | ||
public void ClampsToZero() | ||
{ | ||
packer.Pack(writer, -4.5f); | ||
float outValue = packer.Unpack(GetReader()); | ||
|
||
Assert.That(outValue, Is.Zero); | ||
} | ||
|
||
[Test] | ||
public void CanWriteNearMax() | ||
{ | ||
const float value = 99.5f; | ||
packer.Pack(writer, value); | ||
float outValue = packer.Unpack(GetReader()); | ||
|
||
Assert.That(outValue, Is.EqualTo(value).Within(precsion)); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Tests/Runtime/Serialization/Packers/unsignedFloatPackerTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.