diff options
author | Martin Willi <martin@strongswan.org> | 2005-11-11 13:05:19 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2005-11-11 13:05:19 +0000 |
commit | 55497527cefeea9ef230887bb1909b7703f8b5ec (patch) | |
tree | 44f8ec20f741636714d1839e180551ff614969b8 /Source/charon/testcases/packet_test.c | |
parent | c795c4e5d7c5a51001c9933c544aa2ef9e98d4c4 (diff) | |
download | strongswan-55497527cefeea9ef230887bb1909b7703f8b5ec.tar.bz2 strongswan-55497527cefeea9ef230887bb1909b7703f8b5ec.tar.xz |
- renamed tests to testcases
Diffstat (limited to 'Source/charon/testcases/packet_test.c')
-rw-r--r-- | Source/charon/testcases/packet_test.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/charon/testcases/packet_test.c b/Source/charon/testcases/packet_test.c new file mode 100644 index 000000000..f2cb22887 --- /dev/null +++ b/Source/charon/testcases/packet_test.c @@ -0,0 +1,61 @@ +/** + * @file packet_test.c + * + * @brief Tests to test the class type packet_t + * + */ + +/* + * Copyright (C) 2005 Jan Hutter, Martin Willi + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * 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. + */ + +#include <string.h> +#include "packet_test.h" +#include "../allocator.h" +#include "../packet.h" + + +/* + * Described in Header + */ +void test_packet(tester_t *tester) +{ + packet_t *packet = packet_create(AF_INET); + packet_t *packet2; + char * string_to_copy = "aha, soso"; + + packet->data.ptr = allocator_alloc_thing(string_to_copy); + packet->data.len = sizeof(string_to_copy); + memcpy(packet->data.ptr,string_to_copy,packet->data.len); + + tester->assert_true(tester,(packet != NULL),"NULL pointer check"); + + tester->assert_true(tester,(packet->clone(packet,&packet2) == SUCCESS),"clone call check"); + + tester->assert_false(tester,(packet->data.ptr == packet2->data.ptr),"value pointer check"); + + tester->assert_true(tester,(memcmp(packet->data.ptr,packet2->data.ptr,packet->data.len) == 0),"cloned value check"); + + tester->assert_true(tester,(packet->family == packet2->family),"cloned value check"); + tester->assert_true(tester,(packet->sockaddr_len == packet2->sockaddr_len),"cloned value check"); + tester->assert_true(tester,(memcmp(&(packet->source),&(packet2->source), sizeof(struct sockaddr)) == 0),"cloned value check"); + tester->assert_true(tester,(memcmp(&(packet->destination),&(packet2->destination), sizeof(struct sockaddr)) == 0),"cloned value check"); + + + packet2->destroy(packet2); + packet->destroy(packet); + + + +} |