d3d56709309aecebc2ba92211b1f04bf498829ff
2 * @file ike_sa_id_test.c
4 * @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_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
23 #include "ike_sa_id_test.h"
25 #include <sa/ike_sa_id.h>
28 * described in Header-File
30 void test_ike_sa_id(tester_t
*tester
)
32 ike_sa_id_t
*ike_sa_id
, *clone
, *equal
, *other1
, *other2
, *other3
, *other4
;
33 u_int64_t initiator
, initiator2
, responder
, responder2
;
38 initiator2
= 12345612;
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
);
52 other4
= ike_sa_id_create(initiator
, responder
, is_initiator
);
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");
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");
63 /* check for non equality */
64 tester
->assert_false(tester
,(ike_sa_id
->equals(ike_sa_id
,other1
) == TRUE
), "equal check");
66 tester
->assert_false(tester
,(ike_sa_id
->equals(ike_sa_id
,other2
) == TRUE
), "equal check");
68 tester
->assert_false(tester
,(ike_sa_id
->equals(ike_sa_id
,other3
) == TRUE
), "equal check");
70 tester
->assert_false(tester
,(ike_sa_id
->equals(ike_sa_id
,other4
) == TRUE
), "equal check");
72 other4
->replace_values(other4
,ike_sa_id
);
73 tester
->assert_true(tester
,(ike_sa_id
->equals(ike_sa_id
,other4
) == TRUE
), "equal check");
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
);