Skip to content
Snippets Groups Projects
Commit e48f20b5 authored by Point Gerald's avatar Point Gerald
Browse files

. update documentation

. abort program also when an error occurs in parameter.
.
parent 9735c7f5
Branches
Tags
No related merge requests found
......@@ -24,27 +24,10 @@
#include "arc-shell-preferences.h"
#include "arc-commands.h"
/*
ARC_DEFINE_COMMAND_HELP (check_card_command) = {
"check-card",
"mec5, relation, semantics, symbolic, properties",
"Check that the given properties have the expected cardinality.",
"This command checks, for each given MEC 5 property, that its cardinality is the one passed as argument. If the cardinality is omitted the non-emptyness is checked.\n"
"\n"
"Note that if the preference '" ARC_SHELL_CHECK_CARD_ABORT "' is true and if the cardinality of the set is not the expected one then the program is aborted.\n"
"\n"
"Syntax:\n"
" check-card id1 [card1] id2 [card2] ...\n"
" Checks that Mec 5 relation id1 has card1 elements, id2 has card2 elements, ...\n"
,
NULL, NULL
};
*/
/* --------------- */
ARC_DEFINE_COMMAND (check_card_command)
{
int i = 0;
int i = 0;
int check_ok = 1;
int abort_on_failure =
ccl_config_table_get_boolean (config, ARC_SHELL_CHECK_CARD_ABORT);
arc_command_retval retval = ARC_CMD_SUCCESS;
......@@ -81,7 +64,7 @@ ARC_DEFINE_COMMAND (check_card_command)
propid = ar_identifier_create (arg);
if (ar_mec5_has_relation (propid))
{
int check_ok;
int lcheck;
ar_mec5_relation *R = ar_mec5_get_relation (propid);
double card = ar_mec5_relation_get_cardinality (R);
ar_mec5_relation_del_reference (R);
......@@ -92,28 +75,31 @@ ARC_DEFINE_COMMAND (check_card_command)
if (expected_card < 0.0)
{
ccl_display (" != 0");
check_ok = (card != 0.0);
lcheck = (card != 0.0);
}
else
{
ccl_display (" = %0.f", expected_card);
check_ok = (card == expected_card);
lcheck = (card == expected_card);
}
if (check_ok)
if (lcheck)
ccl_display (" passed\n");
else
ccl_display (" failed (%.0f)\n", card);
if (! check_ok && abort_on_failure)
exit (EXIT_FAILURE);
check_ok = check_ok && lcheck;
}
else
{
ccl_error("undefined set '");
ccl_error("error: undefined set '");
ar_identifier_log (CCL_LOG_ERROR, propid);
ccl_error("'.\n");
retval = ARC_CMD_ERROR;
}
ar_identifier_del_reference(propid);
}
if ((! check_ok || retval == ARC_CMD_ERROR) && abort_on_failure)
exit (EXIT_FAILURE);
return retval;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment