-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from mbbsemu/debug-fixes
Debug & Crash Report Fixes
- Loading branch information
Showing
7 changed files
with
111 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Xunit; | ||
using MBBSEmu.Extensions; | ||
using System; | ||
|
||
namespace MBBSEmu.Tests.Extensions | ||
{ | ||
/// <summary> | ||
/// Unit Tests for MBBSEmu's Extension Class for ReadOnlySpan | ||
/// </summary> | ||
public class ReadOnlySpanExtensionsTests | ||
{ | ||
[Fact] | ||
public void ToCharSpanTest() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 65, 66, 67 }; | ||
ReadOnlySpan<char> expected = new char[] { 'A', 'B', 'C' }; | ||
var result = input.ToCharSpan(); | ||
Assert.Equal(expected.ToArray(), result.ToArray()); | ||
} | ||
|
||
[Fact] | ||
public void ContainsOnlyTest() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 1, 1, 1 }; | ||
var result = input.ContainsOnly(1); | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public void ContainsOnlyTest_False() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 1, 2, 1 }; | ||
var result = input.ContainsOnly(1); | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void ToHexStringTest() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 1, 2, 3, 4, 5 }; | ||
var result = input.ToHexString(0, 5); | ||
|
||
Assert.Contains("5 bytes, 0x0000 -> 0x0005", result); | ||
Assert.Contains("0000 [ 01 02 03 04 05", result); | ||
Assert.DoesNotContain("No Data to Display", result); | ||
Assert.DoesNotContain("Invalid Address Range", result); | ||
} | ||
|
||
[Fact] | ||
public void ToHexStringTest_ZeroLength() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 1, 2, 3, 4, 5 }; | ||
var result = input.ToHexString(0, 0); | ||
Assert.Contains("No Data to Display", result); | ||
} | ||
|
||
[Fact] | ||
public void ToHexStringTest_InvalidLength() | ||
{ | ||
ReadOnlySpan<byte> input = new byte[] { 1, 2, 3, 4, 5 }; | ||
var result = input.ToHexString(0, 6); | ||
Assert.Contains("Invalid Address Range", result); | ||
} | ||
} | ||
} |
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
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