From 0e752a6e215aee21dc73da097c3225495d54a5b6 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 9 Apr 2021 07:19:03 -0300 Subject: Add libotr/etc sources --- libotr/libotr-4.1.1/tests/unit/test_mem.c | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 libotr/libotr-4.1.1/tests/unit/test_mem.c (limited to 'libotr/libotr-4.1.1/tests/unit/test_mem.c') diff --git a/libotr/libotr-4.1.1/tests/unit/test_mem.c b/libotr/libotr-4.1.1/tests/unit/test_mem.c new file mode 100644 index 0000000..24eae20 --- /dev/null +++ b/libotr/libotr-4.1.1/tests/unit/test_mem.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2014 - Julien Voisin + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include + +#include +#include + +#include + +GCRY_THREAD_OPTION_PTHREAD_IMPL; + +#define NUM_TESTS 5 + +static void test_otrl_mem_differ(void) +{ + const unsigned char buf1[] = "\x00" "12" "\x00" "34"; + const unsigned char buf2[] = "\x00" "13" "\x00" "34"; + const unsigned char buf3[] = "\x00" "13" "\x00" "345"; + + ok(otrl_mem_differ(buf1, buf1, sizeof(buf1)) == 0, + "Identical buf are identical"); + ok(otrl_mem_differ(buf1, buf2, sizeof(buf1)) == 1, + "buf1 and buf2 are not identical"); + ok(otrl_mem_differ(buf2, buf3, sizeof(buf1)) == 1, + "buf1 and buf2 are not identical"); + ok(otrl_mem_differ(buf1, NULL, 0) == 0, + "buf1 and NULL are identical"); + ok(otrl_mem_differ(NULL, NULL, 0) == 0, + "NULL and NULL are identical"); +} + +int main(int argc, char **argv) +{ + plan_tests(NUM_TESTS); + + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + OTRL_INIT; + + test_otrl_mem_differ(); + + return 0; +} -- cgit 1.4.1