|
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
|
| EDITSTRING_TEST (simple, "", "hello world!", KEYS( 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!')) |
|
| EDITSTRING_TEST (simple_null, NULL, "hi there", KEYS( 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e')) |
|
| EDITSTRING_TEST (insert, "in middle", "in the middle", KEYS(KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, 't', 'h', 'e', ' ')) |
|
| EDITSTRING_TEST (backspace_end, "byebye", "bye", KEYS(KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE)) |
|
| EDITSTRING_TEST (backspace_all, "abc", "", KEYS(KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE)) |
|
| EDITSTRING_TEST (backspace_empty, NULL, "", KEYS(KEY_BACKSPACE)) |
|
| EDITSTRING_TEST (backspace_beyond, "too far", "", KEYS(KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE)) |
|
| EDITSTRING_TEST (delete_dc, "go away", "goaway", KEYS(KEY_HOME, KEY_RIGHT, KEY_RIGHT, KEY_DC)) |
|
| EDITSTRING_TEST (delete_ctrl_d, "not here", "nohere", KEYS(KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, CTRL_D, CTRL_D)) |
|
| EDITSTRING_TEST (word_end, "remove these two words", "remove these ", KEYS(CTRL_W, CTRL_W)) |
|
| EDITSTRING_TEST (word_start, "no word", "word", KEYS(CTRL_A, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, CTRL_W)) |
|
| EDITSTRING_TEST (word_mid, "delete this word", "delete word", KEYS(KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT, CTRL_W)) |
|
| EDITSTRING_TEST (sol, "everything must go", "go", KEYS(KEY_LEFT, KEY_LEFT, CTRL_U)) |
|
| EDITSTRING_TEST (eol, "all is lost", "all", KEYS(KEY_HOME, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, CTRL_K)) |
|
static void | editstring_okx (struct editstring_test *test, const char *file, unsigned int line) |
| Report an editable string test result. More...
|
|
static void | editstring_test_exec (void) |
| Perform editable string self-tests. More...
|
|
Editable string tests.
Definition in file editstring_test.c.
static void editstring_okx |
( |
struct editstring_test * |
test, |
|
|
const char * |
file, |
|
|
unsigned int |
line |
|
) |
| |
|
static |
Report an editable string test result.
- Parameters
-
test | Editable string test |
file | Test code file |
line | Test code line |
Definition at line 135 of file editstring_test.c.
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",
int replace_string(struct edit_string *string, const char *replacement)
Replace editable string.
unsigned int cursor
Cursor position.
static int isprint(int character)
Check if character is printable.
#define okx(success, file, line)
Report test result.
static __nonnull void init_editstring(struct edit_string *string, char **buf)
Initialise editable string.
static void(* free)(struct refcnt *refcnt))
size_t strlen(const char *src)
Get length of string.
int strcmp(const char *first, const char *second)
Compare strings.
#define NULL
NULL pointer (VOID *)
void * memset(void *dest, int character, size_t len) __nonnull
References edit_string::cursor, DBGC, free, init_editstring(), isprint(), key, memset(), NULL, okx, replace_string(), strcmp(), string, strlen(), and test.