57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using UnityEngine;
|
|
using UnityEngine.TestTools;
|
|
using Newtonsoft.Json;
|
|
using System.Reflection;
|
|
using System.IO;
|
|
using BITKit.IO;
|
|
using System.Text;
|
|
namespace BITKit
|
|
{
|
|
public class ObjectMatcherTest
|
|
{
|
|
[Test]
|
|
public void TestObjectMatcher()
|
|
{
|
|
ObjectMatcher<string, string> matcher = new();
|
|
matcher.list = new ObjectElement<string, string>[]
|
|
{
|
|
new("xyz","x","y","z"),
|
|
new("XYZ","X","Y","Z"),
|
|
new("123","1","2","3"),
|
|
new("BulletHit","Hitbox","Blood"),
|
|
};
|
|
string[][] useCases = new string[][]{
|
|
new string[]{
|
|
"x","y","z"
|
|
},
|
|
new string[]{
|
|
"w","y","x","z"
|
|
},
|
|
new string[]{
|
|
"X","y","Z"
|
|
},
|
|
new string[]{
|
|
"3","1","2"
|
|
},
|
|
new string[]{
|
|
"1","5","7"
|
|
},
|
|
new string[]
|
|
{
|
|
"BulletHit","Hitbox","Blood"
|
|
}
|
|
};
|
|
StringBuilder stringBuilder = new();
|
|
foreach (var useCase in useCases)
|
|
{
|
|
stringBuilder.AppendLine($"当前用例:{JsonConvert.SerializeObject(useCase)}");
|
|
stringBuilder.AppendLine($"当前返回:{matcher.TryMatch(out string value, useCase)} @{value}");
|
|
}
|
|
Debug.Log(stringBuilder);
|
|
}
|
|
}
|
|
} |