Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access nested tables #6

Open
Lucki opened this issue Aug 8, 2021 · 1 comment
Open

Unable to access nested tables #6

Lucki opened this issue Aug 8, 2021 · 1 comment

Comments

@Lucki
Copy link

Lucki commented Aug 8, 2021

This example is directly from the toml.io page:

[dog."tater.man"]
type.name = "pug"

But trying to access them with doc["dog"]["tater.man"]["type"]["name"].as<string> () fails with:

[ERROR] Nothing at `dog`.

Here's a simple example for your tests which outputs the error in the log.

diff --git a/tests/toml-glib.vala b/tests/toml-glib.vala
index a5e0491..2c6b8b6 100644
--- a/tests/toml-glib.vala
+++ b/tests/toml-glib.vala
@@ -36,12 +36,16 @@ date-of-birth = 1975-05-07T08:34:45
 
 [hello]
 description = "Something really cool"
+
+[dog."tater.man"]
+type.name = "pug"
 """).parse ();
             var test = Toml.Serialization.deserialize<SerializationTester> (doc);
             assert_true (doc["name"].as<string> () == test.name);
             assert_true (doc["age"].as<int> () == test.age);
             assert_true (doc["date-of-birth"].as<DateTime> () == test.date_of_birth);
             assert_true (doc["hello"]["description"].as<string> () == test.hello.description);
+            assert_true (doc["dog"]["tater.man"]["type"]["name"].as<string> () == "pug");
         } catch (Error err) {
             print ("ERROR: %s\n", err.message);
             Test.fail ();
…
# Start of toml-glib tests
ok 1 /toml-glib/parser
ok 2 /toml-glib/serialize
ERROR: Nothing at `dog`.
not ok 3 /toml-glib/deserialize
# Start of lexer tests
…

Bonus issue:
You're not using your environment variable G_TEST_SRCDIR inside your tests so the tests /toml-glib/parser/file and /toml-glib/parser/whole-spec fail with

[ERROR] Failed to open file ?test.toml?: No such file or directory
not ok 12 /toml-glib/parser/file
[ERROR] Failed to open file ?all.toml?: No such file or directory
not ok 13 /toml-glib/parser/whole-spec

Bonus issue:
With the above file issue fixed I expect all.toml to fail or throw errors because it contains invalid configurations but it doesn't.

@elegaanz
Copy link
Owner

elegaanz commented Aug 8, 2021

I'm no longer maintaining this library to be honest, but if you want to submit a patch I will accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants