SimGrid  3.14.159
Versatile Simulation of Distributed Systems
xbt_str_unit.cpp File Reference
#include <stdio.h>
#include "xbt.h"
#include <xbt/ex.hpp>
#include "xbt/str.h"

Macros

#define mytest(name, input, expected)
 
#define mytest_str(name, input, separator, expected)
 
#define test_parse_error(function, name, variable, str)
 
#define test_parse_ok(function, name, variable, str, value)
 

Functions

 XBT_TEST_UNIT ("xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted")
 
 XBT_TEST_UNIT ("xbt_str_split_str", test_split_str, "test the function xbt_str_split_str")
 
 XBT_TEST_UNIT ("xbt_str_parse", test_parse, "Test the parsing functions")
 

Macro Definition Documentation

◆ mytest

#define mytest (   name,
  input,
  expected 
)
Value:
s=xbt_str_join(d,"XXX"); \
xbt_test_assert(!strcmp(s,expected),\
"Input (%s) leads to (%s) instead of (%s)", \
input,s,expected);\
free(s); \
xbt_dynar_free(&d);
void int MPI_Datatype int MPI_Aint int MPI_Datatype MPI_Op MPI_Win win void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Aint MPI_Info void baseptr void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Comm int keyval MPI_Comm int void attr_value void int MPI_Datatype int MPI_Comm comm MPI_Comm int int int int MPI_Comm comm_cart MPI_Comm int int int int coords MPI_Comm int int int int dest MPI_Comm MPI_Comm int result MPI_Comm MPI_Group MPI_Comm newcomm MPI_Comm comm int keyval MPI_Comm int void int flag MPI_Comm MPI_Group group MPI_Comm int void attribute_val MPI_Comm int int MPI_Comm comm_out int int errorclass int flag void baseptr void int MPI_Datatype void int int MPI_Datatype int MPI_Comm comm MPI_Status MPI_Datatype int count char * name
Definition: smpi_mpi.cpp:83
xbt_dynar_t xbt_str_split_quoted(const char *s)
Splits a string into a dynar of strings, taking quotes into account.
Definition: xbt_str.cpp:378
static int input(void)
char * xbt_str_join(xbt_dynar_t dynar, const char *sep)
Join a set of strings as a single string.
Definition: xbt_str.cpp:402
#define xbt_test_add(...)
Declare that a new test begins (printf-like parameters, describing the test)
Definition: cunit.h:107

◆ mytest_str

#define mytest_str (   name,
  input,
  separator,
  expected 
)
Value:
d=xbt_str_split_str(input, separator); \
s=xbt_str_join(d,"XXX"); \
xbt_test_assert(!strcmp(s,expected),\
"Input (%s) leads to (%s) instead of (%s)", \
input,s,expected);\
free(s); \
xbt_dynar_free(&d);
void int MPI_Datatype int MPI_Aint int MPI_Datatype MPI_Op MPI_Win win void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Aint MPI_Info void baseptr void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Comm int keyval MPI_Comm int void attr_value void int MPI_Datatype int MPI_Comm comm MPI_Comm int int int int MPI_Comm comm_cart MPI_Comm int int int int coords MPI_Comm int int int int dest MPI_Comm MPI_Comm int result MPI_Comm MPI_Group MPI_Comm newcomm MPI_Comm comm int keyval MPI_Comm int void int flag MPI_Comm MPI_Group group MPI_Comm int void attribute_val MPI_Comm int int MPI_Comm comm_out int int errorclass int flag void baseptr void int MPI_Datatype void int int MPI_Datatype int MPI_Comm comm MPI_Status MPI_Datatype int count char * name
Definition: smpi_mpi.cpp:83
static int input(void)
char * xbt_str_join(xbt_dynar_t dynar, const char *sep)
Join a set of strings as a single string.
Definition: xbt_str.cpp:402
#define xbt_test_add(...)
Declare that a new test begins (printf-like parameters, describing the test)
Definition: cunit.h:107
xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
This functions splits a string after using another string as separator For example A!!B!!C splitted a...
Definition: xbt_str.cpp:233

◆ test_parse_error

#define test_parse_error (   function,
  name,
  variable,
  str 
)
Value:
do { \
xbt_test_add(name); \
try { \
variable = function(str, "Parse error"); \
xbt_test_fail("The test '%s' did not detect the problem",name ); \
} catch(xbt_ex& e) { \
if (e.category != arg_error) { \
xbt_test_exception(e); \
} \
} \
} while (0)
void int MPI_Datatype int MPI_Aint int MPI_Datatype MPI_Op MPI_Win win void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Aint MPI_Info void baseptr void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Comm int keyval MPI_Comm int void attr_value void int MPI_Datatype int MPI_Comm comm MPI_Comm int int int int MPI_Comm comm_cart MPI_Comm int int int int coords MPI_Comm int int int int dest MPI_Comm MPI_Comm int result MPI_Comm MPI_Group MPI_Comm newcomm MPI_Comm comm int keyval MPI_Comm int void int flag MPI_Comm MPI_Group group MPI_Comm int void attribute_val MPI_Comm int int MPI_Comm comm_out int int errorclass int flag void baseptr void int MPI_Datatype void int int MPI_Datatype int MPI_Comm comm MPI_Status MPI_Datatype int count char * name
Definition: smpi_mpi.cpp:83
A legacy exception.
Definition: ex.hpp:64
Invalid argument.
Definition: ex.h:94
xbt_errcat_t category
Category (what went wrong)
Definition: ex.hpp:86

◆ test_parse_ok

#define test_parse_ok (   function,
  name,
  variable,
  str,
  value 
)
Value:
do { \
xbt_test_add(name); \
try { \
variable = function(str, "Parse error"); \
} catch(xbt_ex& e) { \
xbt_test_exception(e); \
} \
xbt_test_assert(variable == value, "Fail to parse '%s'", str); \
} while (0)
void int MPI_Datatype int MPI_Aint int MPI_Datatype MPI_Op MPI_Win win void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Aint MPI_Info void baseptr void int MPI_Datatype void int MPI_Datatype MPI_Comm comm MPI_Comm int keyval MPI_Comm int void attr_value void int MPI_Datatype int MPI_Comm comm MPI_Comm int int int int MPI_Comm comm_cart MPI_Comm int int int int coords MPI_Comm int int int int dest MPI_Comm MPI_Comm int result MPI_Comm MPI_Group MPI_Comm newcomm MPI_Comm comm int keyval MPI_Comm int void int flag MPI_Comm MPI_Group group MPI_Comm int void attribute_val MPI_Comm int int MPI_Comm comm_out int int errorclass int flag void baseptr void int MPI_Datatype void int int MPI_Datatype int MPI_Comm comm MPI_Status MPI_Datatype int count char * name
Definition: smpi_mpi.cpp:83
A legacy exception.
Definition: ex.hpp:64

Function Documentation

◆ XBT_TEST_UNIT() [1/3]

XBT_TEST_UNIT ( "xbt_str_split_quoted"  ,
test_split_quoted  ,
"test the function xbt_str_split_quoted  
)

◆ XBT_TEST_UNIT() [2/3]

XBT_TEST_UNIT ( "xbt_str_split_str"  ,
test_split_str  ,
"test the function xbt_str_split_str  
)

◆ XBT_TEST_UNIT() [3/3]

XBT_TEST_UNIT ( "xbt_str_parse"  ,
test_parse  ,
"Test the parsing functions"   
)