/** * Test a Voxel class. */ public static void Test() { //Console.WriteLine("Start Voxel TEST"); Voxel voxel; long timestamp = Util.currentTimeNanos(); int id = 2000000; voxel = new Voxel(timestamp); Util.Assert(voxel.getTimestamp() == timestamp); Util.Assert(voxel.getId() == -1); voxel.setId(id); Util.Assert(voxel.getId() == id); timestamp += 52; voxel.setTimestamp(timestamp); Util.Assert(voxel.getTimestamp() == timestamp); voxel = new Voxel(id, timestamp); Util.Assert(voxel.getTimestamp() == timestamp); Util.Assert(voxel.getId() == id); List <Voxel> voxels = new List <Voxel>(); voxels.Add(new Voxel(3, 2400)); voxels.Add(new Voxel(2, 1000)); voxels.Add(new Voxel(1, 3200)); voxels.Add(new Voxel(0, 1000)); voxels.Sort(Voxel.Compare); Util.Assert(Voxel.Compare(voxels[0], new Voxel(0, 1000)) == 0); // "== 0" means same value Util.Assert(Voxel.Compare(voxels[1], new Voxel(2, 1000)) == 0); Util.Assert(Voxel.Compare(voxels[2], new Voxel(3, 2400)) == 0); Util.Assert(Voxel.Compare(voxels[3], new Voxel(1, 3200)) == 0); //foreach (Voxel v in voxels) { Console.WriteLine(v.Tostring()); } //Console.WriteLine("End Voxel TEST"); }
/** * Test a Voxel class. */ public static void Test() { //Debug.Log("Start Voxel TEST"); Voxel voxel; long timestamp = Util.currentTimeNanos(); int id = 2000000; voxel = new Voxel(timestamp); Debug.Assert(voxel.getTimestamp() == timestamp); Debug.Assert(voxel.getId() == -1); voxel.setId(id); Debug.Assert(voxel.getId() == id); timestamp += 52; voxel.setTimestamp(timestamp); Debug.Assert(voxel.getTimestamp() == timestamp); voxel = new Voxel(id, 3, timestamp); Debug.Assert(voxel.getTimestamp() == timestamp); Debug.Assert(voxel.getId() == id); List <Voxel> voxels = new List <Voxel>(); voxels.Add(new Voxel(3, 6, 2400)); voxels.Add(new Voxel(2, 5, 1000)); voxels.Add(new Voxel(1, 5, 3200)); voxels.Add(new Voxel(0, 2, 1000)); voxels.Sort(Voxel.Compare); Debug.Assert(Voxel.Compare(voxels[0], new Voxel(0, 1, 1000)) == 0); // "== 0" means same value Debug.Assert(Voxel.Compare(voxels[1], new Voxel(2, 2, 1000)) == 0); Debug.Assert(Voxel.Compare(voxels[2], new Voxel(3, 2, 2400)) == 0); Debug.Assert(Voxel.Compare(voxels[3], new Voxel(1, 4, 3200)) == 0); //foreach (Voxel v in voxels) { Debug.Log(v.Tostring()); } Debug.Log("End a Voxel class test"); }