Minor restructuring to tests.

This commit is contained in:
David Reid
2020-02-22 15:13:28 +10:00
parent 479503ec02
commit e5aaffc299
2 changed files with 38 additions and 37 deletions
+37
View File
@@ -0,0 +1,37 @@
#define MINIAUDIO_IMPLEMENTATION
#include "../../miniaudio.h"
#include <stdio.h>
#define MAX_TESTS 64
typedef int (* ma_test_entry_proc)(int argc, char** argv);
typedef struct
{
const char* pName;
ma_test_entry_proc onEntry;
} ma_test;
struct
{
ma_test pTests[MAX_TESTS];
size_t count;
} g_Tests;
ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
{
MA_ASSERT(pName != NULL);
MA_ASSERT(onEntry != NULL);
if (g_Tests.count >= MAX_TESTS) {
printf("Failed to register test %s because there are too many tests already registered. Increase the value of MAX_TESTS\n", pName);
return MA_INVALID_OPERATION;
}
g_Tests.pTests[g_Tests.count].pName = pName;
g_Tests.pTests[g_Tests.count].onEntry = onEntry;
g_Tests.count += 1;
return MA_SUCCESS;
}