- memory allocation tests removed
[strongswan.git] / Source / charon / testcases / ike_sa_id_test.c
1 /**
2 * @file ike_sa_id_test.c
3 *
4 * @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_t
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #include "ike_sa_id_test.h"
24
25 #include <sa/ike_sa_id.h>
26
27 /*
28 * described in Header-File
29 */
30 void test_ike_sa_id(tester_t *tester)
31 {
32 ike_sa_id_t *ike_sa_id, *clone, *equal, *other1, *other2, *other3, *other4;
33 u_int64_t initiator, initiator2, responder, responder2;
34 bool is_initiator;
35
36 initiator = 0;
37
38 initiator2 = 12345612;
39
40 responder = 34334;
41
42 responder2 = 987863;
43
44 is_initiator = TRUE;
45
46 ike_sa_id = ike_sa_id_create(initiator, responder, is_initiator);
47 equal = ike_sa_id_create(initiator, responder, is_initiator);
48 other1 = ike_sa_id_create(initiator, responder2, is_initiator);
49 other2 = ike_sa_id_create(initiator2, responder2, is_initiator);
50 other3 = ike_sa_id_create(initiator2, responder, is_initiator);
51 is_initiator = FALSE;
52 other4 = ike_sa_id_create(initiator, responder, is_initiator);
53
54 /* check equality */
55 tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,equal) == TRUE), "equal check");
56 tester->assert_true(tester,(equal->equals(equal,ike_sa_id) == TRUE), "equal check");
57
58 /* check clone functionality and equality*/
59 clone = ike_sa_id->clone(ike_sa_id);
60 tester->assert_false(tester,(clone == ike_sa_id), "clone pointer check");
61 tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,clone) == TRUE), "equal check");
62
63 /* check for non equality */
64 tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other1) == TRUE), "equal check");
65
66 tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other2) == TRUE), "equal check");
67
68 tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other3) == TRUE), "equal check");
69
70 tester->assert_false(tester,(ike_sa_id->equals(ike_sa_id,other4) == TRUE), "equal check");
71
72 other4->replace_values(other4,ike_sa_id);
73 tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4) == TRUE), "equal check");
74
75
76 /* check destroy functionality */
77 ike_sa_id->destroy(ike_sa_id);
78 equal->destroy(equal);
79 clone->destroy(clone);
80 other1->destroy(other1);
81 other2->destroy(other2);
82 other3->destroy(other3);
83 other4->destroy(other4);
84 }