55#define KEYS(...) { __VA_ARGS__ }
58#define EDITSTRING_TEST( name, START, EXPECTED, KEYS ) \
59 static const int name ## _keys[] = KEYS; \
60 static struct editstring_test name = { \
62 .keys = name ## _keys, \
63 .count = ( sizeof ( name ## _keys ) / \
64 sizeof ( name ## _keys[0] ) ), \
65 .expected = EXPECTED, \
70 KEYS (
'h',
'e',
'l',
'l',
'o',
' ',
'w',
'o',
'r',
'l',
75 KEYS (
'h',
'i',
' ',
't',
'h',
'e',
'r',
'e' ) );
136 unsigned int line ) {
143 memset ( &
string, 0,
sizeof (
string ) );
149 okx ( actual !=
NULL, file, line );
152 DBGC (
test,
"Initial string: \"%s\"\n", actual );
155 for ( i = 0 ; i <
test->count ; i++ ) {
158 okx ( actual !=
NULL, file, line );
160 DBGC (
test,
"After key %#02x (%c): \"%s\"\n",
170#define editstring_ok( test ) editstring_okx ( test, __FILE__, __LINE__ )
196 .name =
"editstring",
#define NULL
NULL pointer (VOID *)
union @162305117151260234136356364136041353210355154177 key
Sense key.
static int isprint(int character)
Check if character is printable.
int replace_string(struct edit_string *string, const char *replacement)
Replace editable string.
static __nonnull void init_editstring(struct edit_string *string, char **buf)
Initialise editable string.
#define EDITSTRING_TEST(name, START, EXPECTED, KEYS)
Define an editable string test.
static void editstring_okx(struct editstring_test *test, const char *file, unsigned int line)
Report an editable string test result.
#define editstring_ok(test)
static void editstring_test_exec(void)
Perform editable string self-tests.
#define KEYS(...)
Define an inline key sequence.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
void * memset(void *dest, int character, size_t len) __nonnull
#define KEY_RIGHT
Right arrow.
#define KEY_LEFT
Left arrow.
static void(* free)(struct refcnt *refcnt))
int strcmp(const char *first, const char *second)
Compare strings.
size_t strlen(const char *src)
Get length of string.
unsigned int cursor
Cursor position.
const char * start
Initial string, or NULL.
const int * keys
Key sequence.
const char * expected
Expected result.
unsigned int count
Length of key sequence.
Self-test infrastructure.
#define okx(success, file, line)
Report test result.
#define __self_test
Declare a self-test.