update SDL3 to latest commit

This commit is contained in:
Sasha Szpakowski
2024-10-06 20:30:44 -03:00
parent 1b0fdc338b
commit 9e5eb1b018
1426 changed files with 242456 additions and 103496 deletions
+71 -71
View File
@@ -23,7 +23,7 @@ static void SDLCALL count_foo_properties(void *userdata, SDL_PropertiesID props,
++(*count);
}
}
static int properties_testBasic(void *arg)
static int SDLCALL properties_testBasic(void *arg)
{
SDL_PropertiesID props;
char key[2], expected_value[2];
@@ -32,7 +32,7 @@ static int properties_testBasic(void *arg)
const char *value_string;
Sint64 value_number;
float value_float;
SDL_bool value_bool;
bool value_bool;
int i, result, count;
props = SDL_CreateProperties();
@@ -43,12 +43,12 @@ static int properties_testBasic(void *arg)
for (i = 0; i < 10; ++i) {
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i);
result = SDL_SetProperty(props, key, expected_value);
SDLTest_AssertPass("Call to SDL_SetProperty()");
SDLTest_AssertCheck(result == 0,
result = SDL_SetPointerProperty(props, key, expected_value);
SDLTest_AssertPass("Call to SDL_SetPointerProperty()");
SDLTest_AssertCheck(result == true,
"Verify property value was set, got: %d", result);
value = SDL_GetProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetProperty()");
value = SDL_GetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetPointerProperty()");
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, expected_value) == 0,
"Verify property value was set, got %s, expected %s", value ? (const char *)value : "NULL", expected_value);
}
@@ -60,12 +60,12 @@ static int properties_testBasic(void *arg)
for (i = 0; i < 10; ++i) {
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
result = SDL_SetProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_SetProperty(NULL)");
SDLTest_AssertCheck(result == 0,
result = SDL_SetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_SetPointerProperty(NULL)");
SDLTest_AssertCheck(result == true,
"Verify property value was set, got: %d", result);
value = SDL_GetProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetProperty()");
value = SDL_GetPointerProperty(props, key, NULL);
SDLTest_AssertPass("Call to SDL_GetPointerProperty()");
SDLTest_AssertCheck(value == NULL,
"Verify property value was set, got %s, expected NULL", (const char *)value);
}
@@ -76,7 +76,7 @@ static int properties_testBasic(void *arg)
"Verify property count, expected 0, got: %d", count);
/* Check default values */
value = SDL_GetProperty(props, "foo", (void *)0xabcd);
value = SDL_GetPointerProperty(props, "foo", (void *)0xabcd);
SDLTest_AssertCheck(value == (void *)0xabcd,
"Verify property, expected 0xabcd, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", "abcd");
@@ -88,17 +88,17 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 1234.0f);
SDLTest_AssertCheck(value_float == 1234.0f,
"Verify float property, expected 1234, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_TRUE);
SDLTest_AssertCheck(value_bool == SDL_TRUE,
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", true);
SDLTest_AssertCheck(value_bool == true,
"Verify boolean property, expected true, got: %s", value_bool ? "true" : "false");
/* Check data value */
SDLTest_AssertPass("Call to SDL_SetProperty(\"foo\", 0x01)");
SDL_SetProperty(props, "foo", (void *)0x01);
SDLTest_AssertPass("Call to SDL_SetPointerProperty(\"foo\", 0x01)");
SDL_SetPointerProperty(props, "foo", (void *)0x01);
type = SDL_GetPropertyType(props, "foo");
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_POINTER,
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_POINTER, type);
value = SDL_GetProperty(props, "foo", NULL);
value = SDL_GetPointerProperty(props, "foo", NULL);
SDLTest_AssertCheck(value == (void *)0x01,
"Verify property, expected 0x01, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", NULL);
@@ -110,9 +110,9 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
SDLTest_AssertCheck(value_float == 0.0f,
"Verify float property, expected 0, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
SDLTest_AssertCheck(value_bool == SDL_FALSE,
"Verify boolean property, expected SDL_FALSE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", false);
SDLTest_AssertCheck(value_bool == false,
"Verify boolean property, expected false, got: %s", value_bool ? "true" : "false");
/* Check string value */
SDLTest_AssertPass("Call to SDL_SetStringProperty(\"foo\", \"bar\")");
@@ -120,7 +120,7 @@ static int properties_testBasic(void *arg)
type = SDL_GetPropertyType(props, "foo");
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_STRING,
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_STRING, type);
value = SDL_GetProperty(props, "foo", NULL);
value = SDL_GetPointerProperty(props, "foo", NULL);
SDLTest_AssertCheck(value == NULL,
"Verify property, expected NULL, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", NULL);
@@ -132,9 +132,9 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
SDLTest_AssertCheck(value_float == 0.0f,
"Verify float property, expected 0, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
SDLTest_AssertCheck(value_bool == SDL_TRUE,
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", false);
SDLTest_AssertCheck(value_bool == true,
"Verify boolean property, expected true, got: %s", value_bool ? "true" : "false");
/* Check number value */
SDLTest_AssertPass("Call to SDL_SetNumberProperty(\"foo\", 1)");
@@ -142,7 +142,7 @@ static int properties_testBasic(void *arg)
type = SDL_GetPropertyType(props, "foo");
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_NUMBER,
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_NUMBER, type);
value = SDL_GetProperty(props, "foo", NULL);
value = SDL_GetPointerProperty(props, "foo", NULL);
SDLTest_AssertCheck(value == NULL,
"Verify property, expected NULL, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", NULL);
@@ -154,9 +154,9 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
SDLTest_AssertCheck(value_float == 1.0f,
"Verify float property, expected 1, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
SDLTest_AssertCheck(value_bool == SDL_TRUE,
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", false);
SDLTest_AssertCheck(value_bool == true,
"Verify boolean property, expected true, got: %s", value_bool ? "true" : "false");
/* Check float value */
SDLTest_AssertPass("Call to SDL_SetFloatProperty(\"foo\", 1)");
@@ -164,7 +164,7 @@ static int properties_testBasic(void *arg)
type = SDL_GetPropertyType(props, "foo");
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_FLOAT,
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_FLOAT, type);
value = SDL_GetProperty(props, "foo", NULL);
value = SDL_GetPointerProperty(props, "foo", NULL);
SDLTest_AssertCheck(value == NULL,
"Verify property, expected NULL, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", NULL);
@@ -176,17 +176,17 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
SDLTest_AssertCheck(value_float == 1.75f,
"Verify float property, expected 1.75, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
SDLTest_AssertCheck(value_bool == SDL_TRUE,
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", false);
SDLTest_AssertCheck(value_bool == true,
"Verify boolean property, expected true, got: %s", value_bool ? "true" : "false");
/* Check boolean value */
SDLTest_AssertPass("Call to SDL_SetBooleanProperty(\"foo\", SDL_TRUE)");
SDLTest_AssertPass("Call to SDL_SetBooleanProperty(\"foo\", true)");
SDL_SetBooleanProperty(props, "foo", 3); /* Note we're testing non-true/false value here */
type = SDL_GetPropertyType(props, "foo");
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_BOOLEAN,
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_BOOLEAN, type);
value = SDL_GetProperty(props, "foo", NULL);
value = SDL_GetPointerProperty(props, "foo", NULL);
SDLTest_AssertCheck(value == NULL,
"Verify property, expected NULL, got: %p", value);
value_string = SDL_GetStringProperty(props, "foo", NULL);
@@ -198,9 +198,9 @@ static int properties_testBasic(void *arg)
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
SDLTest_AssertCheck(value_float == 1.0f,
"Verify float property, expected 1, got: %f", value_float);
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
SDLTest_AssertCheck(value_bool == SDL_TRUE,
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
value_bool = SDL_GetBooleanProperty(props, "foo", false);
SDLTest_AssertCheck(value_bool == true,
"Verify boolean property, expected true, got: %s", value_bool ? "true" : "false");
/* Make sure we have exactly one property named foo */
count = 0;
@@ -219,7 +219,7 @@ static int properties_testBasic(void *arg)
static void SDLCALL copy_cleanup(void *userdata, void *value)
{
}
static int properties_testCopy(void *arg)
static int SDLCALL properties_testCopy(void *arg)
{
SDL_PropertiesID a, b;
int num;
@@ -230,26 +230,26 @@ static int properties_testCopy(void *arg)
a = SDL_CreateProperties();
SDL_SetNumberProperty(a, "num", 1);
SDL_SetStringProperty(a, "string", "foo");
SDL_SetProperty(a, "data", &a);
SDL_SetPropertyWithCleanup(a, "cleanup", &a, copy_cleanup, &a);
SDL_SetPointerProperty(a, "data", &a);
SDL_SetPointerPropertyWithCleanup(a, "cleanup", &a, copy_cleanup, &a);
b = SDL_CreateProperties();
SDL_SetNumberProperty(b, "num", 2);
SDLTest_AssertPass("Call to SDL_CopyProperties(a, 0)");
result = SDL_CopyProperties(a, 0);
SDLTest_AssertCheck(result == -1,
"SDL_CopyProperties() result, got %d, expected -1", result);
SDLTest_AssertCheck(result == false,
"SDL_CopyProperties() result, got %d, expected false", result);
SDLTest_AssertPass("Call to SDL_CopyProperties(0, b)");
result = SDL_CopyProperties(0, b);
SDLTest_AssertCheck(result == -1,
"SDL_CopyProperties() result, got %d, expected -1", result);
SDLTest_AssertCheck(result == false,
"SDL_CopyProperties() result, got %d, expected false", result);
SDLTest_AssertPass("Call to SDL_CopyProperties(a, b)");
result = SDL_CopyProperties(a, b);
SDLTest_AssertCheck(result == 0,
"SDL_CopyProperties() result, got %d, expected 0", result);
SDLTest_AssertCheck(result == true,
"SDL_CopyProperties() result, got %d, expected true", result);
SDL_DestroyProperties(a);
@@ -261,11 +261,11 @@ static int properties_testCopy(void *arg)
SDLTest_AssertCheck(string && SDL_strcmp(string, "foo") == 0,
"Checking string property, got \"%s\", expected \"foo\"", string);
data = SDL_GetProperty(b, "data", NULL);
data = SDL_GetPointerProperty(b, "data", NULL);
SDLTest_AssertCheck(data == &a,
"Checking data property, got %p, expected %p", data, &a);
data = SDL_GetProperty(b, "cleanup", NULL);
data = SDL_GetPointerProperty(b, "cleanup", NULL);
SDLTest_AssertCheck(data == NULL,
"Checking cleanup property, got %p, expected NULL", data);
@@ -282,7 +282,7 @@ static void SDLCALL cleanup(void *userdata, void *value)
int *count = (int *)userdata;
++(*count);
}
static int properties_testCleanup(void *arg)
static int SDLCALL properties_testCleanup(void *arg)
{
SDL_PropertiesID props;
char key[2], expected_value[2];
@@ -290,10 +290,10 @@ static int properties_testCleanup(void *arg)
props = SDL_CreateProperties();
SDLTest_AssertPass("Call to SDL_SetProperty(cleanup)");
SDLTest_AssertPass("Call to SDL_SetPointerProperty(cleanup)");
count = 0;
SDL_SetPropertyWithCleanup(props, "a", "0", cleanup, &count);
SDL_SetPropertyWithCleanup(props, "a", NULL, cleanup, &count);
SDL_SetPointerPropertyWithCleanup(props, "a", "0", cleanup, &count);
SDL_ClearProperty(props, "a");
SDLTest_AssertCheck(count == 1,
"Verify cleanup for deleting property, got %d, expected 1", count);
@@ -302,7 +302,7 @@ static int properties_testCleanup(void *arg)
for (i = 0; i < 10; ++i) {
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i);
SDL_SetPropertyWithCleanup(props, key, expected_value, cleanup, &count);
SDL_SetPointerPropertyWithCleanup(props, key, expected_value, cleanup, &count);
}
SDL_DestroyProperties(props);
SDLTest_AssertCheck(count == 10,
@@ -316,34 +316,34 @@ static int properties_testCleanup(void *arg)
*/
struct properties_thread_data
{
SDL_bool done;
bool done;
SDL_PropertiesID props;
};
static int properties_thread(void *arg)
static int SDLCALL properties_thread(void *arg)
{
struct properties_thread_data *data = (struct properties_thread_data *)arg;
while (!data->done) {
SDL_LockProperties(data->props);
SDL_SetProperty(data->props, "a", "thread_loop");
SDL_SetPointerProperty(data->props, "a", "thread_loop");
SDL_UnlockProperties(data->props);
}
SDL_LockProperties(data->props);
SDL_SetProperty(data->props, "a", "thread_done");
SDL_SetPointerProperty(data->props, "a", "thread_done");
SDL_UnlockProperties(data->props);
return 0;
}
static int properties_testLocking(void *arg)
static int SDLCALL properties_testLocking(void *arg)
{
struct properties_thread_data data;
SDL_Thread *thread;
void *value;
SDLTest_AssertPass("Testing property locking");
data.done = SDL_FALSE;
data.done = false;
data.props = SDL_CreateProperties();
SDLTest_AssertPass("Setting property to 'init'");
SDL_SetProperty(data.props, "a", "init");
SDL_SetPointerProperty(data.props, "a", "init");
thread = SDL_CreateThread(properties_thread, "properties_thread", &data);
if (thread) {
SDLTest_AssertPass("Waiting for property to change to 'thread_loop'");
@@ -351,7 +351,7 @@ static int properties_testLocking(void *arg)
{
SDL_Delay(10);
SDL_LockProperties(data.props);
value = SDL_GetProperty(data.props, "a", NULL);
value = SDL_GetPointerProperty(data.props, "a", NULL);
SDL_UnlockProperties(data.props);
if (!value || SDL_strcmp((const char *)value, "thread_loop") == 0) {
@@ -363,17 +363,17 @@ static int properties_testLocking(void *arg)
SDLTest_AssertPass("Setting property to 'main'");
SDL_LockProperties(data.props);
SDL_SetProperty(data.props, "a", "main");
SDL_SetPointerProperty(data.props, "a", "main");
SDL_Delay(100);
value = SDL_GetProperty(data.props, "a", NULL);
value = SDL_GetPointerProperty(data.props, "a", NULL);
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "main") == 0,
"After 100ms sleep, property is %s, expected 'main'", value ? (const char *)value : "NULL");
SDL_UnlockProperties(data.props);
data.done = SDL_TRUE;
data.done = true;
SDL_WaitThread(thread, NULL);
value = SDL_GetProperty(data.props, "a", NULL);
value = SDL_GetPointerProperty(data.props, "a", NULL);
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "thread_done") == 0,
"After thread complete, property is %s, expected 'thread_done'", value ? (const char *)value : "NULL");
}
@@ -386,19 +386,19 @@ static int properties_testLocking(void *arg)
/* Properties test cases */
static const SDLTest_TestCaseReference propertiesTestBasic = {
(SDLTest_TestCaseFp)properties_testBasic, "properties_testBasic", "Test basic property functionality", TEST_ENABLED
properties_testBasic, "properties_testBasic", "Test basic property functionality", TEST_ENABLED
};
static const SDLTest_TestCaseReference propertiesTestCopy = {
(SDLTest_TestCaseFp)properties_testCopy, "properties_testCopy", "Test property copy functionality", TEST_ENABLED
properties_testCopy, "properties_testCopy", "Test property copy functionality", TEST_ENABLED
};
static const SDLTest_TestCaseReference propertiesTestCleanup = {
(SDLTest_TestCaseFp)properties_testCleanup, "properties_testCleanup", "Test property cleanup functionality", TEST_ENABLED
properties_testCleanup, "properties_testCleanup", "Test property cleanup functionality", TEST_ENABLED
};
static const SDLTest_TestCaseReference propertiesTestLocking = {
(SDLTest_TestCaseFp)properties_testLocking, "properties_testLocking", "Test property locking functionality", TEST_ENABLED
properties_testLocking, "properties_testLocking", "Test property locking functionality", TEST_ENABLED
};
/* Sequence of Properties test cases */