param_package.cpp 843 B

1234567891011121314151617181920212223242526272829
  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/logging/backend.h"
  7. #include "common/param_package.h"
  8. namespace Common {
  9. TEST_CASE("ParamPackage", "[common]") {
  10. Common::Log::DisableLoggingInTests();
  11. ParamPackage original{
  12. {"abc", "xyz"},
  13. {"def", "42"},
  14. {"jkl", "$$:1:$2$,3"},
  15. };
  16. original.Set("ghi", 3.14f);
  17. ParamPackage copy(original.Serialize());
  18. REQUIRE(copy.Get("abc", "") == "xyz");
  19. REQUIRE(copy.Get("def", 0) == 42);
  20. REQUIRE(std::abs(copy.Get("ghi", 0.0f) - 3.14f) < 0.01f);
  21. REQUIRE(copy.Get("jkl", "") == "$$:1:$2$,3");
  22. REQUIRE(copy.Get("mno", "uvw") == "uvw");
  23. REQUIRE(copy.Get("abc", 42) == 42);
  24. }
  25. } // namespace Common