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

Issue #768: Add unit test to reproduce #773

Closed
wants to merge 1 commit into from

Conversation

KentaKato
Copy link

Unit test to reproduce issue #768

@facontidavide
Copy link
Collaborator

facontidavide commented Feb 14, 2024

There are two errors in this test:

  1. First in line 577, you should use std::optional, not std::shared_ptr
  2. The following XML is wrong:
<NodeWithDefaultNullptr input=""/>

And should be instead:

<NodeWithDefaultNullptr />

In fact, the former version will override the default value and assigns to the port an empty string

Once this is fixed, the tests passes as expected.
Now, something I can try to do is to fail at deployment time (creation of the tree) instead of runtime.
That will certainly help users

@KentaKato
Copy link
Author

@facontidavide
Regarding point 2, I understand that to use the default value, the port should not be listed in the XML.

Yet, with Groot2, an empty string is automatically applied to any empty Port fields. Therefore, to ensure that default values are utilized for certain ports when generating a tree with Groot2, would it be accurate to say that the necessary steps are:

  1. Outputting XML from Groot2
  2. Removing the ports where default values are intended to be used

Is this understanding correct?

@facontidavide
Copy link
Collaborator

Yet, with Groot2, an empty string is automatically applied to any empty Port fields

That is an entirely separate problem that I will be happy to fix.
But I just check and that doesn' happen in Groot2 1.5.2

image

If the default value is specified in the than Groot2 does to add ports with empty strings.

Have a look at commit 6c9929c , where I cherry-picked some of your code.

You will now be alerted that the default is overridden when the tree is constructed.

@KentaKato
Copy link
Author

I deeply appreciate the verification and update.

I have understood the specifications of Groot2 version 1.5.2 and have also confirmed that alerts are generated.
Upon further verification, I identified the cause of the issue I was facing.

When generating XML, I have been outputting the TreeNodesModel to the console using BT::writeTreeNodesModelXML and then copying & pasting it into an XML file. It seems that BT::writeTreeNodesModelXML outputs default="" when the default value is not of a primitive type (such as nullptr or std::optional). As a result, it seems that an empty string "" was being assigned as the default value for empty Ports on Groot2.

In cases where a non-primitive type is set as the default value, what procedure is expected for generating the TreeNodesModel?

@facontidavide
Copy link
Collaborator

Oh, thanks for finding this.

I will have a look and see if I can fix 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

Successfully merging this pull request may close these issues.

2 participants