Giter Site home page Giter Site logo

Tutorial case about fkyaml HOT 9 CLOSED

burgreen avatar burgreen commented on September 2, 2024
Tutorial case

from fkyaml.

Comments (9)

burgreen avatar burgreen commented on September 2, 2024 1

Thanks for your reply. That change made behavior worse.

For the original novels.yaml file, it gives:
libc++abi: terminating due to uncaught exception of type fkyaml::v0_3_0::parse_error: parse_error: Invalid character found in a negative number token. (at line 2, column 2)

For a simpler yaml file:

novels:
    title: Robinson Crusoe
    author: Daniel Defoe
    year: 1678

The previous source code worked fine. With the suggested change, it fails with:
libc++abi: terminating due to uncaught exception of type fkyaml::v0_3_0::type_error: type_error: operator[] is unavailable for a scalar node. type=string

I am using:
set(CMAKE_CXX_STANDARD 17)

C++11 will give the same errors.

$ gcc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.5.0
Thread model: posix

from fkyaml.

burgreen avatar burgreen commented on September 2, 2024 1

Weird. It is working now. No clue what I changed. Sorry, I know that is zero help for debugging the previous issue.

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

@burgreen
Thanks for sharing issues you faced.

target_link_library(example PRIVATE fkYAML::fkYAML)
needs to be changed to
target_link_libraries(example PRIVATE fkYAML::fkYAML)

You're right...Sorry for your inconvenience. I'll fix the typo soon.


As for the error, I've built and run a tutorial on ubuntu22.04 with gcc-11.4.0 & clang 14.0.0 and no errors emitted in both debug/release modes.
But I met build errors when I built the tutorial on Windows10 with Visual Studio 16 2019 and had to made the following changes:

from (where)

template <typename ItrType>
static basic_node deserialize(ItrType&& begin, ItrType&& end)
{
    return deserializer_type().deserialize(
        detail::input_adapter(std::forward<ItrType>(begin), std::forward<ItrType>(end)));
}

to

template <typename ItrType>
static basic_node deserialize(ItrType begin, ItrType end)
{
    return deserializer_type().deserialize(
        detail::input_adapter(std::move(begin), std::move(end)));
}

Since I don't have any macOS environment locally, it would be very helpful if you could check if the changes above fix the error on your environment as well.

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

@burgreen
That's weired... I can successfully run the tutorial app with the simpler yaml file as well.
Did you check if you can compile and run the unit tests on your environment?
You can check that with commands like:

$ cd path/to/fkYAML
$ mkdir build && cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DFK_YAML_BUILD_TEST=ON
$ cmake --build . --config Debug
$ ctest -C Debug --output-on-failure

If the unit tests failed, you would have to add some configurations for your environment.

Also, I just want to make sure your yaml file is encoded either in UTF-8, UTF-16 or UTF-32, since the other encodings are not supported and could produce unexpected situations.

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

@burgreen

Did you check if you can compile and run the unit tests on your environment?

It's turned out that the compiler you're using has not yet been used in any workflows because the runner image for macOS 13 (Ventura), the only image which pre-installs Apple Clang 14.0.3 according to the docs here, is in the beta stage.
So I created a trial branch to check if the unit tests pass successfully with newer Apple Clang compilers installed in the macOS-13 image.
Given the result, fkYAML should work on your environment too...

from fkyaml.

burgreen avatar burgreen commented on September 2, 2024

My xcode version is definitely 14.3.1. I am not sure why my gcc/clang --version is showing 14.0.3.

I recompiled using branch trial/ci_with_macos13

$ ctest -X Debug --output-on-failure
Test project /Volumes/work/pkgs/git/fkYAML
No tests were found!!!

??? Your test results for mac-latest shows same No tests were found!!! result.

$ 0--build/test/unit_test/fkYAMLUnitTest
===============================================================================
All tests passed (4540 assertions in 209 test cases)

Yet, the tutorial code still gives errors.

For original novels.yaml:
libc++abi: terminating due to uncaught exception of type fkyaml::v0_3_0::parse_error: parse_error: Detected duplication in mapping keys. (at line 5, column 2)

And for simpler yaml:
Runs fine.

Here is my test.cpp:

#include <fstream>
#include <iostream>
#include <fkYAML/node.hpp>

int main()
{
    {
    std::ifstream ifs("simple.yaml");
    fkyaml::node root = fkyaml::node::deserialize(ifs);
    auto& novel_node = root["novels"];
    std::cout << novel_node["title"].get_value_ref<std::string&>() << std::endl;
    }

    std::ifstream ifs("novels.yaml");
std::cout << "here1" << std::endl;

    fkyaml::node root = fkyaml::node::deserialize(ifs);
std::cout << "here2" << std::endl;

    for (auto& novel_node : root["novels"])
    {
        std::cout << novel_node["title"].get_value_ref<std::string&>() << std::endl;
    }
std::cout << "here3" << std::endl;

    return 0;
}

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

@burgreen
Weired... but good to hear it's working!
If you happen to recall what's changed and that should be noted in the tutorial, let me know.
I'll just keep the weiredness in mind for now.

And thanks for reporting no tests being executed in the macos-latest jobs.
It seems that compile warning/error stop building unit tests.
I'll take a closer look at it later.

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

@burgreen
Two issues you reported in this issue have been fixed:

  • Typos (target_link_library -> target_link_libraries) in the tutorial (#267)
  • Unit tests not executed in the jobs with the macos-latest runner (#266)

Thanks for your coorporation!

from fkyaml.

fktn-k avatar fktn-k commented on September 2, 2024

I'll close this issue since I think all the fixable issues have been addressed.
Feel free to reopen it if I miss something or something related to this issue is found.

from fkyaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.