Skip to content

Commit

Permalink
Name についてテストケースに追加
Browse files Browse the repository at this point in the history
  • Loading branch information
f-maeda-V committed Aug 6, 2020
1 parent c065863 commit 3f5e78a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Assets/VRM/UniVRM/Editor/Tests/VRMBlendShapeKeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ public class VRMBlendShapeKeyTest
{
static BlendShapeKey CreateBlendShapeKey(string name, BlendShapePreset preset)
{
var argTypes = new Type[] { typeof(string), typeof(BlendShapePreset) };
var argTypes = new Type[] {typeof(string), typeof(BlendShapePreset)};
// private constructor
var constructor = typeof(BlendShapeKey).GetConstructor(
BindingFlags.Instance | BindingFlags.NonPublic,
null, argTypes, null);
return (BlendShapeKey)constructor.Invoke(new object[] { name, preset });
return (BlendShapeKey) constructor.Invoke(new object[] {name, preset});
}

[Test]
public void KeyTest()
{
var key = CreateBlendShapeKey("Blink", BlendShapePreset.Blink);
Assert.AreEqual(key, CreateBlendShapeKey("Blink", BlendShapePreset.Blink));
var key = BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink);
Assert.AreEqual(key, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink));
Assert.AreEqual(key, CreateBlendShapeKey("Blink", BlendShapePreset.Blink));
Assert.AreEqual(key, CreateBlendShapeKey("xxx", BlendShapePreset.Blink));
Assert.AreEqual(key.Name, "Blink");

var dict = new Dictionary<BlendShapeKey, float>();
dict[key] = 1.0f;
Expand All @@ -35,17 +36,23 @@ public void KeyTest()

dict.Clear();

var key2 = BlendShapeKey.CreateUnknown("Blink"); // name: Blink, Preset: Unknown
var key2 = BlendShapeKey.CreateUnknown("Blink"); // Name: Blink, Preset: Unknown
dict[key2] = 1.0f;

Assert.AreEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Unknown));
Assert.AreNotEqual(key2, BlendShapeKey.CreateUnknown("blink"));
Assert.AreNotEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Blink));
Assert.AreNotEqual(key2, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink));
Assert.AreEqual(key2.Name, "Blink");

Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateUnknown("blink")));
Assert.IsFalse(dict.ContainsKey(CreateBlendShapeKey("Blink", BlendShapePreset.Blink)));
Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink)));

var key3 = CreateBlendShapeKey("xxx", BlendShapePreset.Blink); // Unknown 以外は独自の名前を持てない
Assert.AreEqual(key3, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink));
Assert.AreNotEqual(key3, CreateBlendShapeKey("xxx", BlendShapePreset.Unknown));
Assert.AreEqual(key3.Name, "Blink");
}
}
}

0 comments on commit 3f5e78a

Please sign in to comment.