* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Fix new dotnet-format issues after rebase * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * cpu tests: Disable CA2211 for CodeBaseAddress and DataBaseAddress * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * First dotnet format pass * Fix naming rule violations * Remove naming rule violation exceptions * Fix comment style * Use targeted new * Remove redundant code * Remove comment alignment * Remove naming rule exceptions * Add trailing commas * Use nameof expression * Reformat to add remaining trailing commas --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using NUnit.Framework;
|
||
using Ryujinx.HLE.HOS.Applets;
|
||
using System.Text;
|
||
|
||
namespace Ryujinx.Tests.HLE
|
||
{
|
||
public class SoftwareKeyboardTests
|
||
{
|
||
[Test]
|
||
public void StripUnicodeControlCodes_NullInput()
|
||
{
|
||
Assert.IsNull(SoftwareKeyboardApplet.StripUnicodeControlCodes(null));
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_EmptyInput()
|
||
{
|
||
Assert.AreEqual(string.Empty, SoftwareKeyboardApplet.StripUnicodeControlCodes(string.Empty));
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_Passthrough()
|
||
{
|
||
string[] prompts = {
|
||
"Please name him.",
|
||
"Name her, too.",
|
||
"Name your friend.",
|
||
"Name another friend.",
|
||
"Name your pet.",
|
||
"Favorite homemade food?",
|
||
"What’s your favorite thing?",
|
||
"Are you sure?",
|
||
};
|
||
|
||
foreach (string prompt in prompts)
|
||
{
|
||
Assert.AreEqual(prompt, SoftwareKeyboardApplet.StripUnicodeControlCodes(prompt));
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_StripsNewlines()
|
||
{
|
||
Assert.AreEqual("I am very tall", SoftwareKeyboardApplet.StripUnicodeControlCodes("I \r\nam \r\nvery \r\ntall"));
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_StripsDeviceControls()
|
||
{
|
||
// 0x13 is control code DC3 used by some games
|
||
string specialInput = Encoding.UTF8.GetString(new byte[] { 0x13, 0x53, 0x68, 0x69, 0x6E, 0x65, 0x13 });
|
||
Assert.AreEqual("Shine", SoftwareKeyboardApplet.StripUnicodeControlCodes(specialInput));
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_StripsToEmptyString()
|
||
{
|
||
string specialInput = Encoding.UTF8.GetString(new byte[] { 17, 18, 19, 20 }); // DC1 - DC4 special codes
|
||
Assert.AreEqual(string.Empty, SoftwareKeyboardApplet.StripUnicodeControlCodes(specialInput));
|
||
}
|
||
|
||
[Test]
|
||
public void StripUnicodeControlCodes_PreservesMultiCodePoints()
|
||
{
|
||
// Turtles are a good example of multi-codepoint Unicode chars
|
||
string specialInput = "♀ 🐢 🐢 ♂ ";
|
||
Assert.AreEqual(specialInput, SoftwareKeyboardApplet.StripUnicodeControlCodes(specialInput));
|
||
}
|
||
}
|
||
}
|