Files
eden/src/tests/common/param_package.cpp
T

29 lines
814 B
C++
Raw Normal View History

2022-05-15 02:06:02 +02:00
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2017-01-20 21:30:11 +02:00
2018-08-07 19:24:39 -04:00
#include <catch2/catch.hpp>
2017-01-20 21:30:11 +02:00
#include <math.h>
2021-08-13 18:39:45 +00:00
#include "common/logging/backend.h"
2017-01-20 21:30:11 +02:00
#include "common/param_package.h"
namespace Common {
TEST_CASE("ParamPackage", "[common]") {
2021-08-13 18:39:45 +00:00
Common::Log::DisableLoggingInTests();
2017-01-20 21:30:11 +02:00
ParamPackage original{
{"abc", "xyz"},
{"def", "42"},
{"jkl", "$$:1:$2$,3"},
2017-01-20 21:30:11 +02:00
};
original.Set("ghi", 3.14f);
ParamPackage copy(original.Serialize());
REQUIRE(copy.Get("abc", "") == "xyz");
REQUIRE(copy.Get("def", 0) == 42);
REQUIRE(std::abs(copy.Get("ghi", 0.0f) - 3.14f) < 0.01f);
REQUIRE(copy.Get("jkl", "") == "$$:1:$2$,3");
REQUIRE(copy.Get("mno", "uvw") == "uvw");
REQUIRE(copy.Get("abc", 42) == 42);
}
} // namespace Common