Skip to content

Tp json#6

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

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

Conversation

@marsault

Copy link
Copy Markdown

No description provided.

Comment thread tp-json/enonce.md Outdated
Comment thread tp-json/.gitignore Outdated
Comment thread tp-json/enonce.md Outdated
```

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

?

@marsault marsault Mar 28, 2022

Copy link
Copy Markdown
Author

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.

Comment thread tp-json/cpp2022.svg
@@ -0,0 +1,498 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread tp-json/enonce.md Outdated
## 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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

!?

Copy link
Copy Markdown
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

Comment thread tp-json/tests/21_parser_leaf.cpp Outdated
Comment thread tp-json/tests/31_explicit_cast.cpp Outdated
ASSERT_EQUAL(node->as_ObjectNode(), nullptr);*/

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

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread tp-json/tests/32_explicit_cast_const.cpp Outdated
Comment thread tp-json/tests/33_children_count.cpp Outdated
Comment thread tp-json/tests/38_equality.cpp Outdated
{
std::cout << "First command-line argument needs to be where are the json resources.";
exit(EXIT_FAILURE);
}

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread .gitignore
.vscode/
build/
solutions/
_build

Copy link
Copy Markdown
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'...) ?

@marsault marsault Apr 1, 2022

Copy link
Copy Markdown
Author

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é.

Comment thread tp-json/Node_ptr.hpp Outdated
Comment thread tp-json/enonce.md Outdated
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"]`;

@igel-kun igel-kun Apr 1, 2022

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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é.

Comment thread tp-json/enonce.md Outdated
Comment thread tp-json/enonce.md Outdated

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

Copy link
Copy Markdown
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?

@marsault marsault Apr 1, 2022

Copy link
Copy Markdown
Author

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);
        ```

Comment thread tp-json/code_fourni_aux_etudiants/JsonParser.cpp
Comment thread tp-json/tests/40_pokedex.cpp Outdated
std::cerr << "]" << std::endl;
}

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

Copy link
Copy Markdown
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 ?

@marsault marsault Apr 1, 2022

Copy link
Copy Markdown
Author

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.

Comment thread tp-json/tests/40_pokedex.cpp Outdated
Comment thread tp-json/tests/99_dot.cpp Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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 :)

Comment thread tp-json/Node_ptr.hpp Outdated
Comment thread tp-json/code_fourni_aux_etudiants/JsonParser.cpp
Comment thread tp-json/code_fourni_aux_etudiants/JsonParser.cpp
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