From ea9beb1d5dceb99797482ae8b580f5fbd7be8128 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 23 Nov 2018 23:37:11 +0100 Subject: Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- rawmemrelem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'rawmemrelem.c') diff --git a/rawmemrelem.c b/rawmemrelem.c index 75a15a9..4e93b5c 100644 --- a/rawmemrelem.c +++ b/rawmemrelem.c @@ -4,7 +4,7 @@ void * -libsimple_rawmemrelem(const void *hay_, size_t hayn, const void *sub_, size_t subn) +libsimple_rawmemrelem(const void *hay_, size_t hayn, const void *sub_, size_t subn) /* TODO man */ { switch (subn) { case 0: @@ -68,6 +68,11 @@ main(void) assert(!strcmpnul(libsimple_rawmemrelem("abcd1234abcd1234", 4, "1234", 4), "1234")); assert(!strcmpnul(libsimple_rawmemrelem("abcdefgh12345678abcdefgh12345678", 4, "12345678", 8), "12345678")); assert(!strcmpnul(libsimple_rawmemrelem("abc123abc123", 4, "123", 3), "123")); + + assert(!strcmpnul(libsimple_rawmemrelem("-aa--a-a", 4, "a-", 2), "a--a-a")); + assert(!strcmpnul(libsimple_rawmemrelem("--aa----a--a", 4, "a--", 3), "a----a--a")); + assert(!strcmpnul(libsimple_rawmemrelem("---aa------a---a", 4, "a---", 4), "a------a---a")); + assert(!strcmpnul(libsimple_rawmemrelem("-------aa--------------a-------a", 4, "a-------", 8), "a--------------a-------a")); return 0; } -- cgit v1.2.3-70-g09d2