-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in data encoder where MSB of 128 and 0 value bytes was errone…
…ously being flipped
- Loading branch information
1 parent
6676c84
commit bdb8ce4
Showing
3 changed files
with
48 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using EOLib.Domain.Interact.Quest; | ||
using EOLib.IO.Services; | ||
using EOLib.Net; | ||
using EOLib.Net.PacketProcessing; | ||
using NUnit.Framework; | ||
|
||
namespace EOLib.IO.Test.Services | ||
{ | ||
[TestFixture] | ||
public class PacketEncoderServiceTest | ||
{ | ||
[Test] | ||
public void PacketEncoderService_Encode_127Byte_DoesNotProduceAny0ValueBytes() | ||
{ | ||
var svc = new PacketEncoderService(new NumberEncoderService(), new DataEncoderService()); | ||
|
||
var packet = new PacketBuilder(PacketFamily.Quest, PacketAction.Accept) | ||
.AddShort(0) | ||
.AddShort(0) | ||
.AddShort(111) | ||
.AddShort(127) | ||
.AddChar((byte)DialogReply.Link) | ||
.AddChar(1) | ||
.Build(); | ||
|
||
var encoded = svc.Encode(packet, 5); | ||
|
||
Assert.That(encoded, Has.All.Not.EqualTo(0)); | ||
} | ||
|
||
[Test] | ||
public void PacketEncoderService_Encode_0Byte_DoesNotProduceAny128ValueBytes() | ||
{ | ||
var svc = new PacketEncoderService(new NumberEncoderService(), new DataEncoderService()); | ||
|
||
var packet = new PacketBuilder(PacketFamily.Quest, PacketAction.Accept) | ||
.AddByte(0) | ||
.Build(); | ||
|
||
var encoded = svc.Encode(packet, 5); | ||
|
||
Assert.That(encoded, Has.All.Not.EqualTo(128)); | ||
} | ||
} | ||
} |