Skip to content

Commit d514868

Browse files
committed
test(diagram): keep the unclosed class declaration in its own diagram
A class line makes a PlantUML diagram a class diagram, where -> is an arrow rather than a sequence message, so the edge-message fixture could never produce the message arrow it asserts. Put the unclosed declaration in a second @startuml block and assert both diagram kinds. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent d68cd2e commit d514868

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/test_diagrams.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,24 @@ TEST(diagrams_plantuml) {
331331

332332
/* #2818: a sequence message to or from the diagram edge (`A ->: x`, `A <-: x`,
333333
* `[-> A: x`) and a declaration with an unclosed bracket have no operand id;
334-
* they used to read an uninitialized one and crash the index worker. */
334+
* they used to read an uninitialized one and crash the index worker. The
335+
* declaration sits in its own diagram: a `class` line makes a diagram a class
336+
* diagram, where `->` is an arrow rather than a sequence message. */
335337
TEST(diagrams_plantuml_edge_messages) {
336338
CBMFileResult *r = dg_file("@startuml\n"
337339
"participant Alice\n"
338340
"Alice ->: out\n"
339341
"Alice <-: in\n"
340342
"[-> Alice: from the edge\n"
341343
"Alice -> Bob : hello\n"
344+
"@enduml\n"
345+
"@startuml\n"
342346
"class [Unclosed\n"
343347
"@enduml\n",
344348
"docs/edge.puml");
345349
ASSERT_NOT_NULL(r);
350+
ASSERT_STR_EQ(dg_prop(dg_def(r, "edge#diagram-1"), "diagram_kind"), "sequence");
351+
ASSERT_STR_EQ(dg_prop(dg_def(r, "edge#diagram-2"), "diagram_kind"), "class");
346352
ASSERT_NOT_NULL(dg_def(r, "edge#diagram-1.Alice"));
347353
ASSERT_NOT_NULL(dg_def(r, "edge#diagram-1.Bob"));
348354
ASSERT_EQ(r->diagram_arrows.count, 1);

0 commit comments

Comments
 (0)