You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// this class is for logic test.
|
|
/// if you build with this class, this class must be nothing to do.
|
|
/// </summary>
|
|
public class LogicTest : MonoBehaviour
|
|
{
|
|
#if UNITY_EDITOR
|
|
[SerializeField] int testCount = 1;
|
|
|
|
[ContextMenu("Method/LogicTest")]
|
|
public void SwapElementsTest()
|
|
{
|
|
int currentTestCount = 0;
|
|
while(currentTestCount++ < testCount)
|
|
{
|
|
List<int> list = new List<int>();
|
|
|
|
int rndSize = Random.Range(1, 10);
|
|
for (int i = 0; i < rndSize; ++i)
|
|
{
|
|
list.Add(Random.Range(0, 100));
|
|
}
|
|
|
|
string beforeSort = "Before swap : ";
|
|
for (int i = 0; i < list.Count; ++i)
|
|
{
|
|
beforeSort += list[i] + " ";
|
|
}
|
|
Logger.Log(beforeSort);
|
|
|
|
int result = list.SwapElements((e) => e > 50);
|
|
|
|
string afterSort = "After swap : ";
|
|
for (int i = 0; i < list.Count; ++i)
|
|
{
|
|
afterSort += list[i] + " ";
|
|
}
|
|
Logger.Log(afterSort);
|
|
|
|
Logger.Log("Result : " + result);
|
|
}
|
|
}
|
|
#endif
|
|
}
|