1#include "../sdl_prefs.hpp" 
    6#include <winpr/config.h> 
    7#include <winpr/winpr.h> 
    9#if __has_include(<filesystem>) 
   11namespace fs = std::filesystem;
 
   12#elif __has_include(<experimental/filesystem>) 
   13#include <experimental/filesystem> 
   14namespace fs = std::experimental::filesystem;
 
   16#error Could not find system header "<filesystem>" or "<experimental/filesystem>" 
   19static std::shared_ptr<SdlPref> instance()
 
   21#if !defined(TEST_SRC_AREA) 
   22#error "Please define TEST_SRC_AREA to the source directory of this test case" 
   24  fs::path src(TEST_SRC_AREA);
 
   25  src /= 
"sdl-freerdp.json";
 
   28    std::cerr << 
"[ERROR] test configuration file '" << src << 
"' does not exist" << std::endl;
 
   32  return SdlPref::instance(src.string());
 
   35int TestSDLPrefs(
int argc, 
char* argv[])
 
   40#if defined(WITH_WINPR_JSON) 
   41  printf(
"implementation: json\n");
 
   43  printf(
"implementation: fallback\n");
 
   46#if defined(WITH_WINPR_JSON) 
   47  printf(
"config: %s\n", instance()->get_pref_file().c_str());
 
   50  auto string_value = instance()->get_string(
"string_key", 
"cba");
 
   51#if defined(WITH_WINPR_JSON) 
   52  if (string_value != 
"abc")
 
   55  if (string_value != 
"cba")
 
   59  auto string_value_nonexistent = instance()->get_string(
"string_key_nonexistent", 
"cba");
 
   60  if (string_value_nonexistent != 
"cba")
 
   63  auto int_value = instance()->get_int(
"int_key", 321);
 
   64#if defined(WITH_WINPR_JSON) 
   72  auto int_value_nonexistent = instance()->get_int(
"int_key_nonexistent", 321);
 
   73  if (int_value_nonexistent != 321)
 
   76  auto bool_value = instance()->get_bool(
"bool_key", 
false);
 
   77#if defined(WITH_WINPR_JSON) 
   85  auto bool_value_nonexistent = instance()->get_bool(
"bool_key_nonexistent", 
false);
 
   86  if (bool_value_nonexistent)
 
   89  auto array_value = instance()->get_array(
"array_key", { 
"c", 
"b", 
"a" });
 
   90  if (array_value.size() != 3)
 
   92#if defined(WITH_WINPR_JSON) 
   93  if (array_value[0] != 
"a")
 
   95  if (array_value[1] != 
"b")
 
   97  if (array_value[2] != 
"c")
 
  100  if (array_value[0] != 
"c")
 
  102  if (array_value[1] != 
"b")
 
  104  if (array_value[2] != 
"a")
 
  108  auto array_value_nonexistent =
 
  109      instance()->get_array(
"array_key_nonexistent", { 
"c", 
"b", 
"a" });
 
  110  if (array_value_nonexistent.size() != 3)
 
  113  if (array_value_nonexistent[0] != 
"c")
 
  115  if (array_value_nonexistent[1] != 
"b")
 
  117  if (array_value_nonexistent[2] != 
"a")