diff options
| author | Mattias Andrée <m@maandree.se> | 2026-09-25 23:42:55 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-09-25 23:42:55 +0200 |
| commit | 4e81cb177ab77904e7a21ce70b9a5506bf09ad6e (patch) | |
| tree | 05634bdcd5b52c25bbeb986748d6b2c5acb728fb /librecrypt_concat_mem_.c | |
| parent | m (diff) | |
| download | librecrypt-4e81cb177ab77904e7a21ce70b9a5506bf09ad6e.tar.gz librecrypt-4e81cb177ab77904e7a21ce70b9a5506bf09ad6e.tar.bz2 librecrypt-4e81cb177ab77904e7a21ce70b9a5506bf09ad6e.tar.xz | |
Add tests
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_concat_mem_.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/librecrypt_concat_mem_.c b/librecrypt_concat_mem_.c index edc826a..296303e 100644 --- a/librecrypt_concat_mem_.c +++ b/librecrypt_concat_mem_.c @@ -12,10 +12,26 @@ extern inline void librecrypt_concat_mem_(struct concat_state *state, const char int main(void) { + char buf[5]; + struct concat_state state = {buf, sizeof(buf), 0u}; + SET_UP_ALARM(); INIT_RESOURCE_TEST(); - /* TODO test */ + memset(buf, 'x', sizeof(buf)); + + librecrypt_concat_mem_(&state, "abcdef", 6u); + assert(!memcmp(buf, "abcd\0", sizeof(buf))); + assert(state.buf == &buf[4u]); + assert(state.size == 1u); + assert(state.len == 6u); + librecrypt_concat_mem_(&state, "z", 1u); + assert(!memcmp(buf, "abcd\0", sizeof(buf))); + assert(state.len == 7u); + + state = (struct concat_state){NULL, 0u, 0u}; + librecrypt_concat_mem_(&state, "abc", 3u); + assert(state.len == 3u); STOP_RESOURCE_TEST(); return 0; |
