cast_test.c 2.21 KB
Newer Older
1
/*
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Copyright (c) 2012-2019 Belledonne Communications SARL.
 *
 * This file is part of belle-sip.
 *
 * 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 3 of the License, or
 * (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/>.
 */
19 20

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

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

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

39 40
	belle_sip_message("Casting belle_sip_request_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(req);
41
	BC_ASSERT_PTR_NOT_NULL(msg);
42
	belle_sip_message("Ok.");
43 44
	belle_sip_message("Casting belle_sip_response_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(resp);
45
	BC_ASSERT_PTR_NOT_NULL(msg);
46
	belle_sip_message("Ok.");
47 48
	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");
49
	BC_ASSERT_EQUAL(tmp,0,int,"%d");
jehan's avatar
jehan committed
50 51 52 53
	belle_sip_object_unref(req);
	belle_sip_object_unref(resp);
	belle_sip_object_unref(provider);
	belle_sip_object_unref(stack);
54 55 56
}


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

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