4 * @brief Tests to test the class type packet_t
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 #include "packet_test.h"
28 #include <network/packet.h>
29 #include <utils/allocator.h>
30 #include <utils/logger_manager.h>
36 void test_packet(tester_t
*tester
)
38 packet_t
*packet
= packet_create();
40 char * string_to_copy
= "aha, soso";
42 packet
->data
.ptr
= allocator_alloc(strlen(string_to_copy
) + 1);
43 tester
->assert_true(tester
,(packet
->data
.ptr
!= NULL
),"NULL pointer check");
45 packet
->data
.len
= strlen(string_to_copy
) + 1;
46 strcpy(packet
->data
.ptr
,string_to_copy
);
48 tester
->assert_true(tester
,(packet
!= NULL
),"NULL pointer check");
49 tester
->assert_true(tester
,(packet
->clone(packet
,&packet2
) == SUCCESS
),"clone call check");
51 tester
->assert_false(tester
,(packet
->data
.ptr
== packet2
->data
.ptr
),"value pointer check");
53 tester
->assert_true(tester
,(packet
->data
.len
== (strlen(string_to_copy
) + 1)),"value length check");
55 tester
->assert_true(tester
,(memcmp(packet
->data
.ptr
,packet2
->data
.ptr
,packet
->data
.len
) == 0),"cloned value check");
57 packet2
->destroy(packet2
);
58 packet
->destroy(packet
);