-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing time packing returning negative values
- Loading branch information
1 parent
47cff9c
commit 3ad84f2
Showing
3 changed files
with
42 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Mirage.Serialization; | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
|
||
namespace JamesFrowen.PositionSync.Tests | ||
{ | ||
[Category("NetworkPositionSync")] | ||
public class TimeSyncTest : MonoBehaviour | ||
{ | ||
[Test] | ||
public void TimeSerialzesCorrectly([NUnit.Framework.Range(0, 3600 * 24 * 30, 1000)] double time) | ||
{ | ||
var settings = new SyncSettings(); | ||
var writer = new NetworkWriter(1200); | ||
|
||
var packer = settings.CreateTimePacker(); | ||
|
||
packer.Pack(writer, time); | ||
|
||
var reader = new NetworkReader(); | ||
reader.Reset(writer.ToArraySegment()); | ||
|
||
var outTime = packer.Unpack(reader); | ||
|
||
// setting should be sending 0.1ms, so should be within that | ||
Assert.That(outTime, Is.EqualTo(time).Within(1 / 10000f)); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/NetworkPositionSync/Tests/Runtime/TimeSyncTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.