Added Unity project files
This commit is contained in:
@ -0,0 +1,194 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
public class DataDictionaryTests
|
||||
{
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() { { "key1", "value1" }, { "key2", "value2" } };
|
||||
Assert.AreEqual("value1", dictionary["key1"]);
|
||||
Assert.AreEqual("value2", dictionary["key2"]);
|
||||
Assert.AreEqual(2, dictionary.Count);
|
||||
Assert.AreEqual(2, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(2, dictionary.GetValues().Count);
|
||||
dictionary.Add("key3", "value3");
|
||||
Assert.AreEqual("value3", dictionary["key3"]);
|
||||
Assert.AreEqual(3, dictionary.Count);
|
||||
Assert.AreEqual(3, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(3, dictionary.GetValues().Count);
|
||||
dictionary.Add(new KeyValuePair<DataToken, DataToken>("key4", "value4"));
|
||||
Assert.AreEqual("value4", dictionary["key4"]);
|
||||
Assert.AreEqual(4, dictionary.Count);
|
||||
Assert.AreEqual(4, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(4, dictionary.GetValues().Count);
|
||||
}
|
||||
[Test]
|
||||
public void TestTryGetValue()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"};
|
||||
Assert.IsTrue(dictionary.TryGetValue("a", out DataToken value));
|
||||
Assert.AreEqual("a", value);
|
||||
Assert.IsTrue(dictionary.TryGetValue("a", TokenType.String, out value));
|
||||
Assert.AreEqual("a", value);
|
||||
|
||||
Assert.IsFalse(dictionary.TryGetValue("x", out value));
|
||||
Assert.AreEqual(DataError.KeyDoesNotExist, value);
|
||||
Assert.IsFalse(dictionary.TryGetValue("a", TokenType.Boolean, out value));
|
||||
Assert.AreEqual(DataError.TypeMismatch, value);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary();
|
||||
Assert.AreEqual(0, dictionary.Count, "initialized new empty list");
|
||||
dictionary.SetValue("a", "a");
|
||||
Assert.AreEqual(1, dictionary.Count, "added one entry");
|
||||
dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"};
|
||||
Assert.AreEqual(3, dictionary.Count, "initialized new list with 3 entries");
|
||||
dictionary.Remove("c");
|
||||
Assert.AreEqual(2, dictionary.Count, "removed one entry");
|
||||
dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c", ["d"]="d", ["e"]="e", ["f"] = "f", ["g"]=new DataDictionary(), ["h"] = "h"};
|
||||
Assert.AreEqual(8, dictionary.Count, "initialized new list with 8 entries");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"};
|
||||
Assert.AreEqual(3, dictionary.Count);
|
||||
dictionary.Clear();
|
||||
Assert.AreEqual(0, dictionary.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetKeys()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"};
|
||||
Assert.IsTrue(CompareList(dictionary.GetKeys(), new DataList("a", "b", "c")));
|
||||
dictionary.SetValue("d", "d");
|
||||
Assert.IsTrue(dictionary.GetKeys().Contains("d"));
|
||||
dictionary.Remove("d");
|
||||
Assert.IsFalse(dictionary.GetKeys().Contains("d"));
|
||||
dictionary.Clear();
|
||||
Assert.IsFalse(dictionary.GetKeys().Contains("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetValues()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"};
|
||||
Assert.IsTrue(CompareList(dictionary.GetValues(), new DataList("a", "b", "c")));
|
||||
dictionary.SetValue("d", "d");
|
||||
Assert.IsTrue(dictionary.GetValues().Contains("d"));
|
||||
dictionary.Remove("d");
|
||||
Assert.IsFalse(dictionary.GetValues().Contains("d"));
|
||||
dictionary.Clear();
|
||||
Assert.IsFalse(dictionary.GetValues().Contains("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemove()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="x", ["b"]="y", ["c"]="z"};
|
||||
Assert.IsTrue(dictionary.Remove("b"));
|
||||
Assert.IsFalse(dictionary.ContainsKey("b"));
|
||||
Assert.IsFalse(dictionary.Remove("f"));
|
||||
|
||||
Assert.IsTrue(dictionary.Remove("c", out DataToken value));
|
||||
Assert.AreEqual(value, "z");
|
||||
Assert.IsFalse(dictionary.Remove("c", out value));
|
||||
Assert.AreEqual(value, DataError.KeyDoesNotExist);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsKey()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="x", ["b"]="y", ["c"]="z"};
|
||||
Assert.IsTrue(dictionary.ContainsKey("b"));
|
||||
dictionary.Remove("b");
|
||||
Assert.IsFalse(dictionary.ContainsKey("b"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsValue()
|
||||
{
|
||||
DataDictionary dictionary = new DataDictionary() {["a"]="x", ["b"]="y", ["c"]="z"};
|
||||
Assert.IsTrue(dictionary.ContainsValue("y"));
|
||||
dictionary.Remove("b");
|
||||
Assert.IsFalse(dictionary.ContainsValue("y"));
|
||||
}
|
||||
|
||||
|
||||
private bool CompareList(DataList a, DataList b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i].TokenType == TokenType.DataList)
|
||||
{
|
||||
if (b[i].TokenType != TokenType.DataList) return false;
|
||||
if (!CompareList(a[i].DataList, b[i].DataList)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDictionaryEquality()
|
||||
{
|
||||
// Make sure DataDicts act the same way as a C# dictionary in terms of equality
|
||||
void TestDictEqualityToCSharpDict<T>(T _a, T _b)
|
||||
{
|
||||
// Test same keys same values
|
||||
DataDictionary aDataDictionary = new DataDictionary();
|
||||
aDataDictionary[new DataToken(_a)] = "blah";
|
||||
DataDictionary bDataDictionary = new DataDictionary();
|
||||
bDataDictionary[new DataToken(_b)] = "blah";
|
||||
|
||||
Dictionary<T, string> aCSharpDict = new Dictionary<T, string>();
|
||||
aCSharpDict[_a] = "blah";
|
||||
Dictionary<T, string> bCSharpDict = new Dictionary<T, string>();
|
||||
bCSharpDict[_b] = "blah";
|
||||
|
||||
Assert.AreEqual(aDataDictionary == bDataDictionary, aCSharpDict == bCSharpDict);
|
||||
Assert.AreEqual(aDataDictionary.Equals(bDataDictionary), aCSharpDict.Equals(bCSharpDict));
|
||||
|
||||
// Test same keys different values
|
||||
aDataDictionary[new DataToken(_a)] = "not blah";
|
||||
bDataDictionary[new DataToken(_b)] = "blah";
|
||||
aCSharpDict[_a] = "not blah";
|
||||
bCSharpDict[_b] = "blah";
|
||||
|
||||
Assert.AreEqual(aDataDictionary == bDataDictionary, aCSharpDict == bCSharpDict);
|
||||
Assert.AreEqual(aDataDictionary.Equals(bDataDictionary), aCSharpDict.Equals(bCSharpDict));
|
||||
}
|
||||
|
||||
TestDictEqualityToCSharpDict(true, true);
|
||||
TestDictEqualityToCSharpDict((sbyte)5, (sbyte)5);
|
||||
TestDictEqualityToCSharpDict((byte)5, (byte)5);
|
||||
TestDictEqualityToCSharpDict((short)5, (short)5);
|
||||
TestDictEqualityToCSharpDict((ushort)5, (ushort)5);
|
||||
TestDictEqualityToCSharpDict((int)5, (int)5);
|
||||
TestDictEqualityToCSharpDict((uint)5, (uint)5);
|
||||
TestDictEqualityToCSharpDict((long)5, (long)5);
|
||||
TestDictEqualityToCSharpDict((ulong)5, (ulong)5);
|
||||
TestDictEqualityToCSharpDict((float)5, (float)5);
|
||||
TestDictEqualityToCSharpDict((double)5, (double)5);
|
||||
TestDictEqualityToCSharpDict("abc", "abc");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0f0e9c6659d5434399d69c33611db57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,388 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
public class DataListTests
|
||||
{
|
||||
[Test]
|
||||
public void TestTryGetValue()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
Assert.IsTrue(list.TryGetValue(1, out DataToken value));
|
||||
Assert.AreEqual("b", value);
|
||||
Assert.IsTrue(list.TryGetValue(2, TokenType.String, out value));
|
||||
Assert.AreEqual("c", value);
|
||||
|
||||
Assert.IsFalse(list.TryGetValue(-1, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(3, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(-1, TokenType.String, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(3, TokenType.String, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(0, TokenType.Boolean, out value));
|
||||
Assert.AreEqual(DataError.TypeMismatch, value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
DataList test = new DataList();
|
||||
Assert.AreEqual(0, test.Count, "initialized new empty list");
|
||||
test.Add("a");
|
||||
Assert.AreEqual(1, test.Count, "added one entry");
|
||||
test = new DataList("a", "b", "c");
|
||||
Assert.AreEqual(3, test.Count, "initialized new list with 3 entries");
|
||||
test.Remove("c");
|
||||
Assert.AreEqual(2, test.Count, "removed one entry");
|
||||
test = new DataList("a", "b", "c", "d", "e", "f", new DataDictionary(), "h");
|
||||
Assert.AreEqual(8, test.Count, "initialized new list with 8 entries");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsert()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
list.Insert(0, "inserted1");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "b", "c")));
|
||||
list.Insert(3, "inserted2");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "b", "inserted2", "c")));
|
||||
list.Insert(2, "inserted3");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "inserted3", "b", "inserted2", "c")));
|
||||
list.Insert(6, "inserted4");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "inserted3", "b", "inserted2", "c", "inserted4")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsertRange()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
list.InsertRange(0, new DataList("inserted1", "inserted2"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "a", "b", "c")));
|
||||
list.InsertRange(5, new DataList("inserted3", "inserted4"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "a", "b", "c", "inserted3", "inserted4")));
|
||||
list.InsertRange(2, new DataList("inserted5", "inserted6"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "inserted5", "inserted6", "a", "b", "c", "inserted3", "inserted4")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTryGetRange()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c", "d", "e", "f");
|
||||
DataList output = list.GetRange(0, 3);
|
||||
Assert.IsTrue(CompareList(output, new DataList("a", "b", "c")), "get half from start");
|
||||
output = list.GetRange(3, 3);
|
||||
Assert.IsTrue(CompareList(output, new DataList("d", "e", "f")), "get half from end");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShallowClone()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
DataList clone = list.ShallowClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
|
||||
list = new DataList("a", "b", new DataList(1, 2, 3, 4));
|
||||
clone = list.ShallowClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
clone.Add("c");
|
||||
Assert.IsFalse(CompareList(clone, list), "adding an item to the shallow cloned list affected the source list");
|
||||
|
||||
clone = list.ShallowClone();
|
||||
clone[0] = 5;
|
||||
Assert.IsFalse(CompareList(clone, list), "modifying a value in the shallow cloned list affected the source list");
|
||||
list[2].DataList.Add(5);
|
||||
Assert.IsTrue(clone[2].DataList.Contains(5), "modifying a child of the shallow cloned list did not affect the source list");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeepClone()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
DataList clone = list.DeepClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
|
||||
list = new DataList("a", "b", new DataList(1, 2, 3, 4));
|
||||
clone = list.DeepClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
clone.Add("c");
|
||||
Assert.IsFalse(CompareList(clone, list), "adding an item to the deep cloned list affected the source list");
|
||||
|
||||
clone = list.DeepClone();
|
||||
clone[0] = 5;
|
||||
Assert.IsFalse(CompareList(clone, list), "modifying a value in the deep cloned list affected the source list");
|
||||
list[2].DataList.Add(5);
|
||||
Assert.IsFalse(clone[2].DataList.Contains(5), "modifying a child of the deep cloned list affected the source list");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestToArray()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
DataToken[] tokens = list.ToArray();
|
||||
Assert.IsTrue(CompareListToArray(list, tokens), "list did not match array");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
DataList list = new DataList();
|
||||
list.Add("a");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a")));
|
||||
list.Add("b");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b")));
|
||||
list.Add("c");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddRange()
|
||||
{
|
||||
DataList list = new DataList();
|
||||
list.AddRange(new DataList("a", "b"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b")));
|
||||
list.AddRange(new DataList("c", "d"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "d")));
|
||||
list.AddRange(new DataList("e", "f"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "d", "e", "f")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContains()
|
||||
{
|
||||
Assert.IsTrue(new DataList("a").Contains("a"));
|
||||
Assert.IsTrue(new DataList("a", "b", "c").Contains("c"));
|
||||
Assert.IsTrue(new DataList("a","b", "c", "a", "b", "c").Contains("c"));
|
||||
Assert.IsFalse(new DataList("a", "b", "c").Contains("d"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIndexOf()
|
||||
{
|
||||
DataList list = new DataList() { "a", "b", "c", "a", "b", "c"};
|
||||
//Should be valid
|
||||
Assert.AreEqual(0, list.IndexOf("a"), "value exists, should succeed");
|
||||
Assert.AreEqual(3, list.IndexOf("a", 2), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(3, list.IndexOf("a", 1, 5), "count at last entry, should succeed");
|
||||
Assert.AreEqual(5, list.IndexOf("c", 5), "start index at last entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-1, list.IndexOf("f"), "value does not exist, should fail");
|
||||
}
|
||||
[Test]
|
||||
public void TestLastIndexOf()
|
||||
{
|
||||
DataList list = new DataList() { "a", "b", "c", "a", "b", "c"};
|
||||
//Should be valid
|
||||
Assert.AreEqual(3, list.LastIndexOf("a"), "value exists, should succeed");
|
||||
Assert.AreEqual(2, list.LastIndexOf("c", 2), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(3, list.LastIndexOf("a", 5, 3), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(0, list.LastIndexOf("a", 2, 3), "count at first entry, should succeed");
|
||||
Assert.AreEqual(0, list.LastIndexOf("a", 0), "start index at first entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-1, list.LastIndexOf("f"), "value does not exist, should fail");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemove()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
Assert.IsTrue(list.Remove("b"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "c")));
|
||||
list = new DataList("a", "b", "c", "a", "b", "c");
|
||||
Assert.IsTrue(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "a", "b", "c")));
|
||||
Assert.IsTrue(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "b", "c")));
|
||||
|
||||
Assert.IsFalse(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveAt()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
list.RemoveAt(0);
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c")));
|
||||
list.RemoveAt(1);
|
||||
Assert.IsTrue(CompareList(list, new DataList("b")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveRange()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c", "a", "b", "c");
|
||||
list.RemoveRange(0, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "a", "b", "c")));
|
||||
list.RemoveRange(3, 1);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "a", "b")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c");
|
||||
list.Clear();
|
||||
Assert.IsTrue(CompareList(list, new DataList()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReverse()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c", "a", "b", "c");
|
||||
list.Reverse();
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "c", "b", "a")));
|
||||
list.Reverse();
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReverseRange()
|
||||
{
|
||||
DataList list = new DataList("a", "b", "c", "a", "b", "c");
|
||||
list.Reverse(0, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "a", "b", "c")));
|
||||
list.Reverse(3, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "c", "b", "a")));
|
||||
list.Reverse(0, 6);
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSort()
|
||||
{
|
||||
DataList list = new DataList(5, 4, 7, 2, 1);
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(1, 2, 4, 5, 7)));
|
||||
|
||||
list = new DataList((double)8.5f, (float)5.3f, (long)-999999, (ulong)9999999, -53, (uint)9, (short)-32, (ushort)8, (byte)5, (sbyte)6);
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList((long)-999999, -53, (short)-32, (byte)5, (float)5.3f, (sbyte)6, (ushort)8, (double)8.5f, (uint)9, (ulong)9999999)));
|
||||
|
||||
list = new DataList(new DataList("a", "b", "c"), new DataList("a", "b"));
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(new DataList("a", "b"), new DataList("a", "b", "c"))));
|
||||
|
||||
list = new DataList(4, true, new DataToken(),new DataList("a"), "string");
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(new DataToken(), true, 4, "string", new DataList("a"))));
|
||||
}
|
||||
[Test]
|
||||
public void TestSortRange()
|
||||
{
|
||||
DataList list = new DataList(5, 4, 7, 2, 1);
|
||||
list.Sort(0, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList(4, 5, 7, 2, 1)));
|
||||
|
||||
list = new DataList((double)8.5f, (float)5.3f, (long)-999999, (ulong)9999999, -53, (uint)9, (short)-32, (ushort)8, (byte)5, (sbyte)6);
|
||||
list.Sort(0, 8);
|
||||
Assert.IsTrue(CompareList(list, new DataList((long)-999999, -53, (short)-32, (float)5.3f, (ushort)8, (double)8.5f, (uint)9, (ulong)9999999,(byte)5, (sbyte)6)));
|
||||
|
||||
list = new DataList(new DataList("a", "b", "c"), new DataList("a", "b", "c", "d"), new DataList("a", "b"));
|
||||
list.Sort(1, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList( new DataList("a", "b", "c"), new DataList("a", "b"),new DataList("a", "b", "c", "d"))));
|
||||
|
||||
list = new DataList(4, true, new DataToken(),new DataList("a"), "string");
|
||||
list.Sort(1, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList(4, new DataToken(),true,new DataList("a"), "string")));
|
||||
}
|
||||
[Test]
|
||||
public void TestBinarySearch()
|
||||
{
|
||||
DataList list = new DataList() {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
|
||||
//Should be valid
|
||||
Assert.AreEqual(1, list.BinarySearch(10), "value exists, should succeed");
|
||||
Assert.AreEqual(-7, list.BinarySearch(55));
|
||||
Assert.AreEqual(4, list.BinarySearch(2, 5, 40), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(7, list.BinarySearch(5, 6, 70), "count at last entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-12, list.BinarySearch("f"), "value does not exist, should fail");
|
||||
}
|
||||
|
||||
private bool CompareList(DataList a, DataList b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i].TokenType == TokenType.DataList)
|
||||
{
|
||||
if (b[i].TokenType != TokenType.DataList) return false;
|
||||
if (!CompareList(a[i].DataList, b[i].DataList)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private bool CompareListToArray(DataList a, DataToken[] b)
|
||||
{
|
||||
if (a.Count != b.Length) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestListEquality()
|
||||
{
|
||||
// Make sure DataList act the same way as a C# List<> in terms of equality
|
||||
void TestDictEqualityToCSharpList<T>(T _a, T _b)
|
||||
{
|
||||
// Test same keys same values
|
||||
|
||||
DataList aDataList = new DataList();
|
||||
aDataList.Add(new DataToken(_a));
|
||||
DataList bDataList = new DataList();
|
||||
bDataList.Add(new DataToken(_b));
|
||||
|
||||
List<T> aCSharpList = new List<T>();
|
||||
aCSharpList.Add(_a);
|
||||
List<T> bCSharpList = new List<T>();
|
||||
bCSharpList.Add(_b);
|
||||
|
||||
Assert.AreEqual(aDataList == bDataList, aCSharpList == bCSharpList);
|
||||
Assert.AreEqual(aDataList.Equals(bDataList), aCSharpList.Equals(bCSharpList));
|
||||
}
|
||||
|
||||
// Same values
|
||||
TestDictEqualityToCSharpList(true, true);
|
||||
TestDictEqualityToCSharpList((sbyte)5, (sbyte)5);
|
||||
TestDictEqualityToCSharpList((byte)5, (byte)5);
|
||||
TestDictEqualityToCSharpList((short)5, (short)5);
|
||||
TestDictEqualityToCSharpList((ushort)5, (ushort)5);
|
||||
TestDictEqualityToCSharpList((int)5, (int)5);
|
||||
TestDictEqualityToCSharpList((uint)5, (uint)5);
|
||||
TestDictEqualityToCSharpList((long)5, (long)5);
|
||||
TestDictEqualityToCSharpList((ulong)5, (ulong)5);
|
||||
TestDictEqualityToCSharpList((float)5, (float)5);
|
||||
TestDictEqualityToCSharpList((double)5, (double)5);
|
||||
TestDictEqualityToCSharpList("abc", "abc");
|
||||
|
||||
// Different values
|
||||
TestDictEqualityToCSharpList(true, false);
|
||||
TestDictEqualityToCSharpList((sbyte)5, (sbyte)6);
|
||||
TestDictEqualityToCSharpList((byte)5, (byte)6);
|
||||
TestDictEqualityToCSharpList((short)5, (short)6);
|
||||
TestDictEqualityToCSharpList((ushort)5, (ushort)6);
|
||||
TestDictEqualityToCSharpList((int)5, (int)6);
|
||||
TestDictEqualityToCSharpList((uint)5, (uint)6);
|
||||
TestDictEqualityToCSharpList((long)5, (long)6);
|
||||
TestDictEqualityToCSharpList((ulong)5, (ulong)6);
|
||||
TestDictEqualityToCSharpList((float)5, (float)6);
|
||||
TestDictEqualityToCSharpList((double)5, (double)6);
|
||||
TestDictEqualityToCSharpList("abc", "def");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17ace30fb4afe624387090408df4e98d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
using VRC.SDKBase;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
public class DataTokenTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void TestIsNull()
|
||||
{
|
||||
Assert.IsTrue(new DataToken().IsNull);
|
||||
Assert.IsFalse(new DataToken((byte)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((sbyte)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((short)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((ushort)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((int)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((uint)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((long)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((ulong)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((float)5).IsNull);
|
||||
Assert.IsFalse(new DataToken((double)5).IsNull);
|
||||
Assert.IsFalse(new DataToken(true).IsNull);
|
||||
Assert.IsFalse(new DataToken("string").IsNull);
|
||||
string nullstring = null;
|
||||
Assert.IsTrue(new DataToken(nullstring).IsNull);
|
||||
Assert.IsFalse(new DataToken(new DataList(){"4", "5"}).IsNull);
|
||||
Assert.IsFalse(new DataToken(new DataDictionary(){["key"]="value"}).IsNull);
|
||||
Assert.IsFalse(new DataToken(new bool[] {false, true, false}).IsNull);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmpty()
|
||||
{
|
||||
SetAndGet("empty", new DataToken());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBool()
|
||||
{
|
||||
SetAndGet("bool true", new DataToken(true));
|
||||
SetAndGet("bool false", new DataToken(false));
|
||||
}
|
||||
[Test]
|
||||
public void TestByte()
|
||||
{
|
||||
SetAndGet("byte number", (byte)4);
|
||||
SetAndGet("max byte number", byte.MaxValue);
|
||||
SetAndGet("min byte number", byte.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestSByte()
|
||||
{
|
||||
SetAndGet("sbyte number", (sbyte)4);
|
||||
SetAndGet("max sbyte number", sbyte.MaxValue);
|
||||
SetAndGet("min sbyte number", sbyte.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestShort()
|
||||
{
|
||||
SetAndGet("short number", (short)4);
|
||||
SetAndGet("max short number", short.MaxValue);
|
||||
SetAndGet("min short number", short.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestUShort()
|
||||
{
|
||||
SetAndGet("ushort number", (ushort)4);
|
||||
SetAndGet("max ushort number", ushort.MaxValue);
|
||||
SetAndGet("min ushort number", ushort.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestInt()
|
||||
{
|
||||
SetAndGet("int number", (int)4);
|
||||
SetAndGet("max int number", int.MaxValue);
|
||||
SetAndGet("min int number", int.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestUInt()
|
||||
{
|
||||
SetAndGet("uint number", (uint)4);
|
||||
SetAndGet("max uint number", uint.MaxValue);
|
||||
SetAndGet("min uint number", uint.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestLong()
|
||||
{
|
||||
SetAndGet("long number", (long)4);
|
||||
SetAndGet("max long number", long.MaxValue);
|
||||
SetAndGet("min long number", long.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestULong()
|
||||
{
|
||||
SetAndGet("ulong number", (ulong)4);
|
||||
SetAndGet("max ulong number", ulong.MaxValue);
|
||||
SetAndGet("min ulong number", ulong.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestFloat()
|
||||
{
|
||||
SetAndGet("float number", 0.123f);
|
||||
SetAndGet("max float number", float.MaxValue);
|
||||
SetAndGet("large float number", float.MinValue);
|
||||
SetAndGet("epsilon float number", float.Epsilon);
|
||||
SetAndGet("Negative Infinity float number", float.NegativeInfinity);
|
||||
SetAndGet("Positive Infinity float number", float.PositiveInfinity);
|
||||
SetAndGet("NaN float number", float.NaN);
|
||||
SetAndGet("Epsilon float number", float.Epsilon);
|
||||
}
|
||||
[Test]
|
||||
public void TestDouble()
|
||||
{
|
||||
SetAndGet("double number", 0.12341233);
|
||||
SetAndGet("max double number", double.MaxValue);
|
||||
SetAndGet("min double number", double.MinValue);
|
||||
SetAndGet("Negative Infinity double number", double.NegativeInfinity);
|
||||
SetAndGet("Positive Infinity double number", double.PositiveInfinity);
|
||||
SetAndGet("NaN double number", double.NaN);
|
||||
SetAndGet("Epsilon double number", double.Epsilon);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestString()
|
||||
{
|
||||
SetAndGet("backspace", new DataToken("\b"));
|
||||
SetAndGet("form feed", new DataToken("\f"));
|
||||
SetAndGet("newline", new DataToken("\n"));
|
||||
SetAndGet("carriage return", new DataToken("\r"));
|
||||
SetAndGet("tab", new DataToken("\t"));
|
||||
SetAndGet("quotes", new DataToken("\""));
|
||||
SetAndGet("victory hand", new DataToken("✌"));
|
||||
SetAndGet("mandarin", new DataToken("䉟"));
|
||||
SetAndGet("greater than", new DataToken(">"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReference()
|
||||
{
|
||||
SetAndGet("bool array reference", new DataToken(new bool[] {false, true, false}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBitcast()
|
||||
{
|
||||
// test value requires 5 bytes, larger than an int at 4
|
||||
var token = new DataToken(0x12_3456_7890UL);
|
||||
Assert.AreEqual(0x12_3456_7890UL, token.ULong);
|
||||
Assert.AreEqual(TokenType.ULong, token.TokenType);
|
||||
|
||||
// test that normal cast fails
|
||||
Assert.Throws<InvalidOperationException>(() => _ = token.Long);
|
||||
|
||||
// test that bitcast works
|
||||
var bitlong = token.Bitcast(TokenType.Long);
|
||||
Assert.AreEqual(0x12_3456_7890L, bitlong.Long);
|
||||
Assert.AreEqual(TokenType.Long, bitlong.TokenType);
|
||||
|
||||
// truncate the original long
|
||||
var bitint = token.Bitcast(TokenType.Int);
|
||||
Assert.AreEqual(0x3456_7890, bitint.Int);
|
||||
Assert.AreEqual(TokenType.Int, bitint.TokenType);
|
||||
// back to ulong and it should have been zero-extended
|
||||
var bitint_aslong = bitint.Bitcast(TokenType.ULong);
|
||||
Assert.AreEqual(0x3456_7890UL, bitint_aslong.ULong);
|
||||
Assert.AreEqual(TokenType.ULong, bitint_aslong.TokenType);
|
||||
// as byte it will be truncated further
|
||||
var bitint_asbyte = bitint.Bitcast(TokenType.Byte);
|
||||
Assert.AreEqual(0x90, bitint_asbyte.Byte);
|
||||
Assert.AreEqual(TokenType.Byte, bitint_asbyte.TokenType);
|
||||
// converting back from byte will once again zero-extend, the 0x12345678 has been lost, only 0x90 remains
|
||||
var bitint_back = bitint_asbyte.Bitcast(TokenType.Int);
|
||||
Assert.AreEqual(0x90, bitint_back.Int);
|
||||
Assert.AreEqual(TokenType.Int, bitint_back.TokenType);
|
||||
|
||||
// test that bitcasting to types where the bitpattern might be invalid still preserves it
|
||||
var bitdouble = token.Bitcast(TokenType.Double);
|
||||
Assert.AreNotEqual(1.0f, bitdouble.Double);
|
||||
Assert.AreEqual(TokenType.Double, bitdouble.TokenType);
|
||||
var bitdouble_back = bitdouble.Bitcast(TokenType.ULong);
|
||||
Assert.AreEqual(0x12_3456_7890UL, bitdouble_back.ULong);
|
||||
Assert.AreEqual(TokenType.ULong, bitdouble_back.TokenType);
|
||||
|
||||
// test that bitcast fails on incompatible types
|
||||
Assert.Throws<InvalidOperationException>(() => _ = token.Bitcast(TokenType.String));
|
||||
var stringtoken = new DataToken("hello");
|
||||
Assert.Throws<InvalidOperationException>(() => _ = stringtoken.Bitcast(TokenType.Float));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEquality()
|
||||
{
|
||||
void TestEqualityOfDifferentTokensWithSameValue<T>(T _a, T _b)
|
||||
{
|
||||
DataToken a = new DataToken(_a);
|
||||
DataToken b = new DataToken(_b);
|
||||
if (_a == null && _b == null)
|
||||
{
|
||||
// DataTokens both referring to null are expected to be equal
|
||||
Assert.IsTrue(a == b);
|
||||
}
|
||||
else if (typeof(T) == typeof(string))
|
||||
{
|
||||
// Strings are special and their == operator does NOT check if the references are exactly the same, rather it checks the characters
|
||||
Assert.IsTrue(a == b);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(a == b);
|
||||
}
|
||||
Assert.IsTrue(a.Equals(b));
|
||||
}
|
||||
|
||||
TestEqualityOfDifferentTokensWithSameValue(true, true);
|
||||
TestEqualityOfDifferentTokensWithSameValue((sbyte)5, (sbyte)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((byte)5, (byte)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((short)5, (short)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((ushort)5, (ushort)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((int)5, (int)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((uint)5, (uint)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((long)5, (long)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((ulong)5, (ulong)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((float)5, (float)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue((double)5, (double)5);
|
||||
TestEqualityOfDifferentTokensWithSameValue("abc", "abc");
|
||||
TestEqualityOfDifferentTokensWithSameValue<object>(null, null);
|
||||
TestEqualityOfDifferentTokensWithSameValue(new Vector3Int(1, 2, 3), new Vector3Int(1, 2, 3));
|
||||
|
||||
void TestEqualityOfDifferentTokensWithDifferentValues<T>(T _a, T _b)
|
||||
{
|
||||
DataToken a = new DataToken(_a);
|
||||
DataToken b = new DataToken(_b);
|
||||
Assert.IsFalse(a == b);
|
||||
Assert.IsFalse(a.Equals(b));
|
||||
}
|
||||
|
||||
TestEqualityOfDifferentTokensWithDifferentValues(true, false);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((sbyte)5, (sbyte)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((byte)5, (byte)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((short)5, (short)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((ushort)5, (ushort)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((int)5, (int)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((uint)5, (uint)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((long)5, (long)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((ulong)5, (ulong)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((float)5, (float)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues((double)5, (double)6);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues("abc", "def");
|
||||
TestEqualityOfDifferentTokensWithDifferentValues("abc", null);
|
||||
TestEqualityOfDifferentTokensWithDifferentValues(new Vector3Int(1, 2, 3), new Vector3Int(4, 5, 6));
|
||||
|
||||
// Make sure types do not implicitly cast
|
||||
Assert.IsFalse(new DataToken((sbyte)5).Equals(new DataToken((byte)5)));
|
||||
Assert.IsFalse(new DataToken((short)5).Equals(new DataToken((ushort)5)));
|
||||
Assert.IsFalse(new DataToken((int)5).Equals(new DataToken((uint)5)));
|
||||
Assert.IsFalse(new DataToken((long)5).Equals(new DataToken((ulong)5)));
|
||||
Assert.IsFalse(new DataToken((float)5).Equals(new DataToken((double)5)));
|
||||
|
||||
Assert.IsFalse(new DataToken((sbyte)5) == new DataToken((byte)5));
|
||||
Assert.IsFalse(new DataToken((short)5) == new DataToken((ushort)5));
|
||||
Assert.IsFalse(new DataToken((int)5) == new DataToken((uint)5));
|
||||
Assert.IsFalse(new DataToken((long)5) == new DataToken((ulong)5));
|
||||
Assert.IsFalse(new DataToken((float)5) == new DataToken((double)5));
|
||||
}
|
||||
|
||||
private void SetAndGet(string title, DataToken inToken)
|
||||
{
|
||||
SetAndGetDictionary(title, inToken);
|
||||
SetAndGetList(title, inToken);
|
||||
}
|
||||
private void SetAndGetDictionary(string title, DataToken inToken)
|
||||
{
|
||||
DataDictionary dataDictionary = new DataDictionary();
|
||||
dataDictionary.SetValue("key", inToken);
|
||||
Assert.IsTrue(dataDictionary.TryGetValue("key", out DataToken outToken), $"{title} Failed to get value with error {outToken}");
|
||||
Assert.AreEqual(inToken, outToken, $"{title} Input and output tokens were not the same");
|
||||
}
|
||||
private void SetAndGetList(string title, DataToken inToken)
|
||||
{
|
||||
DataList dataList = new DataList();
|
||||
dataList.Add(inToken);
|
||||
Assert.IsTrue(dataList.TryGetValue(0, out DataToken outToken), $"{title} Failed to get value with error {outToken}");
|
||||
Assert.AreEqual(inToken, outToken, $"{title} Input and output tokens were not the same");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4da3a4e08f2d1d541831ff4bb3a21a03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,48 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine.Networking;
|
||||
using VRC.Udon.Editor;
|
||||
using VRC.Udon.Editor.ProgramSources.UdonGraphProgram.UI;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
|
||||
public class GraphNodeTests
|
||||
{
|
||||
[Test]
|
||||
public void CheckHelpURLsForSystemNodes()
|
||||
{
|
||||
var systemRegistry = UdonEditorManager.Instance
|
||||
.GetTopRegistries()
|
||||
.First(r=>r.Key.Equals("System"))
|
||||
.Value;
|
||||
|
||||
foreach (var keyValuePair in systemRegistry)
|
||||
{
|
||||
var registry = keyValuePair.Value;
|
||||
var definitions = registry.GetNodeDefinitions();
|
||||
foreach (var definition in definitions)
|
||||
{
|
||||
// Skip some links which we hide away
|
||||
if (!UdonGraphExtensions.ShouldShowDocumentationLink(definition)) continue;
|
||||
|
||||
var link = UdonGraphExtensions.GetDocumentationLink(definition);
|
||||
Assert.IsTrue(CheckUrlResolves(link), $"URL does not resolve for {definition.fullName}: {link}");
|
||||
}
|
||||
}
|
||||
Assert.Pass("All Systems UdonNodeDefinitions have valid links!");
|
||||
}
|
||||
|
||||
private bool CheckUrlResolves(string url)
|
||||
{
|
||||
using (UnityWebRequest request = UnityWebRequest.Head(url))
|
||||
{
|
||||
var operation = request.SendWebRequest();
|
||||
while (!operation.isDone) { }
|
||||
|
||||
return request.result == UnityWebRequest.Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb94112fbe7c1c64eae97fbdec4c766c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,203 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
|
||||
public class JsonDictionaryTests : MonoBehaviour
|
||||
{
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"key1\":\"value1\", \"key2\":\"value2\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.AreEqual("value1", dictionary["key1"]);
|
||||
Assert.AreEqual("value2", dictionary["key2"]);
|
||||
Assert.AreEqual(2, dictionary.Count);
|
||||
Assert.AreEqual(2, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(2, dictionary.GetValues().Count);
|
||||
dictionary.Add("key3", "value3");
|
||||
Assert.AreEqual("value3", dictionary["key3"]);
|
||||
Assert.AreEqual(3, dictionary.Count);
|
||||
Assert.AreEqual(3, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(3, dictionary.GetValues().Count);
|
||||
dictionary.Add(new KeyValuePair<DataToken, DataToken>("key4", "value4"));
|
||||
Assert.AreEqual("value4", dictionary["key4"]);
|
||||
Assert.AreEqual(4, dictionary.Count);
|
||||
Assert.AreEqual(4, dictionary.GetKeys().Count);
|
||||
Assert.AreEqual(4, dictionary.GetValues().Count);
|
||||
}
|
||||
[Test]
|
||||
public void TestTryGetValue()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"a\", \"b\":\"b\", \"c\":\"c\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(dictionary.TryGetValue("a", out DataToken value));
|
||||
Assert.AreEqual("a", value);
|
||||
Assert.IsTrue(dictionary.TryGetValue("a", TokenType.String, out value));
|
||||
Assert.AreEqual("a", value);
|
||||
|
||||
Assert.IsFalse(dictionary.TryGetValue("x", out value));
|
||||
Assert.AreEqual(DataError.KeyDoesNotExist, value);
|
||||
Assert.IsFalse(dictionary.TryGetValue("a", TokenType.Boolean, out value));
|
||||
Assert.AreEqual(DataError.TypeMismatch, value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.AreEqual(0, dictionary.Count, "initialized new empty list");
|
||||
dictionary.SetValue("a", "a");
|
||||
Assert.AreEqual(1, dictionary.Count, "added one entry");
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"a\", \"b\":\"b\", \"c\":\"c\"}", out token));
|
||||
dictionary = token.DataDictionary;
|
||||
Assert.AreEqual(3, dictionary.Count, "initialized new list with 3 entries");
|
||||
dictionary.Remove("c");
|
||||
Assert.AreEqual(2, dictionary.Count, "removed one entry");
|
||||
dictionary = new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c", ["d"]="d", ["e"]="e", ["f"] = "f", ["g"]=new DataDictionary(), ["h"] = "h"};
|
||||
Assert.AreEqual(8, dictionary.Count, "initialized new list with 8 entries");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"a\", \"b\":\"b\", \"c\":\"c\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.AreEqual(3, dictionary.Count);
|
||||
dictionary.Clear();
|
||||
Assert.AreEqual(0, dictionary.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetKeys()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"a\", \"b\":\"b\", \"c\":\"c\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(CompareList(dictionary.GetKeys(), new DataList("a", "b", "c")));
|
||||
dictionary.SetValue("d", "d");
|
||||
Assert.IsTrue(dictionary.GetKeys().Contains("d"));
|
||||
dictionary.Remove("d");
|
||||
Assert.IsFalse(dictionary.GetKeys().Contains("d"));
|
||||
dictionary.Clear();
|
||||
Assert.IsFalse(dictionary.GetKeys().Contains("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetValues()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"a\", \"b\":\"b\", \"c\":\"c\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(CompareList(dictionary.GetValues(), new DataList("a", "b", "c")));
|
||||
dictionary.SetValue("d", "d");
|
||||
Assert.IsTrue(dictionary.GetValues().Contains("d"));
|
||||
dictionary.Remove("d");
|
||||
Assert.IsFalse(dictionary.GetValues().Contains("d"));
|
||||
dictionary.Clear();
|
||||
Assert.IsFalse(dictionary.GetValues().Contains("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemove()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"x\", \"b\":\"y\", \"c\":\"z\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(dictionary.Remove("b"));
|
||||
Assert.IsFalse(dictionary.ContainsKey("b"));
|
||||
Assert.IsFalse(dictionary.Remove("f"));
|
||||
|
||||
Assert.IsTrue(dictionary.Remove("c", out DataToken value));
|
||||
Assert.AreEqual(value, "z");
|
||||
Assert.IsFalse(dictionary.Remove("c", out value));
|
||||
Assert.AreEqual(value, DataError.KeyDoesNotExist);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsKey()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"x\", \"b\":\"y\", \"c\":\"z\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(dictionary.ContainsKey("b"));
|
||||
dictionary.Remove("b");
|
||||
Assert.IsFalse(dictionary.ContainsKey("b"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsValue()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("{\"a\":\"x\", \"b\":\"y\", \"c\":\"z\"}", out DataToken token));
|
||||
DataDictionary dictionary = token.DataDictionary;
|
||||
Assert.IsTrue(dictionary.ContainsValue("y"));
|
||||
dictionary.Remove("b");
|
||||
Assert.IsFalse(dictionary.ContainsValue("y"));
|
||||
}
|
||||
|
||||
|
||||
private bool CompareList(DataList a, DataList b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i].TokenType == TokenType.DataList)
|
||||
{
|
||||
if (b[i].TokenType != TokenType.DataList) return false;
|
||||
if (!CompareList(a[i].DataList, b[i].DataList)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDictionaryEquality()
|
||||
{
|
||||
// Make sure DataDicts act the same way as a C# dictionary in terms of equality
|
||||
void TestDictEqualityToCSharpDict<T>(T _a, T _b)
|
||||
{
|
||||
// Test same keys same values
|
||||
VRCJson.TryDeserializeFromJson("{\"" + _a + "\":\"blah\"}", out DataToken parseResultA);
|
||||
DataDictionary aDataDictionary = parseResultA.DataDictionary;
|
||||
VRCJson.TryDeserializeFromJson("{\"" + _b + "\":\"blah\"}", out DataToken parseResultB);
|
||||
DataDictionary bDataDictionary = parseResultB.DataDictionary;
|
||||
|
||||
Dictionary<T, string> aCSharpDict = new Dictionary<T, string>();
|
||||
aCSharpDict[_a] = "blah";
|
||||
Dictionary<T, string> bCSharpDict = new Dictionary<T, string>();
|
||||
bCSharpDict[_b] = "blah";
|
||||
|
||||
Assert.AreEqual(aDataDictionary == bDataDictionary, aCSharpDict == bCSharpDict);
|
||||
Assert.AreEqual(aDataDictionary.Equals(bDataDictionary), aCSharpDict.Equals(bCSharpDict));
|
||||
|
||||
// Test same keys different values
|
||||
aDataDictionary[new DataToken(_a)] = "not blah";
|
||||
bDataDictionary[new DataToken(_b)] = "blah";
|
||||
aCSharpDict[_a] = "not blah";
|
||||
bCSharpDict[_b] = "blah";
|
||||
|
||||
Assert.AreEqual(aDataDictionary == bDataDictionary, aCSharpDict == bCSharpDict);
|
||||
Assert.AreEqual(aDataDictionary.Equals(bDataDictionary), aCSharpDict.Equals(bCSharpDict));
|
||||
}
|
||||
|
||||
// TestDictEqualityToCSharpDict(true, true);
|
||||
// TestDictEqualityToCSharpDict((sbyte)5, (sbyte)5);
|
||||
// TestDictEqualityToCSharpDict((byte)5, (byte)5);
|
||||
// TestDictEqualityToCSharpDict((short)5, (short)5);
|
||||
// TestDictEqualityToCSharpDict((ushort)5, (ushort)5);
|
||||
// TestDictEqualityToCSharpDict((int)5, (int)5);
|
||||
// TestDictEqualityToCSharpDict((uint)5, (uint)5);
|
||||
// TestDictEqualityToCSharpDict((long)5, (long)5);
|
||||
// TestDictEqualityToCSharpDict((ulong)5, (ulong)5);
|
||||
// TestDictEqualityToCSharpDict((float)5, (float)5);
|
||||
// TestDictEqualityToCSharpDict((double)5, (double)5);
|
||||
TestDictEqualityToCSharpDict("abc", "abc");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aff2e127ee728e643af3f14dd1dd3b3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,435 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
public class JsonListTests : MonoBehaviour
|
||||
{
|
||||
[Test]
|
||||
public void TestTryGetValue()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
Assert.IsTrue(list.TryGetValue(1, out DataToken value));
|
||||
Assert.AreEqual("b", value);
|
||||
Assert.IsTrue(list.TryGetValue(2, TokenType.String, out value));
|
||||
Assert.AreEqual("c", value);
|
||||
|
||||
Assert.IsFalse(list.TryGetValue(-1, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(3, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(-1, TokenType.String, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(3, TokenType.String, out value));
|
||||
Assert.AreEqual(DataError.IndexOutOfRange, value);
|
||||
Assert.IsFalse(list.TryGetValue(0, TokenType.Boolean, out value));
|
||||
Assert.AreEqual(DataError.TypeMismatch, value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
Assert.AreEqual(0, list.Count, "initialized new empty list");
|
||||
list.Add("a");
|
||||
Assert.AreEqual(1, list.Count, "added one entry");
|
||||
list = new DataList("a", "b", "c");
|
||||
Assert.AreEqual(3, list.Count, "initialized new list with 3 entries");
|
||||
list.Remove("c");
|
||||
Assert.AreEqual(2, list.Count, "removed one entry");
|
||||
list = new DataList("a", "b", "c", "d", "e", "f", new DataDictionary(), "h");
|
||||
Assert.AreEqual(8, list.Count, "initialized new list with 8 entries");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsert()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Insert(0, "inserted1");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "b", "c")));
|
||||
list.Insert(3, "inserted2");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "b", "inserted2", "c")));
|
||||
list.Insert(2, "inserted3");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "inserted3", "b", "inserted2", "c")));
|
||||
list.Insert(6, "inserted4");
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "a", "inserted3", "b", "inserted2", "c", "inserted4")));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsertRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.InsertRange(0, new DataList("inserted1", "inserted2"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "a", "b", "c")));
|
||||
list.InsertRange(5, new DataList("inserted3", "inserted4"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "a", "b", "c", "inserted3", "inserted4")));
|
||||
list.InsertRange(2, new DataList("inserted5", "inserted6"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("inserted1", "inserted2", "inserted5", "inserted6", "a", "b", "c", "inserted3", "inserted4")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTryGetRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
DataList output = list.GetRange(0, 3);
|
||||
Assert.IsTrue(CompareList(output, new DataList("a", "b", "c")), "get half from start");
|
||||
output = list.GetRange(3, 3);
|
||||
Assert.IsTrue(CompareList(output, new DataList("d", "e", "f")), "get half from end");
|
||||
|
||||
}
|
||||
[Test]
|
||||
public void TestShallowClone()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
DataList clone = list.ShallowClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", [1, 2, 3, 4]]", out token));
|
||||
list = token.DataList;
|
||||
clone = list.ShallowClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
clone.Add("c");
|
||||
Assert.IsFalse(CompareList(clone, list), "adding an item to the shallow cloned list affected the source list");
|
||||
|
||||
clone = list.ShallowClone();
|
||||
clone[0] = 5;
|
||||
Assert.IsFalse(CompareList(clone, list), "modifying a value in the shallow cloned list affected the source list");
|
||||
list[2].DataList.Add(5);
|
||||
Assert.IsTrue(clone[2].DataList.Contains(5), "modifying a child of the shallow cloned list did not affect the source list");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeepClone()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
DataList clone = list.DeepClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", [1, 2, 3, 4]]", out token));
|
||||
list = token.DataList;
|
||||
clone = list.DeepClone();
|
||||
Assert.IsTrue(CompareList(clone, list), "cloned list did not match source list");
|
||||
clone.Add("c");
|
||||
Assert.IsFalse(CompareList(clone, list), "adding an item to the deep cloned list affected the source list");
|
||||
|
||||
clone = list.DeepClone();
|
||||
clone[0] = 5;
|
||||
Assert.IsFalse(CompareList(clone, list), "modifying a value in the deep cloned list affected the source list");
|
||||
list[2].DataList.Add(5);
|
||||
Assert.IsFalse(clone[2].DataList.Contains(5), "modifying a child of the deep cloned list affected the source list");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestToArray()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
DataToken[] tokens = list.ToArray();
|
||||
Assert.IsTrue(CompareListToArray(list, tokens), "list did not match array");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Add("a");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a")));
|
||||
list.Add("b");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b")));
|
||||
list.Add("c");
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.AddRange(new DataList("a", "b"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b")));
|
||||
list.AddRange(new DataList("c", "d"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "d")));
|
||||
list.AddRange(new DataList("e", "f"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "d", "e", "f")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContains()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
Assert.IsTrue(list.Contains("a"));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out token));
|
||||
list = token.DataList;
|
||||
Assert.IsTrue(list.Contains("c"));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\",\"a\",\"b\",\"c\"]", out token));
|
||||
list = token.DataList;
|
||||
Assert.IsTrue(list.Contains("c"));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out token));
|
||||
list = token.DataList;
|
||||
Assert.IsFalse(list.Contains("d"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIndexOf()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\",\"a\",\"b\",\"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
//Should be valid
|
||||
Assert.AreEqual(0, list.IndexOf("a"), "value exists, should succeed");
|
||||
Assert.AreEqual(3, list.IndexOf("a", 2), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(3, list.IndexOf("a", 1, 5), "count at last entry, should succeed");
|
||||
Assert.AreEqual(5, list.IndexOf("c", 5), "start index at last entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-1, list.IndexOf("f"), "value does not exist, should fail");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastIndexOf()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\",\"b\",\"c\",\"a\",\"b\",\"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
//Should be valid
|
||||
Assert.AreEqual(3, list.LastIndexOf("a"), "value exists, should succeed");
|
||||
Assert.AreEqual(2, list.LastIndexOf("c", 2), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(3, list.LastIndexOf("a", 5, 3), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(0, list.LastIndexOf("a", 2, 3), "count at first entry, should succeed");
|
||||
Assert.AreEqual(0, list.LastIndexOf("a", 0), "start index at first entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-1, list.LastIndexOf("f"), "value does not exist, should fail");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemove()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
Assert.IsTrue(list.Remove("b"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "c")));
|
||||
list = new DataList("a", "b", "c", "a", "b", "c");
|
||||
Assert.IsTrue(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "a", "b", "c")));
|
||||
Assert.IsTrue(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "b", "c")));
|
||||
|
||||
Assert.IsFalse(list.Remove("a"));
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveAt()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.RemoveAt(0);
|
||||
Assert.IsTrue(CompareList(list, new DataList("b", "c")));
|
||||
list.RemoveAt(1);
|
||||
Assert.IsTrue(CompareList(list, new DataList("b")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\",\"b\",\"c\",\"a\",\"b\",\"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.RemoveRange(0, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "a", "b", "c")));
|
||||
list.RemoveRange(3, 1);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "a", "b")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\", \"b\", \"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Clear();
|
||||
Assert.IsTrue(CompareList(list, new DataList()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReverse()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\",\"b\",\"c\",\"a\",\"b\",\"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Reverse();
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "c", "b", "a")));
|
||||
list.Reverse();
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReverseRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[\"a\",\"b\",\"c\",\"a\",\"b\",\"c\"]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Reverse(0, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "a", "b", "c")));
|
||||
list.Reverse(3, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList("c", "b", "a", "c", "b", "a")));
|
||||
list.Reverse(0, 6);
|
||||
Assert.IsTrue(CompareList(list, new DataList("a", "b", "c", "a", "b", "c")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSort()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[5, 4, 7, 2, 1]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(1d, 2d, 4d, 5d, 7d)));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[8.5, 5.3, -999999, 9999999, -53, 9, -32, 8, 5, 6]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(-999999d, -53d, -32d, 5d, 5.3d, 6d, 8d, 8.5d, 9d, 9999999d)));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[[\"a\", \"b\", \"c\"], [\"a\",\"b\"]]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(new DataList("a", "b"), new DataList("a", "b", "c"))));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[4, true, null, [\"a\"], \"string\"]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort();
|
||||
Assert.IsTrue(CompareList(list, new DataList(new DataToken(), true, 4d, "string", new DataList("a"))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSortRange()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[5, 4, 7, 2, 1]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
list.Sort(0, 3);
|
||||
Assert.IsTrue(CompareList(list, new DataList(4d, 5d, 7d, 2d, 1d)));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[8.5, 5.3, -999999, 9999999, -53, 9, -32, 8, 5, 6]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort(0, 8);
|
||||
Assert.IsTrue(CompareList(list, new DataList(-999999d, -53d, -32d, 5.3d, 8d, 8.5d, 9d, 9999999d, 5d, 6d)));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[[\"a\", \"b\", \"c\"], [\"a\",\"b\"], [\"a\", \"b\", \"c\", \"d\"]]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort(1, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList(new DataList("a", "b", "c"), new DataList("a", "b"), new DataList("a", "b", "c", "d"))));
|
||||
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[4, true, null, [\"a\"], \"string\"]", out token));
|
||||
list = token.DataList;
|
||||
list.Sort(1, 2);
|
||||
Assert.IsTrue(CompareList(list, new DataList(4d, new DataToken(), true, new DataList("a"), "string")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBinarySearch()
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson("[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]", out DataToken token));
|
||||
DataList list = token.DataList;
|
||||
//Should be valid
|
||||
Assert.AreEqual(1, list.BinarySearch(10d), "value exists, should succeed");
|
||||
Assert.AreEqual(-7, list.BinarySearch(55d));
|
||||
Assert.AreEqual(4, list.BinarySearch(2, 5, 40d), "value exists inside range, should succeed");
|
||||
Assert.AreEqual(7, list.BinarySearch(5, 6, 70d), "count at last entry, should succeed");
|
||||
//Should be invalid
|
||||
Assert.AreEqual(-12, list.BinarySearch("f"), "value does not exist, should fail");
|
||||
}
|
||||
|
||||
private bool CompareList(DataList a, DataList b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i].TokenType == TokenType.DataList)
|
||||
{
|
||||
if (b[i].TokenType != TokenType.DataList) return false;
|
||||
if (!CompareList(a[i].DataList, b[i].DataList)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CompareListToArray(DataList a, DataToken[] b)
|
||||
{
|
||||
if (a.Count != b.Length) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
{
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestListEquality()
|
||||
{
|
||||
// Make sure DataList act the same way as a C# List<> in terms of equality
|
||||
void TestDictEqualityToCSharpList<T>(T _a, T _b)
|
||||
{
|
||||
// Test same keys same values
|
||||
|
||||
string aStr = _a is string ? $"\"{_a}\"" : _a.ToString();
|
||||
string bStr = _b is string ? $"\"{_b}\"" : _b.ToString();
|
||||
|
||||
VRCJson.TryDeserializeFromJson($"[{aStr}]", out DataToken parseResultA);
|
||||
DataList aDataList = parseResultA.DataList;
|
||||
VRCJson.TryDeserializeFromJson($"[{bStr}]", out DataToken parseResultB);
|
||||
DataList bDataList = parseResultB.DataList;
|
||||
|
||||
List<T> aCSharpList = new List<T>();
|
||||
aCSharpList.Add(_a);
|
||||
List<T> bCSharpList = new List<T>();
|
||||
bCSharpList.Add(_b);
|
||||
|
||||
Assert.AreEqual(aDataList == bDataList, aCSharpList == bCSharpList);
|
||||
Assert.AreEqual(aDataList.Equals(bDataList), aCSharpList.Equals(bCSharpList));
|
||||
}
|
||||
|
||||
// Same values
|
||||
TestDictEqualityToCSharpList(true, true);
|
||||
TestDictEqualityToCSharpList((sbyte)5, (sbyte)5);
|
||||
TestDictEqualityToCSharpList((byte)5, (byte)5);
|
||||
TestDictEqualityToCSharpList((short)5, (short)5);
|
||||
TestDictEqualityToCSharpList((ushort)5, (ushort)5);
|
||||
TestDictEqualityToCSharpList((int)5, (int)5);
|
||||
TestDictEqualityToCSharpList((uint)5, (uint)5);
|
||||
TestDictEqualityToCSharpList((long)5, (long)5);
|
||||
TestDictEqualityToCSharpList((ulong)5, (ulong)5);
|
||||
TestDictEqualityToCSharpList((float)5, (float)5);
|
||||
TestDictEqualityToCSharpList((double)5, (double)5);
|
||||
TestDictEqualityToCSharpList("abc", "abc");
|
||||
|
||||
// Different values
|
||||
TestDictEqualityToCSharpList(true, false);
|
||||
TestDictEqualityToCSharpList((sbyte)5, (sbyte)6);
|
||||
TestDictEqualityToCSharpList((byte)5, (byte)6);
|
||||
TestDictEqualityToCSharpList((short)5, (short)6);
|
||||
TestDictEqualityToCSharpList((ushort)5, (ushort)6);
|
||||
TestDictEqualityToCSharpList((int)5, (int)6);
|
||||
TestDictEqualityToCSharpList((uint)5, (uint)6);
|
||||
TestDictEqualityToCSharpList((long)5, (long)6);
|
||||
TestDictEqualityToCSharpList((ulong)5, (ulong)6);
|
||||
TestDictEqualityToCSharpList((float)5, (float)6);
|
||||
TestDictEqualityToCSharpList((double)5, (double)6);
|
||||
TestDictEqualityToCSharpList("abc", "def");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31e2f9e37f4abc149ba2afe12177f907
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71390c79b4a2cd542bd5608acf8a62af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f08a66c0e0553c44cb72691292e9f0b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,412 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &285526749
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 285526751}
|
||||
- component: {fileID: 285526750}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &285526750
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 285526749}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &285526751
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 285526749}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &572933028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 572933030}
|
||||
- component: {fileID: 572933029}
|
||||
m_Layer: 0
|
||||
m_Name: UdonTestGraph2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &572933029
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 572933028}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
interactTextPlacement: {fileID: 0}
|
||||
interactText: Use
|
||||
interactTextGO: {fileID: 0}
|
||||
proximity: 2
|
||||
SynchronizePosition: 0
|
||||
AllowCollisionOwnershipTransfer: 1
|
||||
Reliable: 0
|
||||
_syncMethod: 2
|
||||
serializedProgramAsset: {fileID: 11400000, guid: d642b1243efff6043b83411eae2d612d,
|
||||
type: 2}
|
||||
programSource: {fileID: 11400000, guid: da113172081f2ba40b9cc46674a846d0, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgIAAAAAAAAAAi8CAAAAAVgAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAVQBuAGkAdAB5AEUAbgBnAGkAbgBlAC4AVQBJAC4AUwBsAGkAZABlAHIALAAgAFUAbgBpAHQAeQBFAG4AZwBpAG4AZQAuAFUASQBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAQgAAAB1AGkAUwBsAGkAZABlAHIAJwEEAAAAdAB5AHAAZQABFwAAAFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQALAAgAG0AcwBjAG8AcgBsAGkAYgAtAQUAAABWAGEAbAB1AGUABwUCLwMAAAABVgAAAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAC4AVQBkAG8AbgBWAGEAcgBpAGEAYgBsAGUAYAAxAFsAWwBVAG4AaQB0AHkARQBuAGcAaQBuAGUALgBVAEkALgBUAGUAeAB0ACwAIABVAG4AaQB0AHkARQBuAGcAaQBuAGUALgBVAEkAXQBdACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgADAAAABgIAAAAAAAAAJwEEAAAAdAB5AHAAZQABFwAAAFMAeQBzAHQAZQBtAC4AUwB0AHIAaQBuAGcALAAgAG0AcwBjAG8AcgBsAGkAYgAnAQoAAABTAHkAbQBiAG8AbABOAGEAbQBlAAEGAAAAdQBpAFQAZQB4AHQAJwEEAAAAdAB5AHAAZQABFwAAAFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQALAAgAG0AcwBjAG8AcgBsAGkAYgAtAQUAAABWAGEAbAB1AGUABwUHBQcF
|
||||
publicVariablesUnityEngineObjects: []
|
||||
publicVariablesSerializationDataFormat: 0
|
||||
--- !u!4 &572933030
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 572933028}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1176873290
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1176873293}
|
||||
- component: {fileID: 1176873292}
|
||||
- component: {fileID: 1176873291}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &1176873291
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1176873290}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &1176873292
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1176873290}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1176873293
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1176873290}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1317367948
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1317367950}
|
||||
- component: {fileID: 1317367949}
|
||||
m_Layer: 0
|
||||
m_Name: UdonTestGraph1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1317367949
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1317367948}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
interactTextPlacement: {fileID: 0}
|
||||
interactText: Use
|
||||
interactTextGO: {fileID: 0}
|
||||
proximity: 2
|
||||
SynchronizePosition: 0
|
||||
AllowCollisionOwnershipTransfer: 1
|
||||
Reliable: 0
|
||||
_syncMethod: 2
|
||||
serializedProgramAsset: {fileID: 11400000, guid: aec1ad21ec8f16449a3eb1cf3baad37e,
|
||||
type: 2}
|
||||
programSource: {fileID: 11400000, guid: 953e2e6278cc9314f9f2913d9bc25309, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUoAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBTAGkAbgBnAGwAZQAsACAAbQBzAGMAbwByAGwAaQBiAF0AXQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAgAAAAYCAAAAAAAAACcBBAAAAHQAeQBwAGUAARcAAABTAHkAcwB0AGUAbQAuAFMAdAByAGkAbgBnACwAIABtAHMAYwBvAHIAbABpAGIAJwEKAAAAUwB5AG0AYgBvAGwATgBhAG0AZQABCwAAAG0AYQB4AEQAaQBzAHQAYQBuAGMAZQAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAGkAbgBnAGwAZQAsACAAbQBzAGMAbwByAGwAaQBiAB8BBQAAAFYAYQBsAHUAZQAAAAAABwUHBQcF
|
||||
publicVariablesUnityEngineObjects: []
|
||||
publicVariablesSerializationDataFormat: 0
|
||||
--- !u!4 &1317367950
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1317367948}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d49885815537cc443beee0124d74cab0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "UnityEditorTests",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"VRC.Udon.Editor",
|
||||
"VRC.Udon",
|
||||
"VRC.SDK3",
|
||||
"VRC.SDKBase",
|
||||
"VRC.SDK3.Editor",
|
||||
"VRC.SDKBase.Editor"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"nunit.framework.dll",
|
||||
"VRC.Udon.ClientBindings.dll",
|
||||
"VRC.Udon.Common.dll",
|
||||
"VRC.Udon.EditorBindings.dll",
|
||||
"VRC.Udon.Compiler.dll",
|
||||
"VRC.Udon.Graph.dll",
|
||||
"VRCSDK3.dll",
|
||||
"VRCSDK3-Editor.dll",
|
||||
"VRCSDKBase.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dcda41e86c546c4c978d0ef060d17bd
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.Udon.Editor;
|
||||
using VRC.Udon.Editor.ProgramSources.UdonGraphProgram;
|
||||
using VRC.Udon.Graph;
|
||||
using VRC.Udon.Editor.ProgramSources.UdonGraphProgram.UI.GraphView;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
public class UICompilerTests
|
||||
{
|
||||
[Test]
|
||||
public void CompareAssemblies()
|
||||
{
|
||||
// Cache Udon Graph View window for reuse
|
||||
var graphViewWindow = EditorWindow.GetWindow<UdonGraphWindow>();
|
||||
|
||||
// Loop through every asset in project
|
||||
var assets = AssetDatabase.FindAssets("t:UdonGraphProgramAsset");
|
||||
foreach (string guid in assets)
|
||||
{
|
||||
// Make sure we're in a clean state
|
||||
Settings.CleanSerializedData();
|
||||
|
||||
// Compile assembly from copy of existing asset
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var legacyData = GetDataFromAssetAtPath(path);
|
||||
var legacyAssembly = UdonEditorManager.Instance.CompileGraph(legacyData, null, out Dictionary<string, (string uid, string fullName, int index)> _, out Dictionary<string, (object value, Type type)> heapDefaultValues, out _);
|
||||
|
||||
// Compile assembly from copy of asset loaded into new graph
|
||||
var newAsset = ScriptableObject.CreateInstance<UdonGraphProgramAsset>();
|
||||
newAsset.graphData = new UdonGraphData(legacyData);
|
||||
newAsset.name = legacyData.name;
|
||||
// This function loads the asset and reSerializes it
|
||||
Settings.SetLastGraph(newAsset);
|
||||
var graphSettings = Settings.GetLastGraph();
|
||||
Assert.AreSame(newAsset, graphSettings.programAsset);
|
||||
var newData = graphSettings.programAsset.graphData;
|
||||
Assert.AreSame(newAsset.graphData, newData);
|
||||
var newAssembly = UdonEditorManager.Instance.CompileGraph(newData, null, out Dictionary<string, (string uid, string fullName, int index)> _, out Dictionary<string, (object value, Type type)> heapDefaultValues1, out _);
|
||||
|
||||
Assert.AreEqual(newAssembly, legacyAssembly);
|
||||
Settings.CloseGraph(newAsset.name);
|
||||
}
|
||||
graphViewWindow.Close();
|
||||
}
|
||||
|
||||
public UdonGraphData GetDataFromAssetAtPath(string path)
|
||||
{
|
||||
var targetAsset = AssetDatabase.LoadAssetAtPath<UdonGraphProgramAsset>(path);
|
||||
return new UdonGraphData(targetAsset.graphData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02e7e7f5f9fc2c24ab3af0b8780f3623
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,391 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using VRC.Udon;
|
||||
using VRC.Udon.Editor.ProgramSources.UdonGraphProgram;
|
||||
using VRC.Udon.Editor.ProgramSources.UdonGraphProgram.UI.GraphView;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
public class UdonGraphSettingsTests
|
||||
{
|
||||
private const string TestAssetPath1 = "MaxAllPlayerVoice-TestGraph";
|
||||
private const string TestAssetPath2 = "SyncedSlider-TestGraph";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
// Make sure we have a clean state
|
||||
Settings.CleanSerializedData();
|
||||
var graphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
|
||||
foreach (var graph in graphs)
|
||||
{
|
||||
//Validate that the graph settings are in a good state
|
||||
Assert.IsNotNull(graph.programAsset);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UseNeonStyleTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
bool useNeonStyle = Settings.UseNeonStyle;
|
||||
Assert.IsFalse(useNeonStyle); // Default value is false
|
||||
|
||||
Settings.UseNeonStyle = true;
|
||||
Assert.IsTrue(Settings.UseNeonStyle); // Value should be true after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchOnSelectedNodeRegistryTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
bool searchOnSelectedNodeRegistry = Settings.SearchOnSelectedNodeRegistry;
|
||||
Assert.IsTrue(searchOnSelectedNodeRegistry); // Default value is true
|
||||
|
||||
Settings.SearchOnSelectedNodeRegistry = false;
|
||||
Assert.IsFalse(Settings.SearchOnSelectedNodeRegistry); // Value should be false after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GridSnapSizeTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
int gridSnapSize = Settings.GridSnapSize;
|
||||
Assert.AreEqual(0, gridSnapSize); // Default value is 0
|
||||
|
||||
Settings.GridSnapSize = 10;
|
||||
Assert.AreEqual(10, Settings.GridSnapSize); // Value should be 10 after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchOnNoodleDropTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
bool searchOnNoodleDrop = Settings.SearchOnNoodleDrop;
|
||||
Assert.IsTrue(searchOnNoodleDrop); // Default value is true
|
||||
|
||||
Settings.SearchOnNoodleDrop = false;
|
||||
Assert.IsFalse(Settings.SearchOnNoodleDrop); // Value should be false after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HighlightFlowTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
bool highlightFlow = Settings.HighlightFlow;
|
||||
Assert.IsFalse(highlightFlow); // Default value is false
|
||||
|
||||
Settings.HighlightFlow = true;
|
||||
Assert.IsTrue(Settings.HighlightFlow); // Value should be true after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LastGraphIndexTest()
|
||||
{
|
||||
Settings.Reset(); // Reset to default values
|
||||
int lastGraphIndex = Settings.LastGraphIndex;
|
||||
Assert.AreEqual(0, lastGraphIndex); // Default value is 0
|
||||
|
||||
Settings.LastGraphIndex = 10;
|
||||
Assert.AreEqual(10, Settings.LastGraphIndex); // Value should be 10 after setting it
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeGraphsTest()
|
||||
{
|
||||
// Create Test Data
|
||||
List<Settings.GraphSettings> testGraphs = new List<Settings.GraphSettings>();
|
||||
Settings.GraphSettings testGraph1 = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.GraphSettings testGraph2 = LoadTestGraphSetting(TestAssetPath2);
|
||||
testGraphs.Add(testGraph1);
|
||||
testGraphs.Add(testGraph2);
|
||||
|
||||
// Serialize test data
|
||||
Settings.GraphSettingsList.SetGraphSettings(testGraphs);
|
||||
// Deserialize test data
|
||||
List<Settings.GraphSettings> deserializedGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
|
||||
// Serialized and de-/re-Serialized graphs should match (Makes sure data isn't mutated)
|
||||
for (int i = 0; i < deserializedGraphs.Count; i++)
|
||||
{
|
||||
Settings.GraphSettings deSerializedGraph = deserializedGraphs[i];
|
||||
Settings.GraphSettings preSerializedGraph = testGraphs[i];
|
||||
|
||||
// Graphs should have the same data
|
||||
Assert.AreEqual(preSerializedGraph.uid, deSerializedGraph.uid);
|
||||
Assert.AreEqual(preSerializedGraph.scenePath, deSerializedGraph.scenePath);
|
||||
Assert.AreEqual(preSerializedGraph.assetPath, deSerializedGraph.assetPath);
|
||||
Assert.AreEqual(preSerializedGraph.programAsset, deSerializedGraph.programAsset);
|
||||
}
|
||||
}
|
||||
|
||||
private static Settings.GraphSettings LoadTestGraphSetting(string graphAssetPath)
|
||||
{
|
||||
// Load test graph program assets from disk
|
||||
UdonGraphProgramAsset graphAsset =
|
||||
Resources.Load(graphAssetPath, typeof(UdonGraphProgramAsset)) as UdonGraphProgramAsset;
|
||||
//Create test graph settings from the assets
|
||||
Settings.GraphSettings testGraph = Settings.GraphSettings.Create(graphAsset);
|
||||
Assert.IsNotNull(testGraph);
|
||||
return testGraph;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LastGraphTest()
|
||||
{
|
||||
// Load test graph program assets from disk
|
||||
Settings.GraphSettings testGraph1 = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.GraphSettings testGraph2 = LoadTestGraphSetting(TestAssetPath2);
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
Settings.SetLastGraph(testGraph2);
|
||||
Settings.GraphSettings lastGraph = Settings.GetLastGraph();
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, lastGraph.uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, lastGraph.scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, lastGraph.assetPath); // Graph asset paths should match
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
lastGraph = Settings.GetLastGraph();
|
||||
Assert.AreEqual(testGraph1.uid, lastGraph.uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, lastGraph.scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, lastGraph.assetPath); // Graph asset paths should match
|
||||
|
||||
Settings.LastGraphIndex = -1; // Set index to -1 to test if it returns null
|
||||
lastGraph = Settings.GetLastGraph();
|
||||
Assert.IsNull(lastGraph); // Last graph should be null
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LastGraphFromAssetTest()
|
||||
{
|
||||
// Load test graph program assets from disk
|
||||
UdonGraphProgramAsset graphAsset1 = Resources.Load("MaxAllPlayerVoice-TestGraph", typeof(UdonGraphProgramAsset)) as UdonGraphProgramAsset;
|
||||
UdonGraphProgramAsset graphAsset2 = Resources.Load("SyncedSlider-TestGraph", typeof(UdonGraphProgramAsset)) as UdonGraphProgramAsset;
|
||||
|
||||
Settings.SetLastGraph(graphAsset1);
|
||||
Settings.SetLastGraph(graphAsset2);
|
||||
Settings.GraphSettings lastGraph = Settings.GetLastGraph();
|
||||
|
||||
Assert.AreEqual(graphAsset2, lastGraph.programAsset); // Graphs should match
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetGraphTest()
|
||||
{
|
||||
Settings.GraphSettings testGraph = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.SetLastGraph(testGraph);
|
||||
|
||||
Settings.GraphSettings graph = Settings.GetGraph(TestAssetPath1);
|
||||
Assert.AreEqual(testGraph.uid, graph.uid); // Graph UIDs should match
|
||||
|
||||
// Try to get a graph that doesn't exist
|
||||
graph = Settings.GetGraph("123456789");
|
||||
Assert.IsNull(graph); // Graph should be null
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetGraphFromSceneTest()
|
||||
{
|
||||
// Open test scene
|
||||
var scene = Resources.Load("UdonEditorTestScene") as SceneAsset;
|
||||
string scenePath = AssetDatabase.GetAssetPath(scene);
|
||||
EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
||||
|
||||
// Load test graph programs from scene
|
||||
UdonBehaviour[] udonBehaviours = Object.FindObjectsByType<UdonBehaviour>(FindObjectsSortMode.None);
|
||||
Assert.AreEqual(2, udonBehaviours.Length);
|
||||
|
||||
UdonGraphProgramAsset graphAsset1 = udonBehaviours[0].programSource as UdonGraphProgramAsset;
|
||||
UdonGraphProgramAsset graphAsset2 = udonBehaviours[1].programSource as UdonGraphProgramAsset;
|
||||
Assert.IsNotNull(graphAsset1);
|
||||
Assert.IsNotNull(graphAsset2);
|
||||
|
||||
// Close test graphs
|
||||
Settings.CloseGraph(graphAsset1.name);
|
||||
Settings.CloseGraph(graphAsset2.name);
|
||||
|
||||
// Validate graph settings
|
||||
List<Settings.GraphSettings> openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(0, openGraphs.Count); // There should be 0 open graphs
|
||||
|
||||
// Open graphs in GraphWindow
|
||||
Settings.SetLastGraph(graphAsset1, udonBehaviours[0]);
|
||||
Settings.SetLastGraph(graphAsset2, udonBehaviours[1]);
|
||||
|
||||
// Validate graph settings
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
Assert.AreEqual(udonBehaviours[0].gameObject.scene.path, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
// TODO: Expected: <UdonGraphProgramAsset: SyncedSlider-TestGraph> But was: <UdonGraphProgramAsset: MaxAllPlayerVoice-TestGraph>
|
||||
Assert.AreEqual(udonBehaviours[0].programSource, openGraphs[0].programAsset); // Graph assets should match
|
||||
|
||||
Assert.AreEqual(udonBehaviours[1].gameObject.scene.path, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(udonBehaviours[1].programSource, openGraphs[1].programAsset); // Graph assets should match
|
||||
|
||||
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
||||
//yield return new WaitForDomainReload();
|
||||
|
||||
// Validate graph settings
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
Assert.AreEqual(udonBehaviours[0].gameObject.scene.path, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(udonBehaviours[0].programSource, openGraphs[0].programAsset); // Graph assets should match
|
||||
|
||||
Assert.AreEqual(udonBehaviours[1].gameObject.scene.path, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(udonBehaviours[1].programSource, openGraphs[1].programAsset); // Graph assets should match
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetOpenGraphsTest()
|
||||
{
|
||||
Settings.GraphSettings testGraph1 = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.GraphSettings testGraph2 = LoadTestGraphSetting(TestAssetPath2);
|
||||
|
||||
// Close test graphs
|
||||
Settings.GraphSettingsList.SetGraphSettings(Array.Empty<Settings.GraphSettings>());
|
||||
|
||||
// Validate graph settings
|
||||
List<Settings.GraphSettings> openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(0, openGraphs.Count); // There should be 0 open graphs
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
Settings.SetLastGraph(testGraph2);
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
Assert.AreEqual(testGraph1.uid, openGraphs[0].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, openGraphs[0].assetPath); // Graph asset paths should match
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, openGraphs[1].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, openGraphs[1].assetPath); // Graph asset paths should match
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChangeLastGraphTest()
|
||||
{
|
||||
Settings.GraphSettings testGraph1 = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.GraphSettings testGraph2 = LoadTestGraphSetting(TestAssetPath2);
|
||||
|
||||
// Close test graphs
|
||||
Settings.GraphSettingsList.SetGraphSettings(Array.Empty<Settings.GraphSettings>());
|
||||
|
||||
// Validate graph settings
|
||||
List<Settings.GraphSettings> openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(0, openGraphs.Count); // There should be 0 open graphs
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
Settings.SetLastGraph(testGraph2);
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
Assert.AreEqual(testGraph1.uid, openGraphs[0].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, openGraphs[0].assetPath); // Graph asset paths should match
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, openGraphs[1].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, openGraphs[1].assetPath); // Graph asset paths should match
|
||||
|
||||
// Graph 2 should be the last selected graph and the index should point to its original position in the list
|
||||
var lastGraph = Settings.GetLastGraph();
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, lastGraph.uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, lastGraph.scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, lastGraph.assetPath); // Graph asset paths should match
|
||||
|
||||
int lastGraphIndex = Settings.LastGraphIndex;
|
||||
Assert.AreEqual(1, lastGraphIndex); // Graph index should be 1
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
// Graph 1 should still be first in the list, despite being selected last
|
||||
Assert.AreEqual(testGraph1.uid, openGraphs[0].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, openGraphs[0].assetPath); // Graph asset paths should match
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, openGraphs[1].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, openGraphs[1].assetPath); // Graph asset paths should match
|
||||
|
||||
// Graph 1 should be the last selected graph and the index should point to its original position in the list
|
||||
lastGraph = Settings.GetLastGraph();
|
||||
|
||||
Assert.AreEqual(testGraph1.uid, lastGraph.uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, lastGraph.scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, lastGraph.assetPath); // Graph asset paths should match
|
||||
|
||||
lastGraphIndex = Settings.LastGraphIndex;
|
||||
Assert.AreEqual(0, lastGraphIndex); // Graph index should be 0
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloseGraphTest()
|
||||
{
|
||||
Settings.GraphSettings testGraph1 = LoadTestGraphSetting(TestAssetPath1);
|
||||
Settings.GraphSettings testGraph2 = LoadTestGraphSetting(TestAssetPath2);
|
||||
|
||||
// Close test graphs
|
||||
Settings.GraphSettingsList.SetGraphSettings(Array.Empty<Settings.GraphSettings>());
|
||||
|
||||
// Validate graph settings
|
||||
List<Settings.GraphSettings> openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(0, openGraphs.Count); // There should be 0 open graphs
|
||||
|
||||
Settings.SetLastGraph(testGraph1);
|
||||
Settings.SetLastGraph(testGraph2);
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(2, openGraphs.Count); // There should be 2 open graphs
|
||||
|
||||
Assert.AreEqual(testGraph1.uid, openGraphs[0].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, openGraphs[0].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, openGraphs[0].assetPath); // Graph asset paths should match
|
||||
|
||||
Assert.AreEqual(testGraph2.uid, openGraphs[1].uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph2.scenePath, openGraphs[1].scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph2.assetPath, openGraphs[1].assetPath); // Graph asset paths should match
|
||||
|
||||
// Close last graph
|
||||
Settings.CloseGraph(testGraph2.programAsset.name);
|
||||
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(1, openGraphs.Count); // There should be 1 open graph
|
||||
|
||||
Settings.GraphSettings lastGraph = Settings.GetLastGraph();
|
||||
// Last graph should be the first graph now
|
||||
Assert.AreEqual(testGraph1.uid, lastGraph.uid); // Graph UIDs should match
|
||||
Assert.AreEqual(testGraph1.scenePath, lastGraph.scenePath); // Graph scene paths should match
|
||||
Assert.AreEqual(testGraph1.assetPath, lastGraph.assetPath); // Graph asset paths should match
|
||||
|
||||
// Try closing something that doesn't exist
|
||||
Settings.CloseGraph("This graph doesn't exist");
|
||||
|
||||
openGraphs = Settings.GraphSettingsList.GetGraphSettings();
|
||||
Assert.AreEqual(1, openGraphs.Count); // There should still be 1 open graph
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResetSettings()
|
||||
{
|
||||
Settings.Reset();
|
||||
Assert.IsFalse(Settings.HighlightFlow); // HighlightFlow should be false
|
||||
Assert.AreEqual(0, Settings.LastGraphIndex); // LastGraphIndex should be 0
|
||||
Assert.IsNull(Settings.GetLastGraph()); // LastGraph should be null
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5ecdc6e48942134fb203261251a26c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a6f9d583bdb9734fa047ef936b86d48
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9d3ea3ffc62e724ca7b3d4db36f1b22
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,232 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f11136daadff0b44ac2278a314682ab, type: 3}
|
||||
m_Name: MaxAllPlayerVoice-TestGraph
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: d7fdd48ef1a96a54da39809853e1b970, type: 2}
|
||||
udonAssembly: ".data_start\r\n\r\n .export maxDistance\r\n \r\n __index_0:
|
||||
%SystemInt32, null\r\n __condition_0: %SystemBoolean, null\r\n __Boolean_0:
|
||||
%SystemBoolean, null\r\n __Object_0: %SystemObject, null\r\n __Object_1:
|
||||
%SystemObject, null\r\n __var_0: %SystemObject, null\r\n __instance_2:
|
||||
%VRCSDKBaseVRCPlayerApi, null\r\n __far_0: %SystemSingle, null\r\n __instance_3:
|
||||
%VRCSDKBaseVRCPlayerApi, null\r\n __distance_0: %SystemSingle, null\r\n
|
||||
__instance_1: %VRCSDKBaseVRCPlayerApiArray, null\r\n __Int32_1: %SystemInt32,
|
||||
null\r\n __players_0: %VRCSDKBaseVRCPlayerApiArray, null\r\n __start_0:
|
||||
%SystemInt32, null\r\n __end_0: %SystemInt32, null\r\n __step_0: %SystemInt32,
|
||||
null\r\n __instance_0: %VRCSDKBaseVRCPlayerApiArray, null\r\n __Int32_0:
|
||||
%SystemInt32, null\r\n maxDistance: %SystemSingle, null\r\n\r\n.data_end\r\n\r\n.code_start\r\n\r\n
|
||||
.export _interact\r\n \r\n _interact:\r\n \r\n PUSH, __Int32_0\r\n
|
||||
PUSH, __instance_0\r\n EXTERN, \"VRCSDKBaseVRCPlayerApiArray.__ctor__SystemInt32__VRCSDKBaseVRCPlayerApiArray\"\r\n
|
||||
PUSH, __instance_0\r\n PUSH, __end_0\r\n EXTERN, \"VRCSDKBaseVRCPlayerApiArray.__get_Length__SystemInt32\"\r\n
|
||||
PUSH, __start_0\r\n PUSH, __index_0\r\n COPY\r\n PUSH, __index_0\r\n
|
||||
PUSH, __end_0\r\n PUSH, __condition_0\r\n EXTERN, \"SystemInt32.__op_LessThan__SystemInt32_SystemInt32__SystemBoolean\"\r\n
|
||||
PUSH, __condition_0\r\n JUMP_IF_FALSE, 0x000001F0\r\n PUSH, __instance_0\r\n
|
||||
PUSH, __players_0\r\n COPY\r\n PUSH, __instance_0\r\n PUSH,
|
||||
__instance_1\r\n EXTERN, \"VRCSDKBaseVRCPlayerApi.__GetPlayers__VRCSDKBaseVRCPlayerApiArray__VRCSDKBaseVRCPlayerApiArray\"\r\n
|
||||
PUSH, __index_0\r\n PUSH, __Int32_1\r\n COPY\r\n PUSH, __instance_1\r\n
|
||||
PUSH, __Int32_1\r\n PUSH, __Object_0\r\n EXTERN, \"VRCSDKBaseVRCPlayerApiArray.__Get__SystemInt32__VRCSDKBaseVRCPlayerApi\"\r\n
|
||||
PUSH, __var_0\r\n PUSH, __Object_1\r\n COPY\r\n PUSH, __Object_0\r\n
|
||||
PUSH, __Object_1\r\n PUSH, __Boolean_0\r\n EXTERN, \"SystemObject.__op_Inequality__SystemObject_SystemObject__SystemBoolean\"\r\n
|
||||
PUSH, __Boolean_0\r\n JUMP_IF_FALSE, 0x000001C8\r\n PUSH, __instance_0\r\n
|
||||
PUSH, __players_0\r\n COPY\r\n PUSH, __index_0\r\n PUSH,
|
||||
__Int32_1\r\n COPY\r\n PUSH, __Object_0\r\n PUSH, __instance_2\r\n
|
||||
COPY\r\n PUSH, __Object_0\r\n PUSH, maxDistance\r\n EXTERN,
|
||||
\"VRCSDKBaseVRCPlayerApi.__SetVoiceDistanceFar__SystemSingle__SystemVoid\"\r\n
|
||||
PUSH, __instance_0\r\n PUSH, __players_0\r\n COPY\r\n PUSH,
|
||||
__index_0\r\n PUSH, __Int32_1\r\n COPY\r\n PUSH, __Object_0\r\n
|
||||
PUSH, __instance_3\r\n COPY\r\n PUSH, __Object_0\r\n PUSH,
|
||||
maxDistance\r\n EXTERN, \"VRCSDKBaseVRCPlayerApi.__SetAvatarAudioFarRadius__SystemSingle__SystemVoid\"\r\n
|
||||
JUMP, 0x000001C8\r\n PUSH, __index_0\r\n PUSH, __step_0\r\n
|
||||
PUSH, __index_0\r\n EXTERN, \"SystemInt32.__op_Addition__SystemInt32_SystemInt32__SystemInt32\"\r\n
|
||||
JUMP, 0x00000044\r\n JUMP, 0xFFFFFFFC\r\n \r\n\r\n.code_end\r\n"
|
||||
assemblyError:
|
||||
graphData:
|
||||
name:
|
||||
description:
|
||||
nodes:
|
||||
- fullName: Variable_SystemSingle
|
||||
uid: 41d495ae-1331-4ab9-bb00-f6e3844acfcd
|
||||
position: {x: 0, y: 0}
|
||||
nodeUIDs:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|maxDistance
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|True
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|none
|
||||
- fullName: Get_Variable
|
||||
uid: 5cf1f089-94c2-4770-a1c0-b164f60d7bf7
|
||||
position: {x: 1570.3755, y: 440.48584}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|41d495ae-1331-4ab9-bb00-f6e3844acfcd
|
||||
- fullName: VRCSDKBaseVRCPlayerApiArray.__ctor__SystemInt32__VRCSDKBaseVRCPlayerApiArray
|
||||
uid: 43786ea1-0a43-4d0f-9775-f0aed4e2c5fe
|
||||
position: {x: 208.3397, y: 400.87683}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|8
|
||||
- fullName: VRCSDKBaseVRCPlayerApiArray.__get_Length__SystemInt32
|
||||
uid: bb1afc1e-fe52-410c-926b-898e50b65165
|
||||
position: {x: 420.26245, y: 256.4167}
|
||||
nodeUIDs:
|
||||
- 43786ea1-0a43-4d0f-9775-f0aed4e2c5fe|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: For
|
||||
uid: 457c5494-413f-41a5-a7de-ad3ca6518e18
|
||||
position: {x: 695.4876, y: 191.46388}
|
||||
nodeUIDs:
|
||||
-
|
||||
- bb1afc1e-fe52-410c-926b-898e50b65165|0
|
||||
-
|
||||
flowUIDs:
|
||||
- 6e3b3c30-35cd-4cd5-8e7c-360cfcb6d044
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|1
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|1
|
||||
- fullName: Event_Interact
|
||||
uid: db7b9c11-75bf-4976-8c7c-6abfe5061ec6
|
||||
position: {x: 547.7544, y: 165.47472}
|
||||
nodeUIDs: []
|
||||
flowUIDs:
|
||||
- 457c5494-413f-41a5-a7de-ad3ca6518e18
|
||||
nodeValues: []
|
||||
- fullName: VRCSDKBaseVRCPlayerApiArray.__Get__SystemInt32__VRCSDKBaseVRCPlayerApi
|
||||
uid: 2d3bd590-c7dc-4190-95e2-effd3ce1bfa7
|
||||
position: {x: 893.10547, y: 400.0312}
|
||||
nodeUIDs:
|
||||
- 13b8c47e-1340-4392-bbcd-1fd439b16c27|0
|
||||
- 457c5494-413f-41a5-a7de-ad3ca6518e18|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: Branch
|
||||
uid: 6e3b3c30-35cd-4cd5-8e7c-360cfcb6d044
|
||||
position: {x: 1361.6233, y: 186.31009}
|
||||
nodeUIDs:
|
||||
- a0bd3f50-668b-420e-844c-536d8a4530d5|0
|
||||
flowUIDs:
|
||||
- e45965b1-be04-448c-8f32-de5c5fe9ce89
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- fullName: SystemObject.__op_Inequality__SystemObject_SystemObject__SystemBoolean
|
||||
uid: a0bd3f50-668b-420e-844c-536d8a4530d5
|
||||
position: {x: 1178.9456, y: 261.78915}
|
||||
nodeUIDs:
|
||||
- 2d3bd590-c7dc-4190-95e2-effd3ce1bfa7|0
|
||||
- c42b64c8-30a2-4619-abf1-3da339159b2a|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Const_Null
|
||||
uid: c42b64c8-30a2-4619-abf1-3da339159b2a
|
||||
position: {x: 1051.0082, y: 287.23203}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: VRCSDKBaseVRCPlayerApi.__GetPlayers__VRCSDKBaseVRCPlayerApiArray__VRCSDKBaseVRCPlayerApiArray
|
||||
uid: 13b8c47e-1340-4392-bbcd-1fd439b16c27
|
||||
position: {x: 589.74316, y: 402.59503}
|
||||
nodeUIDs:
|
||||
- 43786ea1-0a43-4d0f-9775-f0aed4e2c5fe|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: VRCSDKBaseVRCPlayerApi.__SetVoiceDistanceFar__SystemSingle__SystemVoid
|
||||
uid: 0fd3e05e-7e7d-454d-856b-6bda42760146
|
||||
position: {x: 1755.559, y: 327.15527}
|
||||
nodeUIDs:
|
||||
- 2d3bd590-c7dc-4190-95e2-effd3ce1bfa7|0
|
||||
- 5cf1f089-94c2-4770-a1c0-b164f60d7bf7|0
|
||||
flowUIDs:
|
||||
-
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: VRCSDKBaseVRCPlayerApi.__SetAvatarAudioFarRadius__SystemSingle__SystemVoid
|
||||
uid: b78d84d3-6acd-4fbd-b2b3-d288d1c60b28
|
||||
position: {x: 1759.1759, y: 459.5569}
|
||||
nodeUIDs:
|
||||
- 2d3bd590-c7dc-4190-95e2-effd3ce1bfa7|0
|
||||
- 5cf1f089-94c2-4770-a1c0-b164f60d7bf7|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: Block
|
||||
uid: e45965b1-be04-448c-8f32-de5c5fe9ce89
|
||||
position: {x: 1590.7582, y: 274.69427}
|
||||
nodeUIDs: []
|
||||
flowUIDs:
|
||||
- 0fd3e05e-7e7d-454d-856b-6bda42760146
|
||||
- b78d84d3-6acd-4fbd-b2b3-d288d1c60b28
|
||||
nodeValues: []
|
||||
updateOrder: 0
|
||||
graphElementData:
|
||||
- type: 2
|
||||
uid:
|
||||
jsonData: '{"uid":"33884f4e-b34c-498f-8124-30c4716e8cfd","layout":{"serializedVersion":"2","x":1431.9425048828125,"y":195.11395263671876,"width":128.0,"height":128.0},"containedElements":["c42b64c8-30a2-4619-abf1-3da339159b2a","a0bd3f50-668b-420e-844c-536d8a4530d5","6e3b3c30-35cd-4cd5-8e7c-360cfcb6d044"],"title":"Check
|
||||
that Player exists","layer":0,"elementTypeColor":{"r":0.0,"g":0.0,"b":0.0,"a":0.0}}'
|
||||
- type: 2
|
||||
uid:
|
||||
jsonData: '{"uid":"cd914d85-1505-4159-9007-61b1e8932e34","layout":{"serializedVersion":"2","x":1545.3756103515625,"y":210.69424438476563,"width":606.0,"height":401.0},"containedElements":["e45965b1-be04-448c-8f32-de5c5fe9ce89","b78d84d3-6acd-4fbd-b2b3-d288d1c60b28","0fd3e05e-7e7d-454d-856b-6bda42760146","5cf1f089-94c2-4770-a1c0-b164f60d7bf7"],"title":"Set
|
||||
Voice and Avatar Audio to maxDistance","layer":0,"elementTypeColor":{"r":0.0,"g":0.0,"b":0.0,"a":0.0}}'
|
||||
- type: 5
|
||||
uid: dc63dc6b-f6d7-4ba5-b506-93cb1352c962
|
||||
jsonData: '{"visible":true,"layout":{"serializedVersion":"2","x":10.0,"y":130.0,"width":200.0,"height":150.0}}'
|
||||
- type: 4
|
||||
uid: da536a20-8ebd-453c-96bf-f297a234d10a
|
||||
jsonData: '{"visible":true,"layout":{"serializedVersion":"2","x":10.0,"y":20.0,"width":0.0,"height":0.0}}'
|
||||
version: 1.0.0
|
||||
showAssembly: 0
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 953e2e6278cc9314f9f2913d9bc25309
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,340 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f11136daadff0b44ac2278a314682ab, type: 3}
|
||||
m_Name: SyncedSlider-TestGraph
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: c33a48de6fbe43b4eb491cac621b1ac6, type: 2}
|
||||
udonAssembly: ".data_start\r\n\r\n .export uiSlider\r\n .export uiText\r\n
|
||||
.sync sliderValue, none\r\n \r\n __Boolean_0: %SystemBoolean, null\r\n
|
||||
__Single_0: %SystemSingle, null\r\n __Single_1: %SystemSingle, null\r\n
|
||||
__player_0: %VRCSDKBaseVRCPlayerApi, null\r\n __obj_0: %UnityEngineGameObject,
|
||||
this\r\n __instance_1: %VRCUdonUdonBehaviour, this\r\n __symbolName_0:
|
||||
%SystemString, null\r\n __value_0: %SystemObject, null\r\n __instance_0:
|
||||
%UnityEngineUISlider, null\r\n __instance_2: %VRCUdonUdonBehaviour, this\r\n
|
||||
__instance_3: %UnityEngineUIText, null\r\n __value_1: %SystemString, null\r\n
|
||||
__instance_4: %SystemSingle, null\r\n __instance_5: %UnityEngineUISlider,
|
||||
null\r\n __value_2: %SystemSingle, null\r\n __name_0: %SystemString, null\r\n
|
||||
sliderValue: %SystemSingle, null\r\n uiSlider: %UnityEngineUISlider, null\r\n
|
||||
uiText: %UnityEngineUIText, null\r\n __returnValue: %SystemObject, null\r\n\r\n.data_end\r\n\r\n.code_start\r\n\r\n
|
||||
.export OnValueChanged\r\n \r\n OnValueChanged:\r\n \r\n PUSH,
|
||||
uiSlider\r\n PUSH, __instance_0\r\n COPY\r\n PUSH, __instance_0\r\n
|
||||
PUSH, __Single_0\r\n EXTERN, \"UnityEngineUISlider.__get_value__SystemSingle\"\r\n
|
||||
PUSH, __Single_0\r\n PUSH, sliderValue\r\n PUSH, __Boolean_0\r\n
|
||||
EXTERN, \"SystemSingle.__op_Inequality__SystemSingle_SystemSingle__SystemBoolean\"\r\n
|
||||
PUSH, __Boolean_0\r\n JUMP_IF_FALSE, 0x000000E4\r\n PUSH, __player_0\r\n
|
||||
EXTERN, \"VRCSDKBaseNetworking.__get_LocalPlayer__VRCSDKBaseVRCPlayerApi\"\r\n
|
||||
PUSH, __player_0\r\n PUSH, __obj_0\r\n EXTERN, \"VRCSDKBaseNetworking.__SetOwner__VRCSDKBaseVRCPlayerApi_UnityEngineGameObject__SystemVoid\"\r\n
|
||||
PUSH, uiSlider\r\n PUSH, __instance_0\r\n COPY\r\n PUSH,
|
||||
__Single_0\r\n PUSH, __value_0\r\n COPY\r\n PUSH, __instance_1\r\n
|
||||
PUSH, __symbolName_0\r\n PUSH, __Single_0\r\n EXTERN, \"VRCUdonCommonInterfacesIUdonEventReceiver.__SetProgramVariable__SystemString_SystemObject__SystemVoid\"\r\n
|
||||
PUSH, __instance_2\r\n EXTERN, \"VRCUdonCommonInterfacesIUdonEventReceiver.__RequestSerialization__SystemVoid\"\r\n
|
||||
JUMP, 0x000000E4\r\n JUMP, 0xFFFFFFFC\r\n \r\n .export _onVarChange_sliderValue\r\n
|
||||
\r\n _onVarChange_sliderValue:\r\n \r\n PUSH, uiText\r\n
|
||||
PUSH, __instance_3\r\n COPY\r\n PUSH, sliderValue\r\n PUSH,
|
||||
__value_1\r\n EXTERN, \"SystemSingle.__ToString__SystemString\"\r\n
|
||||
PUSH, __instance_3\r\n PUSH, __value_1\r\n EXTERN, \"UnityEngineUIText.__set_text__SystemString__SystemVoid\"\r\n
|
||||
PUSH, uiSlider\r\n PUSH, __instance_5\r\n COPY\r\n PUSH,
|
||||
__instance_5\r\n PUSH, sliderValue\r\n EXTERN, \"UnityEngineUISlider.__set_value__SystemSingle__SystemVoid\"\r\n
|
||||
JUMP, 0xFFFFFFFC\r\n \r\n\r\n.code_end\r\n"
|
||||
assemblyError:
|
||||
graphData:
|
||||
name:
|
||||
description:
|
||||
nodes:
|
||||
- fullName: Variable_SystemSingle
|
||||
uid: 681f688f-6b05-479f-b350-84415532656d
|
||||
position: {x: 60, y: -684}
|
||||
nodeUIDs:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|sliderValue
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|True
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|none
|
||||
- fullName: Variable_UnityEngineUISlider
|
||||
uid: 181b218a-898a-4725-bee3-34d8a7893ce6
|
||||
position: {x: 280, y: -562}
|
||||
nodeUIDs:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|uiSlider
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|True
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|none
|
||||
- fullName: Get_Variable
|
||||
uid: 01a5da6d-ed90-444e-b8e3-9a7afdab6522
|
||||
position: {x: 380, y: 180}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|181b218a-898a-4725-bee3-34d8a7893ce6
|
||||
- fullName: UnityEngineUISlider.__get_value__SystemSingle
|
||||
uid: da176d15-c265-46bf-87a8-8a508f1d5f6e
|
||||
position: {x: -150, y: -340}
|
||||
nodeUIDs:
|
||||
- 0dcc3560-73e5-453f-9f2c-17b429083a2e|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Set_Variable
|
||||
uid: aebbea54-c452-4521-954a-00bb267dfeca
|
||||
position: {x: 560, y: -390}
|
||||
nodeUIDs:
|
||||
-
|
||||
- da176d15-c265-46bf-87a8-8a508f1d5f6e|0
|
||||
-
|
||||
flowUIDs:
|
||||
- dfa92252-2496-4eef-b156-385bee9ace37
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|681f688f-6b05-479f-b350-84415532656d
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|True
|
||||
- fullName: UnityEngineUISlider.__set_value__SystemSingle__SystemVoid
|
||||
uid: 8c875359-d6c7-4bb0-83bd-01ffe4cf267c
|
||||
position: {x: 560, y: -10}
|
||||
nodeUIDs:
|
||||
- 01a5da6d-ed90-444e-b8e3-9a7afdab6522|0
|
||||
- 2ee6a71e-7892-4d2c-a868-d1fc992e3210|0
|
||||
flowUIDs:
|
||||
-
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: Variable_UnityEngineUIText
|
||||
uid: bf75ad30-48c8-456e-a7f7-ae92672059c1
|
||||
position: {x: 60, y: -504}
|
||||
nodeUIDs:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|uiText
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|True
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: UnityEngineUIText.__set_text__SystemString__SystemVoid
|
||||
uid: 38dce4b4-e64b-4eec-a652-c7f00d78eec7
|
||||
position: {x: 320, y: -10}
|
||||
nodeUIDs:
|
||||
- 57b26821-6967-42a4-89f1-9ae388669d60|0
|
||||
- 7c882298-e2ba-4d00-84d4-ef5560f3241a|0
|
||||
flowUIDs:
|
||||
- 8c875359-d6c7-4bb0-83bd-01ffe4cf267c
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Get_Variable
|
||||
uid: 57b26821-6967-42a4-89f1-9ae388669d60
|
||||
position: {x: 120, y: 60}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|bf75ad30-48c8-456e-a7f7-ae92672059c1
|
||||
- fullName: SystemSingle.__ToString__SystemString
|
||||
uid: 7c882298-e2ba-4d00-84d4-ef5560f3241a
|
||||
position: {x: 80, y: 150}
|
||||
nodeUIDs:
|
||||
- 2ee6a71e-7892-4d2c-a868-d1fc992e3210|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: Event_Custom
|
||||
uid: 0348b9cd-402a-43cd-b830-6edf5369ee14
|
||||
position: {x: -40, y: -460}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs:
|
||||
- 066054b5-b9fc-4a58-9ebd-081b21b4aded
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|OnValueChanged
|
||||
- fullName: VRCSDKBaseNetworking.__SetOwner__VRCSDKBaseVRCPlayerApi_UnityEngineGameObject__SystemVoid
|
||||
uid: 837f4cb7-7911-4637-8f5d-f4e9b0cc2006
|
||||
position: {x: 430, y: -390}
|
||||
nodeUIDs:
|
||||
- e011db3a-e941-4638-95ed-1db764289ec3|0
|
||||
-
|
||||
flowUIDs:
|
||||
- aebbea54-c452-4521-954a-00bb267dfeca
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: VRCSDKBaseNetworking.__get_LocalPlayer__VRCSDKBaseVRCPlayerApi
|
||||
uid: e011db3a-e941-4638-95ed-1db764289ec3
|
||||
position: {x: 260, y: -260}
|
||||
nodeUIDs: []
|
||||
flowUIDs: []
|
||||
nodeValues: []
|
||||
- fullName: VRCUdonCommonInterfacesIUdonEventReceiver.__RequestSerialization__SystemVoid
|
||||
uid: dfa92252-2496-4eef-b156-385bee9ace37
|
||||
position: {x: 730, y: -390}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Variable_SystemObject
|
||||
uid: ceecf9a0-6fab-4704-87b2-b5fb4217464a
|
||||
position: {x: 0, y: 0}
|
||||
nodeUIDs:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|__returnValue
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|none
|
||||
- fullName: Event_OnVariableChange
|
||||
uid: 2ee6a71e-7892-4d2c-a868-d1fc992e3210
|
||||
position: {x: -240, y: -10}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs:
|
||||
- 38dce4b4-e64b-4eec-a652-c7f00d78eec7
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|681f688f-6b05-479f-b350-84415532656d
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Get_Variable
|
||||
uid: 0dcc3560-73e5-453f-9f2c-17b429083a2e
|
||||
position: {x: -310, y: -340}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|181b218a-898a-4725-bee3-34d8a7893ce6
|
||||
- fullName: SystemSingle.__op_Inequality__SystemSingle_SystemSingle__SystemBoolean
|
||||
uid: 13e2ac21-b327-4cce-a645-ec0db208e723
|
||||
position: {x: 30, y: -260}
|
||||
nodeUIDs:
|
||||
- da176d15-c265-46bf-87a8-8a508f1d5f6e|0
|
||||
- f1962a04-ab03-44bf-bf14-29bd0699fd93|0
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|0
|
||||
- fullName: Get_Variable
|
||||
uid: f1962a04-ab03-44bf-bf14-29bd0699fd93
|
||||
position: {x: -150, y: -210}
|
||||
nodeUIDs:
|
||||
-
|
||||
flowUIDs: []
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|681f688f-6b05-479f-b350-84415532656d
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue:
|
||||
- fullName: Branch
|
||||
uid: 066054b5-b9fc-4a58-9ebd-081b21b4aded
|
||||
position: {x: 180, y: -390}
|
||||
nodeUIDs:
|
||||
- 13e2ac21-b327-4cce-a645-ec0db208e723|0
|
||||
flowUIDs:
|
||||
- 837f4cb7-7911-4637-8f5d-f4e9b0cc2006
|
||||
nodeValues:
|
||||
- unityObjectValue: {fileID: 0}
|
||||
stringValue: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089|False
|
||||
updateOrder: 0
|
||||
graphElementData:
|
||||
- type: 2
|
||||
uid: 6a0871a6-97af-462f-868e-423ad3ffbeaa
|
||||
jsonData: '{"uid":"6a0871a6-97af-462f-868e-423ad3ffbeaa","layout":{"serializedVersion":"2","x":-440.0,"y":-530.0,"width":1384.0,"height":432.0},"containedElements":["4ae03fa2-a4e2-48b6-a2e9-950568f9c506","aebbea54-c452-4521-954a-00bb267dfeca","df9b1434-6157-4120-8f85-5d9646029b5d","da176d15-c265-46bf-87a8-8a508f1d5f6e","0348b9cd-402a-43cd-b830-6edf5369ee14","43337f82-869f-4ff7-a7c8-e25e17b441a1","837f4cb7-7911-4637-8f5d-f4e9b0cc2006","e011db3a-e941-4638-95ed-1db764289ec3","dfa92252-2496-4eef-b156-385bee9ace37","0dcc3560-73e5-453f-9f2c-17b429083a2e","13e2ac21-b327-4cce-a645-ec0db208e723","f1962a04-ab03-44bf-bf14-29bd0699fd93","066054b5-b9fc-4a58-9ebd-081b21b4aded","03da57fa-118d-4b11-8d1c-a7b34343af3a"],"title":"When
|
||||
UI is changed, check that it''s different than the variable, then become owner
|
||||
and update it","layer":0,"elementTypeColor":{"r":0.0,"g":0.0,"b":0.0,"a":0.0}}'
|
||||
- type: 2
|
||||
uid: d92e16d2-3692-45d2-b422-93cec59fe872
|
||||
jsonData: '{"uid":"d92e16d2-3692-45d2-b422-93cec59fe872","layout":{"serializedVersion":"2","x":-280.0,"y":-70.0,"width":993.0,"height":362.0},"containedElements":["8decd684-56d0-4a80-8757-9d1b74867cac","7c882298-e2ba-4d00-84d4-ef5560f3241a","38dce4b4-e64b-4eec-a652-c7f00d78eec7","e6e4b6ac-32c3-4664-b326-247fd6d68cfb","8c875359-d6c7-4bb0-83bd-01ffe4cf267c","01ff7ac5-acdd-4207-a8e8-d4953ab13349","2ee6a71e-7892-4d2c-a868-d1fc992e3210","01a5da6d-ed90-444e-b8e3-9a7afdab6522","57b26821-6967-42a4-89f1-9ae388669d60","c7256455-804d-46ba-8cae-f815ae765cc8","2fb29dc0-6bd5-4932-b385-faee5e290008"],"title":"Update
|
||||
Text and Slider Value whenever slider is moved","layer":0,"elementTypeColor":{"r":0.0,"g":0.0,"b":0.0,"a":0.0}}'
|
||||
- type: 3
|
||||
uid: 03da57fa-118d-4b11-8d1c-a7b34343af3a
|
||||
jsonData: '{"uid":"03da57fa-118d-4b11-8d1c-a7b34343af3a","layout":{"serializedVersion":"2","x":-420.0,"y":-470.0,"width":350.6292419433594,"height":90.59757995605469},"title":"This
|
||||
event can have any name we want as long as we make it the same on the UI item
|
||||
that triggers it.","layer":0,"elementTypeColor":{"r":0.0,"g":0.0,"b":0.0,"a":0.0}}'
|
||||
- type: 5
|
||||
uid: c386a6db-9e4c-4a8c-9ad8-9777e0978956
|
||||
jsonData: '{"visible":true,"layout":{"serializedVersion":"2","x":10.0,"y":130.0,"width":200.0,"height":150.0}}'
|
||||
- type: 4
|
||||
uid: 375ae574-056c-4f5d-a57b-0c9c2c87c61a
|
||||
jsonData: '{"visible":true,"layout":{"serializedVersion":"2","x":10.0,"y":20.0,"width":0.0,"height":0.0}}'
|
||||
version: 1.0.0
|
||||
showAssembly: 1
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da113172081f2ba40b9cc46674a846d0
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,519 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Tests.DataContainers
|
||||
{
|
||||
public class VRCJsonTests : MonoBehaviour
|
||||
{
|
||||
[Test]
|
||||
public void TestEmpty()
|
||||
{
|
||||
SetAndGetJson("empty", new DataToken());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBool()
|
||||
{
|
||||
SetAndGetJson("bool true", new DataToken(true));
|
||||
SetAndGetJson("bool false", new DataToken(false));
|
||||
}
|
||||
[Test]
|
||||
public void TestByte()
|
||||
{
|
||||
SetAndGetJson("byte number", (byte)4);
|
||||
SetAndGetJson("max byte number", byte.MaxValue);
|
||||
SetAndGetJson("min byte number", byte.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestSByte()
|
||||
{
|
||||
SetAndGetJson("sbyte number", (sbyte)4);
|
||||
SetAndGetJson("max sbyte number", sbyte.MaxValue);
|
||||
SetAndGetJson("min sbyte number", sbyte.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestShort()
|
||||
{
|
||||
SetAndGetJson("short number", (short)4);
|
||||
SetAndGetJson("max short number", short.MaxValue);
|
||||
SetAndGetJson("min short number", short.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestUShort()
|
||||
{
|
||||
SetAndGetJson("ushort number", (ushort)4);
|
||||
SetAndGetJson("max ushort number", ushort.MaxValue);
|
||||
SetAndGetJson("min ushort number", ushort.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestInt()
|
||||
{
|
||||
SetAndGetJson("int number", (int)4);
|
||||
SetAndGetJson("max int number", int.MaxValue);
|
||||
SetAndGetJson("min int number", int.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestUInt()
|
||||
{
|
||||
SetAndGetJson("uint number", (uint)4);
|
||||
SetAndGetJson("max uint number", uint.MaxValue);
|
||||
SetAndGetJson("min uint number", uint.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestLong()
|
||||
{
|
||||
SetAndGetJson("long number", (long)4);
|
||||
SetAndGetJson("max long number", long.MaxValue);
|
||||
SetAndGetJson("min long number", long.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestULong()
|
||||
{
|
||||
SetAndGetJson("ulong number", (ulong)4);
|
||||
SetAndGetJson("max ulong number", ulong.MaxValue);
|
||||
SetAndGetJson("min ulong number", ulong.MinValue);
|
||||
}
|
||||
[Test]
|
||||
public void TestFloat()
|
||||
{
|
||||
//SetAndGetJson("float number", 0.123f, false);
|
||||
SetAndGetJson( "1.23e-2)",1.23e-2f);
|
||||
SetAndGetJson( "1.234e-5",1.234e-5f);
|
||||
SetAndGetJson( "1.2345E-10",1.2345E-10f);
|
||||
SetAndGetJson( "1.23456E-20",1.23456E-20f);
|
||||
SetAndGetJson( "5E-20",5E-20f);
|
||||
SetAndGetJson( "1.23E+2",1.23E+2f);
|
||||
SetAndGetJson( "1.234e5",1.234e5f);
|
||||
SetAndGetJson( "1.2345E10",1.2345E10f);
|
||||
SetAndGetJson( "-7.576E-05",-7.576E-05f);
|
||||
SetAndGetJson( "1.23456e20",1.23456e20f);
|
||||
SetAndGetJson( "5e+20",5e+20f);
|
||||
SetAndGetJson( "5e-200",5e-200f);
|
||||
SetAndGetJson( "9.1093822E-31",9.1093822E-31f);
|
||||
SetAndGetJson( "5.9736e24",5.9736e24f);
|
||||
SetAndGetJson("90.00001 float", 90.00001f);
|
||||
SetAndGetJson("max float number / 1000", float.MaxValue /1000);
|
||||
SetAndGetJson("max float number / 100", float.MaxValue /100);
|
||||
SetAndGetJson("max float number / 10", float.MaxValue /10);
|
||||
SetAndGetJson("max float number", float.MaxValue);
|
||||
SetAndGetJson("min float number", float.MinValue);
|
||||
SetAndGetJson("Epsilon float number", float.Epsilon);
|
||||
}
|
||||
[Test]
|
||||
public void TestDouble()
|
||||
{
|
||||
SetAndGetJson( "1",1);
|
||||
SetAndGetJson( "1.23e-2",1.23e-2);
|
||||
SetAndGetJson( "1.234e-5",1.234e-5);
|
||||
SetAndGetJson( "1.2345E-10",1.2345E-10);
|
||||
SetAndGetJson( "1.23456E-20",1.23456E-20);
|
||||
SetAndGetJson( "5E-20",5E-20);
|
||||
SetAndGetJson( "1.23E+2",1.23E+2);
|
||||
SetAndGetJson( "1.234e5",1.234e5);
|
||||
SetAndGetJson( "1.2345E10",1.2345E10);
|
||||
SetAndGetJson( "-7.576E-05",-7.576E-05);
|
||||
SetAndGetJson( "1.23456e20",1.23456e20);
|
||||
SetAndGetJson( "5e+20",5e+20);
|
||||
SetAndGetJson( "5e-200",5e-200);
|
||||
SetAndGetJson( "9.1093822E-31",9.1093822E-31);
|
||||
SetAndGetJson( "5.9736e24",5.9736e24);
|
||||
SetAndGetJson("max float number as double", (double)float.MaxValue);
|
||||
SetAndGetJson("min float number as double", (double)float.MinValue);
|
||||
SetAndGetJson("double MaxValue", double.MaxValue);
|
||||
SetAndGetJson( "double MinValue",double.MinValue);
|
||||
SetAndGetJson( "double Epsilon",double.Epsilon);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestString()
|
||||
{
|
||||
SetAndGetJson("space", new DataToken(" "));
|
||||
SetAndGetJson("backspace", new DataToken("\b"));
|
||||
SetAndGetJson("form feed", new DataToken("\f"));
|
||||
SetAndGetJson("newline", new DataToken("\n"));
|
||||
SetAndGetJson("carriage return", new DataToken("\r"));
|
||||
SetAndGetJson("tab", new DataToken("\t"));
|
||||
SetAndGetJson("quotes", new DataToken("\""));
|
||||
SetAndGetJson("non breaking space", new DataToken("\u00A0"));
|
||||
SetAndGetJson("victory hand", new DataToken("✌"));
|
||||
SetAndGetJson("mandarin", new DataToken("䉟"));
|
||||
SetAndGetJson("greater than", new DataToken(">"));
|
||||
SetAndGetJson("emoji", new DataToken("🎶"));
|
||||
}
|
||||
[Test]
|
||||
public void RecursiveSerialization()
|
||||
{
|
||||
DataList a = new DataList();
|
||||
a.Add(1);
|
||||
a.Add(2);
|
||||
a.Add(3);
|
||||
|
||||
DataList b = new DataList();
|
||||
b.Add(1);
|
||||
b.Add(2);
|
||||
b.Add(3);
|
||||
|
||||
b.Add(a);
|
||||
a.Add(b);
|
||||
|
||||
Assert.IsFalse(VRCJson.TrySerializeToJson(a, JsonExportType.Beautify, out DataToken result), "should fail serialization because it's recursive");
|
||||
|
||||
b.Remove(a);
|
||||
|
||||
Assert.IsTrue(VRCJson.TrySerializeToJson(a, JsonExportType.Beautify, out result), "Should succeed serialization because it's not recursive");
|
||||
|
||||
a.Add(b);
|
||||
|
||||
Assert.IsTrue(VRCJson.TrySerializeToJson(a, JsonExportType.Beautify, out result), "Should succeed serialization because it's not recursive, even if it contains multiple copies of the same container");
|
||||
|
||||
}
|
||||
|
||||
private void SetAndGetJson(string title, DataToken inToken)
|
||||
{
|
||||
SerializeDictionary(title + " through serialization", inToken);
|
||||
SerializeList(title + " through serialization", inToken);
|
||||
}
|
||||
private void SerializeDictionary(string title, DataToken inToken)
|
||||
{
|
||||
DataDictionary dataDictionary = new DataDictionary();
|
||||
dataDictionary.SetValue("key", inToken);
|
||||
|
||||
Assert.IsTrue(VRCJson.TrySerializeToJson(dataDictionary, JsonExportType.Minify, out DataToken serialized), $"{title} failed to serialize to JSON with error ({serialized})");
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(serialized.String, out DataToken deserialized), $"failed to deserialize JSON {serialized.ToString()} with error {deserialized} ");
|
||||
Assert.IsTrue(deserialized.DataDictionary.TryGetValue("key", out DataToken outToken), $"{title} failed to get value with error {outToken}");
|
||||
CompareTokens(title, inToken, outToken);
|
||||
}
|
||||
private void SerializeList(string title, DataToken inToken)
|
||||
{
|
||||
DataList dataList = new DataList();
|
||||
dataList.Add(inToken);
|
||||
|
||||
Assert.IsTrue(VRCJson.TrySerializeToJson(dataList, JsonExportType.Minify, out DataToken serialized), $"{title} failed to serialize to JSON ({serialized})");
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(serialized.String, out DataToken deserialized), $"failed to deserialize JSON {serialized.ToString()} with error {deserialized} ");
|
||||
Assert.IsTrue(deserialized.DataList.TryGetValue(0, out DataToken outToken), $"{title} Failed to get value with error {outToken}");
|
||||
CompareTokens(title, inToken, outToken);
|
||||
}
|
||||
|
||||
private void CompareTokens(string title, DataToken a, DataToken b)
|
||||
{
|
||||
|
||||
if (a.TokenType == TokenType.Float)
|
||||
{
|
||||
Assert.IsTrue(Mathf.Approximately(a.Float, Convert.ToSingle(b.Double)), $"{title} Input ({a.Float.ToString("G")}) and output ({b.Double.ToString("G")}) tokens were not the same");
|
||||
}
|
||||
else if (a.IsNumber)
|
||||
{
|
||||
Assert.IsTrue(Approximately(a.Double, b.Double), $"{title} Input ({a.Double.ToString("G")}) and output ({b.Number.ToString("G")}) tokens were not the same");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.AreEqual(expected: a, b, $"{title} Input ({a}) and output ({b}) tokens were not the same");
|
||||
}
|
||||
}
|
||||
private bool Approximately(double a, double b)
|
||||
{
|
||||
if (Math.Sign(a) != Math.Sign(b)) return false;
|
||||
a = Math.Abs(a);
|
||||
b = Math.Abs(b);
|
||||
double max = Math.Max(a, b);
|
||||
return a - b < Math.Max(max / 100000000000, 0.1f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnsupportedNumbers()
|
||||
{
|
||||
ShouldFailSerialization(new DataList() {float.NaN}, DataError.ValueUnsupported);
|
||||
ShouldFailSerialization(new DataList() {float.NegativeInfinity}, DataError.ValueUnsupported);
|
||||
ShouldFailSerialization(new DataList() {float.PositiveInfinity }, DataError.ValueUnsupported);
|
||||
ShouldFailSerialization(new DataList() {double.NaN}, DataError.ValueUnsupported);
|
||||
ShouldFailSerialization(new DataList() {double.NegativeInfinity}, DataError.ValueUnsupported);
|
||||
ShouldFailSerialization(new DataList() {double.PositiveInfinity}, DataError.ValueUnsupported);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnsupportedReferences()
|
||||
{
|
||||
ShouldFailSerialization(new DataList() {new DataToken(new bool[]{false, true, false})}, DataError.TypeUnsupported);
|
||||
ShouldFailSerialization(new DataList() {new DataToken(DateTime.Now)}, DataError.TypeUnsupported);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnsupportedDictionaryKeys()
|
||||
{
|
||||
ShouldFailSerialization(new DataDictionary() { [312] = "value" }, DataError.TypeUnsupported);
|
||||
ShouldFailSerialization(new DataDictionary() { [true] = "value" }, DataError.TypeUnsupported);
|
||||
ShouldFailSerialization(new DataDictionary() { [false] = "value" }, DataError.TypeUnsupported);
|
||||
ShouldFailSerialization(new DataDictionary() { [5.432f] = "value" }, DataError.TypeUnsupported);
|
||||
ShouldFailSerialization(new DataDictionary() { [new DataList()] = "value" }, DataError.TypeUnsupported);
|
||||
}
|
||||
|
||||
private void ShouldFailSerialization(DataToken token, DataError expectedError)
|
||||
{
|
||||
Assert.IsFalse(VRCJson.TrySerializeToJson(token, JsonExportType.Minify, out DataToken result), "Should fail to serialize");
|
||||
Assert.AreEqual(result, expectedError, $"Resulting error should be {expectedError}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGoodJsonArrays()
|
||||
{
|
||||
ValidateJsonList("[]", new DataToken[]{});
|
||||
ValidateJsonList("[\"value\"]", new DataToken[]{"value"});
|
||||
ValidateJsonList("[\"value1\", \"value2\",\"value3\"]", new DataToken[]{"value1", "value2", "value3"});
|
||||
ValidateJsonList("[1]", new DataToken[]{1});
|
||||
ValidateJsonList("[1, 2, 3]", new DataToken[]{1, 2, 3});
|
||||
ValidateJsonList("[1, 2, 3,]", new DataToken[]{1, 2, 3});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGoodJsonObjects()
|
||||
{
|
||||
ValidateJsonObject("{}", new DataToken[]{}, new DataToken[] {});
|
||||
ValidateJsonObject("{\"key\":\"value\"}", new DataToken[]{"key"}, new DataToken[] {"value"});
|
||||
ValidateJsonObject("{\"key\": \"value\",}", new DataToken[] {"key"}, new DataToken[] {"value"});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGoodJsonTokens()
|
||||
{
|
||||
ValidateJsonToken("[\"\\u0020\"]", " ");
|
||||
ValidateJsonToken("[\"\\u00A9\"]", "©");
|
||||
ValidateJsonToken("[\"\\u00E9\"]", "é");
|
||||
ValidateJsonToken("[\"\\u3042\"]", "あ");
|
||||
ValidateJsonToken("[true]", true);
|
||||
ValidateJsonToken("[false]", false);
|
||||
ValidateJsonToken("[null]", new DataToken());
|
||||
ValidateJsonToken( $"[{double.MaxValue.ToString(CultureInfo.InvariantCulture).Replace("+", "")}]", double.MaxValue);
|
||||
ValidateJsonToken( $"[{double.MinValue.ToString(CultureInfo.InvariantCulture).Replace("+", "")}]", double.MinValue);
|
||||
ValidateJsonToken( $"[{double.Epsilon.ToString(CultureInfo.InvariantCulture).Replace("+", "")}]", double.Epsilon);
|
||||
}
|
||||
|
||||
private void ValidateJsonList(string input, DataToken[] expectedTokens)
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(input, out DataToken list), $"Attempting to deserialize {input}");
|
||||
Assert.AreEqual(list.TokenType, TokenType.DataList, $"Comparing type of {input}");
|
||||
Assert.AreEqual(list.DataList.Count, expectedTokens.Length, $"Comparing count of {input}");
|
||||
for (int i = 0; i < list.DataList.Count; i++)
|
||||
{
|
||||
Assert.IsTrue(list.DataList.TryGetValue(i, out DataToken value), $"Attempting to get value {i} from {input}, hit {value.Error}");
|
||||
CompareTokens($"Comparing token {i} in {input}", value, expectedTokens[i]);
|
||||
}
|
||||
}
|
||||
private void ValidateJsonObject(string input, DataToken[] expectedKeys, DataToken[] expectedValues)
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(input, out DataToken dictionary), $"Attempting to deserialize {input}");
|
||||
Assert.AreEqual(dictionary.TokenType, TokenType.DataDictionary, $"Comparing type of {input}");
|
||||
Assert.AreEqual(dictionary.DataDictionary.Count, expectedValues.Length, $"Comparing count of {input}");
|
||||
DataList keys = dictionary.DataDictionary.GetKeys();
|
||||
for (int i = 0; i < dictionary.DataDictionary.Count; i++)
|
||||
{
|
||||
CompareTokens($"comparing key {i}", expectedKeys[i], keys[i]);
|
||||
Assert.IsTrue(dictionary.DataDictionary.TryGetValue(keys[i], out DataToken value), $"Attempting to get value {keys[i]} from {input}, hit {value.Error}");
|
||||
CompareTokens($"Comparing token {keys[i]} in {input}", value, expectedValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateJsonToken(string input, DataToken token)
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(input, out DataToken list), $"Attempting to deserialize {input}");
|
||||
Assert.AreEqual(list.TokenType, TokenType.DataList);
|
||||
Assert.AreEqual(list.DataList.Count, 1);
|
||||
Assert.IsTrue(list.DataList.TryGetValue(0, out DataToken value));
|
||||
CompareTokens($"comparing token {token} against json {input}",value, token);
|
||||
}
|
||||
|
||||
[Repeat(32)]
|
||||
[Test]
|
||||
public void GenerateGarbage()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
sb.Insert(Random.Range(0, sb.Length), (char)j);
|
||||
ShouldFailToDeserialize(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// bad JSON objects:
|
||||
[TestCase(null, DataError.UnableToParse)]
|
||||
[TestCase("a", DataError.TypeUnsupported)]
|
||||
[TestCase("\"", DataError.TypeUnsupported)]
|
||||
[TestCase("{", DataError.UnableToParse)]
|
||||
[TestCase("}", DataError.TypeUnsupported)]
|
||||
[TestCase("{\"key\"}", DataError.UnableToParse)]
|
||||
[TestCase("{key: 1}", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\":}", DataError.UnableToParse)]
|
||||
[TestCase("{\"unfinished", DataError.UnableToParse)]
|
||||
[TestCase("{\"unfinished\":", DataError.UnableToParse)]
|
||||
[TestCase("{\"unfinished\":\"", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\":\"unfinished string}", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\":\"unfinished object\"", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\":\"bad brackets\"{", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\": +1121}", DataError.UnableToParse)]
|
||||
[TestCase("{\"key\":\"copy\",\"key\":\"duplicate\"}", DataError.UnableToParse)]
|
||||
// bad JSON arrays:
|
||||
[TestCase("[\"", DataError.UnableToParse)]
|
||||
[TestCase("\"]", DataError.TypeUnsupported)]
|
||||
[TestCase("[\"a", DataError.UnableToParse)]
|
||||
[TestCase("a\"]", DataError.TypeUnsupported)]
|
||||
[TestCase("[\"unfinished string]", DataError.UnableToParse)]
|
||||
[TestCase("[\"unfinished array\"", DataError.UnableToParse)]
|
||||
[TestCase("[\"bad brackets\"[", DataError.UnableToParse)]
|
||||
public void ShouldFailToDeserialize(string input, DataError? expectedDataError = null)
|
||||
{
|
||||
Assert.IsFalse(VRCJson.TryDeserializeFromJson(input, out DataToken result), $"Should fail to deserialize {input}");
|
||||
if (expectedDataError.HasValue)
|
||||
{
|
||||
Assert.IsTrue(result == expectedDataError.Value, $"Expected data error was {expectedDataError.Value}, result was actually \"{result}\"");
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("\"\\u00zz\"")]
|
||||
[TestCase("\"\\uD800\"")]
|
||||
[TestCase("1.0e+")]
|
||||
[TestCase("1.0e")]
|
||||
[TestCase("110+21")]
|
||||
[TestCase("11-21")]
|
||||
[TestCase("1121e")]
|
||||
[TestCase("--1121")]
|
||||
[TestCase("tru")]
|
||||
[TestCase("fa")]
|
||||
public void ShouldFailToParseDictionaryValue(string valueString)
|
||||
{
|
||||
string input = $"{{\"key\": {valueString}}}";
|
||||
Assert.IsTrue(VRCJson.TryDeserializeFromJson(input, out DataToken result), $"Should deserialize {input}");
|
||||
Assert.IsFalse(result.DataDictionary.TryGetValue("key", out DataToken value), $"should fail to parse {input}, instead resulted in {value}");
|
||||
Assert.AreEqual(DataError.UnableToParse, value, $"Resulting error should be {DataError.UnableToParse}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeToJson()
|
||||
{
|
||||
//MINIFY
|
||||
//lists
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {true, false, true}, "[true,false,true]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {"a", "b", "c"}, "[\"a\",\"b\",\"c\"]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {new DataToken(), new DataToken(), new DataToken()}, "[null,null,null]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(byte)1, (byte)2, (byte)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(sbyte)1, (sbyte)2, (sbyte)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(short)1, (short)2, (short)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(ushort)1, (ushort)2, (ushort)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(int)1, (int)2, (int)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(uint)1, (uint)2, (uint)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(long)1, (long)2, (long)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(ulong)1, (ulong)2, (ulong)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(float)1, (float)2, (float)3}, "[1,2,3]");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList() {(double)1, (double)2, (double)3}, "[1,2,3]");
|
||||
//Lists inside list
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList()
|
||||
{
|
||||
new DataList(){1, 2, 3},
|
||||
new DataList() {4, 5, 6},
|
||||
new DataList() {7, 8, 9}
|
||||
}, "[[1,2,3],[4,5,6],[7,8,9]]");
|
||||
//Dictionaries inside list
|
||||
ShouldSerialize(JsonExportType.Minify,new DataList()
|
||||
{
|
||||
new DataDictionary() {["a"]=1, ["b"]=2, ["c"]=3},
|
||||
new DataDictionary() {["d"]=4, ["e"]=5, ["f"]=6},
|
||||
new DataDictionary() {["g"]=7, ["h"]=8, ["i"]=9}
|
||||
}, "[{\"a\":1,\"b\":2,\"c\":3},{\"d\":4,\"e\":5,\"f\":6},{\"g\":7,\"h\":8,\"i\":9}]");
|
||||
|
||||
//dictionaries
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=true, ["b"]=false, ["c"]=true}, "{\"a\":true,\"b\":false,\"c\":true}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"}, "{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=new DataToken(), ["b"]=new DataToken(), ["c"]=new DataToken()}, "{\"a\":null,\"b\":null,\"c\":null}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(byte)1, ["b"]=(byte)2, ["c"]=(byte)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(sbyte)1, ["b"]=(sbyte)2, ["c"]=(sbyte)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(short)1, ["b"]=(short)2, ["c"]=(short)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(ushort)1, ["b"]=(ushort)2, ["c"]=(ushort)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(int)1, ["b"]=(int)2, ["c"]=(int)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(uint)1, ["b"]=(uint)2, ["c"]=(uint)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(long)1, ["b"]=(long)2, ["c"]=(long)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(ulong)1, ["b"]=(ulong)2, ["c"]=(ulong)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(float)1, ["b"]=(float)2, ["c"]=(float)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {["a"]=(double)1, ["b"]=(double)2, ["c"]=(double)3}, "{\"a\":1,\"b\":2,\"c\":3}");
|
||||
//Lists inside dictionary
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary()
|
||||
{
|
||||
["a"]=new DataList() {1, 2, 3},
|
||||
["b"]=new DataList() {4, 5, 6},
|
||||
["c"]=new DataList() {7, 8, 9}
|
||||
}, "{\"a\":[1,2,3],\"b\":[4,5,6],\"c\":[7,8,9]}");
|
||||
//Dictionaries inside dictionary
|
||||
ShouldSerialize(JsonExportType.Minify,new DataDictionary() {
|
||||
["a"]=new DataDictionary() { ["a"]=1, ["b"]=2, ["c"]=3 },
|
||||
["b"]=new DataDictionary() {["d"]=4, ["e"]=5, ["f"]=6},
|
||||
["c"]=new DataDictionary() {["g"]=7, ["h"]=8, ["i"]=9}},
|
||||
"{\"a\":{\"a\":1,\"b\":2,\"c\":3},\"b\":{\"d\":4,\"e\":5,\"f\":6},\"c\":{\"g\":7,\"h\":8,\"i\":9}}");
|
||||
|
||||
//BEAUTIFY
|
||||
//lists
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {true, false, true}, "[\n\ttrue,\n\tfalse,\n\ttrue\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {"a", "b", "c"}, "[\n\t\"a\",\n\t\"b\",\n\t\"c\"\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {new DataToken(), new DataToken(), new DataToken()}, "[\n\tnull,\n\tnull,\n\tnull\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(byte)1, (byte)2, (byte)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(sbyte)1, (sbyte)2, (sbyte)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(short)1, (short)2, (short)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(ushort)1, (ushort)2, (ushort)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(int)1, (int)2, (int)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(uint)1, (uint)2, (uint)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(long)1, (long)2, (long)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(ulong)1, (ulong)2, (ulong)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(float)1, (float)2, (float)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList() {(double)1, (double)2, (double)3}, "[\n\t1,\n\t2,\n\t3\n]");
|
||||
//Lists inside list
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList()
|
||||
{
|
||||
new DataList(){1, 2, 3},
|
||||
new DataList() {4, 5, 6},
|
||||
new DataList() {7, 8, 9}
|
||||
}, "[\n\t[\n\t\t1,\n\t\t2,\n\t\t3\n\t],\n\t[\n\t\t4,\n\t\t5,\n\t\t6\n\t],\n\t[\n\t\t7,\n\t\t8,\n\t\t9\n\t]\n]");
|
||||
//Dictionaries inside list
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataList()
|
||||
{
|
||||
new DataDictionary() {["a"]=1, ["b"]=2, ["c"]=3},
|
||||
new DataDictionary() {["d"]=4, ["e"]=5, ["f"]=6},
|
||||
new DataDictionary() {["g"]=7, ["h"]=8, ["i"]=9}
|
||||
}, "[\n\t{\n\t\t\"a\": 1,\n\t\t\"b\": 2,\n\t\t\"c\": 3\n\t},\n\t{\n\t\t\"d\": 4,\n\t\t\"e\": 5,\n\t\t\"f\": 6\n\t},\n\t{\n\t\t\"g\": 7,\n\t\t\"h\": 8,\n\t\t\"i\": 9\n\t}\n]");
|
||||
|
||||
//Dictionaries
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=true, ["b"]=false, ["c"]=true}, "{\n\t\"a\": true,\n\t\"b\": false,\n\t\"c\": true\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]="a", ["b"]="b", ["c"]="c"}, "{\n\t\"a\": \"a\",\n\t\"b\": \"b\",\n\t\"c\": \"c\"\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=new DataToken(), ["b"]=new DataToken(), ["c"]=new DataToken()}, "{\n\t\"a\": null,\n\t\"b\": null,\n\t\"c\": null\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(byte)1, ["b"]=(byte)2, ["c"]=(byte)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(sbyte)1, ["b"]=(sbyte)2, ["c"]=(sbyte)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(short)1, ["b"]=(short)2, ["c"]=(short)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(ushort)1, ["b"]=(ushort)2, ["c"]=(ushort)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(int)1, ["b"]=(int)2, ["c"]=(int)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(uint)1, ["b"]=(uint)2, ["c"]=(uint)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(long)1, ["b"]=(long)2, ["c"]=(long)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(ulong)1, ["b"]=(ulong)2, ["c"]=(ulong)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(float)1, ["b"]=(float)2, ["c"]=(float)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {["a"]=(double)1, ["b"]=(double)2, ["c"]=(double)3}, "{\n\t\"a\": 1,\n\t\"b\": 2,\n\t\"c\": 3\n}");
|
||||
//Lists inside dictionary
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary()
|
||||
{
|
||||
["a"]=new DataList() {1, 2, 3},
|
||||
["b"]=new DataList() {4, 5, 6},
|
||||
["c"]=new DataList() {7, 8, 9}
|
||||
}, "{\n\t\"a\": [\n\t\t1,\n\t\t2,\n\t\t3\n\t],\n\t\"b\": [\n\t\t4,\n\t\t5,\n\t\t6\n\t],\n\t\"c\": [\n\t\t7,\n\t\t8,\n\t\t9\n\t]\n}");
|
||||
//Dictionaries inside dictionary
|
||||
ShouldSerialize(JsonExportType.Beautify,new DataDictionary() {
|
||||
["a"]=new DataDictionary() { ["a"]=1, ["b"]=2, ["c"]=3 },
|
||||
["b"]=new DataDictionary() {["d"]=4, ["e"]=5, ["f"]=6},
|
||||
["c"]=new DataDictionary() {["g"]=7, ["h"]=8, ["i"]=9}},
|
||||
"{\n\t\"a\": {\n\t\t\"a\": 1,\n\t\t\"b\": 2,\n\t\t\"c\": 3\n\t},\n\t\"b\": {\n\t\t\"d\": 4,\n\t\t\"e\": 5,\n\t\t\"f\": 6\n\t},\n\t\"c\": {\n\t\t\"g\": 7,\n\t\t\"h\": 8,\n\t\t\"i\": 9\n\t}\n}");
|
||||
}
|
||||
|
||||
private void ShouldSerialize(JsonExportType type, DataToken token, string expected)
|
||||
{
|
||||
Assert.IsTrue(VRCJson.TrySerializeToJson(token, type, out DataToken result));
|
||||
Assert.AreEqual(expected, result.String);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cccff2f4f65049041acd7bc5eaa352e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user