2017-01-20 19:30:11 +00:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-11-29 00:39:19 +00:00
|
|
|
#include <cmath>
|
2017-01-20 19:30:11 +00:00
|
|
|
#include <catch.hpp>
|
|
|
|
#include "common/param_package.h"
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
TEST_CASE("ParamPackage", "[common]") {
|
|
|
|
ParamPackage original{
|
2018-03-09 17:54:43 +00:00
|
|
|
{"abc", "xyz"},
|
|
|
|
{"def", "42"},
|
|
|
|
{"jkl", "$$:1:$2$,3"},
|
2017-01-20 19:30:11 +00: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
|