Wes xx build fix

This commit is contained in:
Dries Van Schuylenbergh
2023-03-09 12:44:11 +00:00
committed by Louis Adriaens
parent 601cf38c61
commit 2fa54620ef
74 changed files with 1009 additions and 214 deletions

View File

@@ -1,176 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;
public class TestProgress : MonoBehaviour
{
[Serializable]
// Dummy struct
private struct SerializableStruct
{
public int r, g, b;
public float x, y, z;
}
private struct NonSerializableStruct
{
public int r, g, b;
public float x, y, z;
}
// Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException`
private bool AddNonSerializableStruct()
{
Progress progress = new Progress();
NonSerializableStruct nss = new NonSerializableStruct();
try { progress.AddOrUpdate<NonSerializableStruct>("key", nss); }
catch (SerializationException) { return true; }
return false;
}
// Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException`
private bool AccessInvalidKey()
{
Progress progress = new Progress();
try { progress.Get<int>("non-existing key"); }
catch (KeyNotFoundException) { return true; }
return false;
}
// Helper method, returns true if `Progress.Get(...)` throws a `InvalidCastException`
private bool AccessInvalidType()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 123456789);
try { progress.Get<double>("key"); }
catch (InvalidCastException) { return true; }
return false;
}
void Start()
{
TestNewProgress();
TestProgressAddInvalidData();
TestProgressAddDuplicateKey();
TestProgressAddInt();
TestProgressAddDouble();
TestProgressAddString();
TestProgressAddSerializableStruct();
TestProgressAddNonSerializableStruct();
TestProgressGetInvalidKey();
TestProgressGetInvalidType();
TestProgressUpdate();
TestProgressGetInt();
TestProgressGetDouble();
TestProgressGetString();
TestProgressGetStruct();
}
public void TestNewProgress()
{
Progress progress = new Progress();
Debug.Assert(progress != null);
}
public void TestProgressAddInvalidData()
{
Progress progress = new Progress();
Debug.Assert(!progress.AddOrUpdate<GameObject>("key", null));
}
public void TestProgressAddDuplicateKey()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key 1", 0);
Debug.Assert(progress.AddOrUpdate<int>("key 1", 1));
}
public void TestProgressAddInt()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<int>("key", 1));
}
public void TestProgressAddDouble()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<double>("key", 1.0));
}
public void TestProgressAddString()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<string>("key", "Hello World!"));
}
public void TestProgressAddSerializableStruct()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<SerializableStruct>("key", new SerializableStruct()));
}
public void TestProgressAddNonSerializableStruct()
{
Debug.Assert(AddNonSerializableStruct());
}
public void TestProgressGetInvalidKey()
{
Debug.Assert(AccessInvalidKey());
}
public void TestProgressGetInvalidType()
{
Debug.Assert(AccessInvalidType());
}
public void TestProgressUpdate()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 1);
Debug.Assert(progress.Get<int>("key") == 1);
progress.AddOrUpdate<int>("key", 2);
Debug.Assert(progress.Get<int>("key") == 2);
}
public void TestProgressGetInt()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 1);
Debug.Assert(progress.Get<int>("key") == 1);
}
public void TestProgressGetDouble()
{
Progress progress = new Progress();
progress.AddOrUpdate<double>("key", 1.0);
Debug.Assert(progress.Get<double>("key") == 1.0);
}
public void TestProgressGetString()
{
Progress progress = new Progress();
progress.AddOrUpdate<string>("key", "Hello World!");
Debug.Assert(progress.Get<string>("key") == "Hello World!");
}
public void TestProgressGetStruct()
{
Progress progress = new Progress();
int R = 1, G = 10, B = 100;
float X = 0.1f, Y = 0.01f, Z = 0.001f;
SerializableStruct data = new SerializableStruct { r = R, g = G, b = B, x = X, y = Y, z = Z };
progress.AddOrUpdate<SerializableStruct>("key", data);
SerializableStruct result = progress.Get<SerializableStruct>("key");
Debug.Assert(result.r == R);
Debug.Assert(result.g == G);
Debug.Assert(result.b == B);
Debug.Assert(result.x == X);
Debug.Assert(result.y == Y);
Debug.Assert(result.z == Z);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 49445c42f43d1bb488f588623826a39e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestUserCreationScreen : MonoBehaviour
{
void Start()
{
TestIsValidUsernameTrue();
TestIsValidUsernameFalse();
}
public void TestIsValidUsernameTrue()
{
foreach (char c in "abcdefghijklmnopqrstuvwxyz")
Debug.Assert(UserCreationScreen.IsValidUsername(c.ToString()));
Debug.Assert(UserCreationScreen.IsValidUsername("abcdefghijkl"));
}
public void TestIsValidUsernameFalse()
{
Debug.Assert(!UserCreationScreen.IsValidUsername(string.Empty));
foreach (char c in " \n\t0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-*/%_(){}[]\\")
Debug.Assert(!UserCreationScreen.IsValidUsername(c.ToString()));
Debug.Assert(!UserCreationScreen.IsValidUsername("abcdefghijklmnopqrstuvwxyz"));
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b6dabaf99e10900459274641f4cc9010
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: