Skip to content

Tp json#6

Open
marsault wants to merge 5 commits intoLaefy:masterfrom
marsault:tp-json
Open

Tp json#6
marsault wants to merge 5 commits intoLaefy:masterfrom
marsault:tp-json

Conversation

@marsault
Copy link

No description provided.

```

Après reconfiguration, une nouvelle ligne apparait dans la barre en bas de vscode. Vous pouvez lancer la suite de tests en cliquant dessus.
Pour simplifier, chaque fichier
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

@marsault marsault Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pensais que dans la version finale, on allait commenter la ligne enable_testing() du CMakeLists.txt pour ne pas ajouter du bordel dans vscode dans les premiers tps.

@@ -0,0 +1,498 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json_example_as_svg.svg

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je l'ai renommé example_cpp2022_as_image.svg

## Parseur

Un parseur de JSON est fourni (classe `JsonParser` dans le fichier `JsonParser.cpp`), et normalement vous n'aurez pas besoin de le modifier.
Il pourra éventuellement être utile de regarder ce fichier partir des tests qui utilisent le parser.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an informative discussion <3

ASSERT_EQUAL(node->as_ObjectNode(), nullptr);*/

Node_ptr node = BooleanLeaf::make_ptr(true);
ASSERT_UNEQUAL(node->as_BooleanLeaf(), nullptr);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT_EQUAL(node->as_BooleanLeaf(), node.get()) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si on fait ça, on impose le type de Node_ptr, ce que j'avais essayé d'éviter.

{
std::cout << "First command-line argument needs to be where are the json resources.";
exit(EXIT_FAILURE);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A calculer avec le chemin du programme + copier les resources dans le cmake à coté des exe/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai réglé ce problème: on peut donc maintenant lancer les tests individuellement avec la liste dans l'interface graphique.

.vscode/
build/
solutions/
_build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'imagine que c'est la bibliotheque des testes qui veut rajouter '_build' ? Pourrait-on la configurer pour utiliser le 'build' qu'on a déjà (ça me soule un peu d'avoir 2 'build'...) ?

Copy link
Author

@marsault marsault Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne crois pas, je pense que je faisais des cmake .. à la main. J'ai supprimé le répertoire et le .gitignore de mon côté.

1. un *booléen*, par exemple `true`;
2. un *nombre*, par exemple `2022`;
3. une *chaîne de caractère*, par exemple `"C++"`;
4. une *liste* de valeurs JSON entre `[`...`]` et séparées par des virgules, par exemple `["Céline","Matthias","Victor"]`;
Copy link
Collaborator

@igel-kun igel-kun Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

les types dans la liste, peuvent-ils varier ? Peut-on avoir '["bla", 42, [true, "blubb"]]' ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui, je rajoute un exemple dans l'énoncé.


Node_ptr JsonParser::parse_NumberLeaf()
{
// unsigned starting_pos = _in.tellg();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pour le string et array node, on fait pas confience au fonction appelant, mais on teste bien que le prochain charactere correspond à ce qu'on attend. Ici on le fait pas. Y-a-t-il une raison pour l'inconsistence?

Copy link
Author

@marsault marsault Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectivement, j'ai oublié de rétablir ça (je pense que les lignes commentées vérifiait). J'ai corrigé:

    unsigned starting_pos = _in.tellg();

    double d;
    _in >> d;

    size_t end_pos = _in.tellg();

    if (starting_pos == end_pos)
        return nullptr;
    else
        return NumberLeaf::make_ptr(d);
        ```

std::cerr << "]" << std::endl;
}

std::vector<std::tuple<std::string, std::string>> const tests = { { "Bulbasaur", "Grass" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi tuple avant pair ?

Copy link
Author

@marsault marsault Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moins de mots clef à retenir par moi.
Je peux changer si ça choque aussi @Laefy.


std::ofstream out("/tmp/test.gv");
dot(out, node);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai pas compris pourquoi t'as introduit un nouveau scope ici oO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copier-coller sans doute :)

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.

3 participants

Comments