add YAML parser

This commit is contained in:
MihailRis
2025-03-23 08:49:09 +03:00
parent 239181bb64
commit 2aea19febd
8 changed files with 406 additions and 25 deletions
+22
View File
@@ -0,0 +1,22 @@
#include <gtest/gtest.h>
#include "coders/yaml.hpp"
#include "coders/json.hpp"
#include "coders/commons.hpp"
#include "io/io.hpp"
#include "io/devices/StdfsDevice.hpp"
namespace fs = std::filesystem;
TEST(YAML, EncodeDecode) {
io::set_device("root", std::make_shared<io::StdfsDevice>(fs::u8path("../../")));
auto filename = "root:.github/workflows/windows-clang.yml";
try {
auto value = yaml::parse(io::read_string(filename));
std::cout << json::stringify(value, true) << std::endl;
} catch (const parsing_error& error) {
std::cerr << error.errorLog() << std::endl;
throw error;
}
}