Skip to content

Commit

Permalink
Big-endian test case fixes: BinaryWriter (#49688)
Browse files Browse the repository at this point in the history
* Fix endian assumption in BinaryWriter_WriteSpan
  (BinaryWriter always uses little-endian byte order)
  • Loading branch information
uweigand authored Mar 16, 2021
1 parent 3982863 commit 6866357
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,13 @@ public void BinaryWriter_WriteSpan()

char testChar;

testChar = BitConverter.ToChar(new byte[] { (byte)baseStream.ReadByte(), (byte)baseStream.ReadByte() }, 0);
testChar = (char)((ushort)baseStream.ReadByte() + ((ushort)baseStream.ReadByte() << 8));
Assert.Equal('a', testChar);

testChar = BitConverter.ToChar(new byte[] { (byte)baseStream.ReadByte(), (byte)baseStream.ReadByte() }, 0);
testChar = (char)((ushort)baseStream.ReadByte() + ((ushort)baseStream.ReadByte() << 8));
Assert.Equal('7', testChar);

testChar = BitConverter.ToChar(new byte[] { (byte)baseStream.ReadByte(), (byte)baseStream.ReadByte() }, 0);
testChar = (char)((ushort)baseStream.ReadByte() + ((ushort)baseStream.ReadByte() << 8));
Assert.Equal(char.MaxValue, testChar);
}
}
Expand Down

0 comments on commit 6866357

Please sign in to comment.