cast_test.c 2.2 KB
Newer Older
1 2 3 4 5 6
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    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
7
    the Free Software Foundation, either version 2 of the License, or
8 9 10 11 12 13 14 15 16 17 18 19
    (at your option) any later version.

    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, see <http://www.gnu.org/licenses/>.
*/

#include "belle-sip/belle-sip.h"
Ghislain MARY's avatar
Ghislain MARY committed
20
#include "belle_sip_tester.h"
21

22
static void cast_test(void){
23
	belle_sip_stack_t *stack=belle_sip_stack_new(NULL);
24 25
	belle_sip_listening_point_t *lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"UDP");
	belle_sip_provider_t *provider;
26 27 28
	belle_sip_request_t *req=belle_sip_request_new();
	belle_sip_response_t *resp=belle_sip_response_new();
	belle_sip_message_t *msg;
29
	int tmp;
30

31 32
	BC_ASSERT_PTR_NOT_NULL(stack);
	BC_ASSERT_PTR_NOT_NULL(lp);
33
	provider=belle_sip_stack_create_provider(stack,lp);
34 35 36
	BC_ASSERT_PTR_NOT_NULL(provider);
	BC_ASSERT_PTR_NOT_NULL(req);
	BC_ASSERT_PTR_NOT_NULL(resp);
37

38 39
	belle_sip_message("Casting belle_sip_request_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(req);
40
	BC_ASSERT_PTR_NOT_NULL(msg);
41
	belle_sip_message("Ok.");
42 43
	belle_sip_message("Casting belle_sip_response_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(resp);
44
	BC_ASSERT_PTR_NOT_NULL(msg);
45
	belle_sip_message("Ok.");
46 47
	tmp=BELLE_SIP_IS_INSTANCE_OF(req,belle_sip_response_t);
	belle_sip_message("Casting belle_sip_request_t to belle_sip_response_t: %s",tmp ? "yes" : "no");
48
	BC_ASSERT_EQUAL(tmp,0,int,"%d");
jehan's avatar
jehan committed
49 50 51 52
	belle_sip_object_unref(req);
	belle_sip_object_unref(resp);
	belle_sip_object_unref(provider);
	belle_sip_object_unref(stack);
53 54 55
}


Ghislain MARY's avatar
Ghislain MARY committed
56
test_t cast_tests[] = {
57
	TEST_NO_TAG("Casting requests and responses", cast_test)
Ghislain MARY's avatar
Ghislain MARY committed
58
};
59

60 61
test_suite_t cast_test_suite = {"Object inheritance", NULL, NULL, NULL, NULL,
								sizeof(cast_tests) / sizeof(cast_tests[0]), cast_tests};