1#include "../sdl_prefs.hpp"
6#include <winpr/config.h>
7#include <winpr/winpr.h>
9#include "../filesystem.hpp"
11static std::shared_ptr<SdlPref> instance()
13#if !defined(TEST_SRC_AREA)
14#error "Please define TEST_SRC_AREA to the source directory of this test case"
16 fs::path src(TEST_SRC_AREA);
17 src /=
"sdl-freerdp.json";
20 std::cerr <<
"[ERROR] test configuration file '" << src <<
"' does not exist" << std::endl;
24 return SdlPref::instance(src.string());
27int TestSDLPrefs(
int argc,
char* argv[])
32#if defined(WITH_WINPR_JSON)
33 printf(
"implementation: json\n");
35 printf(
"implementation: fallback\n");
38#if defined(WITH_WINPR_JSON)
39 printf(
"config: %s\n", instance()->get_pref_file().c_str());
42 auto string_value = instance()->get_string(
"string_key",
"cba");
43#if defined(WITH_WINPR_JSON)
44 if (string_value !=
"abc")
47 if (string_value !=
"cba")
51 auto string_value_nonexistent = instance()->get_string(
"string_key_nonexistent",
"cba");
52 if (string_value_nonexistent !=
"cba")
55 auto int_value = instance()->get_int(
"int_key", 321);
56#if defined(WITH_WINPR_JSON)
64 auto int_value_nonexistent = instance()->get_int(
"int_key_nonexistent", 321);
65 if (int_value_nonexistent != 321)
68 auto bool_value = instance()->get_bool(
"bool_key",
false);
69#if defined(WITH_WINPR_JSON)
77 auto bool_value_nonexistent = instance()->get_bool(
"bool_key_nonexistent",
false);
78 if (bool_value_nonexistent)
81 auto array_value = instance()->get_array(
"array_key", {
"c",
"b",
"a" });
82 if (array_value.size() != 3)
84#if defined(WITH_WINPR_JSON)
85 if (array_value.at(0) !=
"a")
87 if (array_value.at(1) !=
"b")
89 if (array_value.at(2) !=
"c")
92 if (array_value.at(0) !=
"c")
94 if (array_value.at(1) !=
"b")
96 if (array_value.at(2) !=
"a")
100 auto array_value_nonexistent =
101 instance()->get_array(
"array_key_nonexistent", {
"c",
"b",
"a" });
102 if (array_value_nonexistent.size() != 3)
105 if (array_value_nonexistent.at(0) !=
"c")
107 if (array_value_nonexistent.at(1) !=
"b")
109 if (array_value_nonexistent.at(2) !=
"a")