/// <summary> /// Clears all testcase records from memory. /// </summary> public unsafe static void Dispose() { TestRecord *it = Records; while (it != null) { TestRecord *next = it->Next; MemoryManager.Free(it); it = next; } }
/// <summary> /// Gets the amount of test records that arve currently held. /// </summary> public unsafe static int GetTestCount() { int count = 0; TestRecord *it = Records; while (it != null) { it = it->Next; ++count; } return(count); }
/// <summary> /// Performs a new test, optionally printing it and/or recording it in memory. /// </summary> public unsafe static void Test(bool result, string source, string name) { CString8 *sourceStr = CString8.Copy(source); CString8 *nameStr = CString8.Copy(name); if (PrintTestcases) { Debug.COM1.Write(sourceStr); Debug.COM1.Write(": "); Debug.COM1.Write(nameStr); Debug.COM1.Write(" ... "); TextMode.SaveAttributes(); if (result) { Debug.COM1.WriteLine("PASS"); } else { Debug.COM1.WriteLine("FAIL"); } TextMode.RestoreAttributes(); } if (RecordTestcases) { TestRecord *rec = (TestRecord *)MemoryManager.Allocate((uint)sizeof(TestRecord)); rec->Source = sourceStr; rec->Name = nameStr; rec->Result = result; rec->Next = null; if (Records == null) { Records = rec; } else { GetLastTest()->Next = rec; } } else { MemoryManager.Free(sourceStr); MemoryManager.Free(nameStr); } }
/// <summary> /// Gets a test by it's numerical index. /// </summary> public unsafe static TestRecord *GetTest(int index) { int x = 0; TestRecord *it = Records; while (it != null && x < index) { it = it->Next; ++x; } if (x < index) { return(null); } return(it); }
/// <summary> /// Gets the last test record that is held. /// </summary> public unsafe static TestRecord *GetLastTest() { if (!RecordTestcases) { return(null); } if (Records == null) { return(null); } TestRecord *it = Records; while (it->Next != null) { it = it->Next; } return(it); }
/// <summary> /// Iterates over the record list. /// </summary> public unsafe static TestRecord *GetNextTest(TestRecord *rec) { Diagnostics.Assert(rec != null, "Testcase::GetNextTest(): argument `rec' is null"); return(rec->Next); }