Files
FreeRDP/libfreerdp/core/test/TestSettings.c
Armin Novak abc93f924c Added python generator for freerdp_[g|s]et_param*
The settings getters and setters are now automatically generated.
Added a test case to check if all available options can be retrieved.
2019-05-08 14:17:23 +02:00

148 lines
3.1 KiB
C

#include <freerdp/settings.h>
#include "settings_property_lists.h"
int TestSettings(int argc, char* argv[])
{
int rc = -1;
size_t x;
rdpSettings* settings = NULL;
rdpSettings* cloned;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
settings = freerdp_settings_new(0);
if (!settings)
{
printf("Couldn't create settings\n");
return -1;
}
settings->Username = _strdup("abcdefg");
settings->Password = _strdup("xyz");
cloned = freerdp_settings_clone(settings);
if (!cloned)
{
printf("Problem cloning settings\n");
freerdp_settings_free(settings);
return -1;
}
#if defined(have_bool_list_indices)
for (x = 0; x < ARRAYSIZE(bool_list_indices); x++)
{
const size_t key = bool_list_indices[x];
const BOOL val = freerdp_get_param_bool(settings, key);
if (!freerdp_set_param_bool(settings, key, val))
goto fail;
}
#endif
#if defined(have_int16_list_indices)
for (x = 0; x < ARRAYSIZE(int16_list_indices); x++)
{
const size_t key = int16_list_indices[x];
const INT16 val = freerdp_get_param_int16(settings, key);
if (!freerdp_set_param_int16(settings, key, val))
goto fail;
}
#endif
#if defined(have_uint16_list_indices)
for (x = 0; x < ARRAYSIZE(uint16_list_indices); x++)
{
const size_t key = uint16_list_indices[x];
const UINT16 val = freerdp_get_param_uint16(settings, key);
if (!freerdp_set_param_uint16(settings, key, val))
goto fail;
}
#endif
#if defined(have_uint32_list_indices)
for (x = 0; x < ARRAYSIZE(uint32_list_indices); x++)
{
const size_t key = uint32_list_indices[x];
const UINT32 val = freerdp_get_param_uint32(settings, key);
if (!freerdp_set_param_uint32(settings, key, val))
goto fail;
}
#endif
#if defined(have_int32_list_indices)
for (x = 0; x < ARRAYSIZE(int32_list_indices); x++)
{
const size_t key = int32_list_indices[x];
const INT32 val = freerdp_get_param_int32(settings, key);
if (!freerdp_set_param_int32(settings, key, val))
goto fail;
}
#endif
#if defined(have_uint64_list_indices)
for (x = 0; x < ARRAYSIZE(uint64_list_indices); x++)
{
const size_t key = uint64_list_indices[x];
const UINT64 val = freerdp_get_param_uint64(settings, key);
if (!freerdp_set_param_uint64(settings, key, val))
goto fail;
}
#endif
#if defined(have_int64_list_indices)
for (x = 0; x < ARRAYSIZE(int64_list_indices); x++)
{
const size_t key = int64_list_indices[x];
const INT64 val = freerdp_get_param_int64(settings, key);
if (!freerdp_set_param_int64(settings, key, val))
goto fail;
}
#endif
#if defined(have_string_list_indices)
for (x = 0; x < ARRAYSIZE(string_list_indices); x++)
{
const size_t key = string_list_indices[x];
const char* val = "test-string";
const char* res;
if (!freerdp_set_param_string(settings, key, val))
goto fail;
res = freerdp_get_param_string(settings, key);
if (strncmp(val, res, sizeof(val)) != 0)
goto fail;
}
#endif
#if defined(have_pointer_list_indices)
for (x = 0; x < ARRAYSIZE(pointer_list_indices); x++)
{
const size_t key = pointer_list_indices[x];
const void* val = freerdp_get_param_pointer(settings, key);
}
#endif
rc = 0;
fail:
freerdp_settings_free(cloned);
freerdp_settings_free(settings);
return rc;
}