param_package.cpp 765 B

123456789101112131415161718192021222324252627
  1. // Copyright 2017 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <catch2/catch.hpp>
  5. #include <math.h>
  6. #include "common/param_package.h"
  7. namespace Common {
  8. TEST_CASE("ParamPackage", "[common]") {
  9. ParamPackage original{
  10. {"abc", "xyz"},
  11. {"def", "42"},
  12. {"jkl", "$$:1:$2$,3"},
  13. };
  14. original.Set("ghi", 3.14f);
  15. ParamPackage copy(original.Serialize());
  16. REQUIRE(copy.Get("abc", "") == "xyz");
  17. REQUIRE(copy.Get("def", 0) == 42);
  18. REQUIRE(std::abs(copy.Get("ghi", 0.0f) - 3.14f) < 0.01f);
  19. REQUIRE(copy.Get("jkl", "") == "$$:1:$2$,3");
  20. REQUIRE(copy.Get("mno", "uvw") == "uvw");
  21. REQUIRE(copy.Get("abc", 42) == 42);
  22. }
  23. } // namespace Common