discord-bot/Tests/RegexTest.cs
Ilya 72dbc4074a
Some performance and code optimizations (#955)
* upgrade deps, remove wrong ppu hashes

* upgrade compiler packages

will require container pull after build

* replace Regex with compiler-generated versions

* use new collection initialization syntax

* configure global defaults for regex

* bump min amd driver version

fixes #950

* add macos version check

fixes #948

* fix #954 (!sudo log date)
2024-05-18 14:26:34 +01:00

28 lines
1.2 KiB
C#

using System.Text.RegularExpressions;
using NUnit.Framework;
using CompatBot.Utils;
namespace Tests;
[TestFixture]
public partial class RegexTest
{
[GeneratedRegex(@"Rap file not found: (\xE2\x80\x9C)?(?<rap_file>.*?)(\xE2\x80\x9D)?\r?$", RegexOptions.Multiline | RegexOptions.ExplicitCapture)]
private static partial Regex RapFileMissingLogLine();
[Test]
public void Utf8AsAsciiRegexTest()
{
const string input = """
·W 0:09:45.540824 {PPU[0x1000016] Thread (addContSyncThread) [HLE:0x01245834, LR:0x0019b834]} sceNp: npDrmIsAvailable(): Rap file not found: /dev_hdd0/home/00000001/exdata/EP4062-NPEB02436_00-ADDCONTENT000001.rap
·W 0:09:45.540866 {PPU[0x1000016] Thread (addContSyncThread) [HLE:0x01245834, LR:0x0019b834]} sceNp: sceNpDrmIsAvailable2(k_licensee=*0xd521b0, drm_path=*0xd00ddac0)
""";
var latin = input.ToLatin8BitEncoding();
var match = RapFileMissingLogLine().Match(latin);
Assert.Multiple(() =>
{
Assert.That(match.Success, Is.True);
Assert.That(match.Groups["rap_file"].Value, Is.EqualTo("/dev_hdd0/home/00000001/exdata/EP4062-NPEB02436_00-ADDCONTENT000001.rap"));
});
}
}