-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLibraryAcceptRateTest.cs
75 lines (65 loc) · 1.69 KB
/
LibraryAcceptRateTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.IO;
using System.Linq;
using MaiLib;
using SimaiSharp;
namespace Sitreamai;
internal static class LibraryAcceptRateTest
{
private static int total = 0;
private static int maiLib = 0;
private static int simaiSharp = 0;
public static void Test()
{
TestDir(@"E:\Desktop\dist");
Console.WriteLine($"MaiLib: {maiLib}/{total}\nSimaiSharp: {simaiSharp}/{total}");
}
private static void TestDir(string dir)
{
foreach (var file in Directory.EnumerateFiles(dir, "*.txt"))
{
TestFile(file);
}
foreach (var subDir in Directory.EnumerateDirectories(dir))
{
TestDir(subDir);
}
}
private static void TestFile(string file)
{
total++;
var content = File.ReadAllText(file);
try
{
content = SimaiConvert.Serialize(SimaiConvert.Deserialize(content));
}
catch
{
}
// Test MaiLib
try
{
var parser = new SimaiParser();
var candidate = parser.ChartOfToken(TokensFromText(content));
// var converted = new Ma2(candidate) { ChartVersion = ChartEnum.ChartVersion.Ma2_104 };
// converted.Compose();
maiLib++;
}
catch
{
}
// Test SimaiSharp
try
{
// SimaiConvert.Deserialize(content);
// simaiSharp++;
}
catch
{
}
}
private static string[] TokensFromText(string text)
{
return new string(text.ToCharArray().Where((Func<char, bool>)(c => !char.IsWhiteSpace(c))).ToArray()).Split(',');
}
}