Added SDL_SetBooleanProperty() and SDL_GetBooleanProperty()
This commit is contained in:
@@ -32,6 +32,7 @@ static int properties_testBasic(void *arg)
|
||||
const char *value_string;
|
||||
Sint64 value_number;
|
||||
float value_float;
|
||||
SDL_bool value_bool;
|
||||
int i, result, count;
|
||||
|
||||
props = SDL_CreateProperties();
|
||||
@@ -87,6 +88,9 @@ 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");
|
||||
|
||||
/* Check data value */
|
||||
SDLTest_AssertPass("Call to SDL_SetProperty(\"foo\", 0x01)");
|
||||
@@ -106,6 +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");
|
||||
|
||||
/* Check string value */
|
||||
SDLTest_AssertPass("Call to SDL_SetStringProperty(\"foo\", \"bar\")");
|
||||
@@ -125,6 +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_FALSE,
|
||||
"Verify boolean property, expected SDL_FALSE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check number value */
|
||||
SDLTest_AssertPass("Call to SDL_SetNumberProperty(\"foo\", 1)");
|
||||
@@ -144,9 +154,12 @@ 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");
|
||||
|
||||
/* Check float value */
|
||||
SDLTest_AssertPass("Call to SDL_SetNumberProperty(\"foo\", 1)");
|
||||
SDLTest_AssertPass("Call to SDL_SetFloatProperty(\"foo\", 1)");
|
||||
SDL_SetFloatProperty(props, "foo", 1.0f);
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_FLOAT,
|
||||
@@ -163,6 +176,31 @@ static int properties_testBasic(void *arg)
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 1.0f,
|
||||
"Verify string property, expected 1, 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");
|
||||
|
||||
/* Check boolean value */
|
||||
SDLTest_AssertPass("Call to SDL_SetBooleanProperty(\"foo\", SDL_TRUE)");
|
||||
SDL_SetBooleanProperty(props, "foo", SDL_TRUE);
|
||||
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);
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property, expected NULL, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string == NULL,
|
||||
"Verify string property, expected NULL, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 0,
|
||||
"Verify number property, expected 0, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 0.0f,
|
||||
"Verify string 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");
|
||||
|
||||
/* Make sure we have exactly one property named foo */
|
||||
count = 0;
|
||||
|
||||
Reference in New Issue
Block a user