cast_test.c 2.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
	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
    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/>.
*/

Simon Morlat's avatar
Simon Morlat committed
19
#include "CUnit/Basic.h"
20 21 22

#include "belle-sip/belle-sip.h"

Simon Morlat's avatar
Simon Morlat committed
23 24 25 26 27 28 29 30 31
static int init_cast_suite(){
	return 0;
}

static int cleanup_cast_suite(){
	return 0;
}

static void cast_test(){
32 33 34
	belle_sip_stack_t *stack=belle_sip_stack_new(NULL);
	belle_sip_listening_point_t *lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",5060,"UDP");
	belle_sip_provider_t *provider=belle_sip_stack_create_provider(stack,lp);
35 36 37
	belle_sip_request_t *req=belle_sip_request_new();
	belle_sip_response_t *resp=belle_sip_response_new();
	belle_sip_message_t *msg;
Simon Morlat's avatar
Simon Morlat committed
38 39 40 41 42
	int tmp;
	
	CU_ASSERT_PTR_NOT_NULL(stack);
	CU_ASSERT_PTR_NOT_NULL(lp);
	CU_ASSERT_PTR_NOT_NULL(provider);
43 44
	CU_ASSERT_PTR_NOT_NULL(req);
	CU_ASSERT_PTR_NOT_NULL(resp);
45
	
46 47 48
	belle_sip_message("Casting belle_sip_request_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(req);
	CU_ASSERT_PTR_NOT_NULL(msg);
Simon Morlat's avatar
Simon Morlat committed
49
	belle_sip_message("Ok.");
50 51 52
	belle_sip_message("Casting belle_sip_response_t to belle_sip_message_t");
	msg=BELLE_SIP_MESSAGE(resp);
	CU_ASSERT_PTR_NOT_NULL(msg);
Simon Morlat's avatar
Simon Morlat committed
53
	belle_sip_message("Ok.");
54 55
	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");
Simon Morlat's avatar
Simon Morlat committed
56 57 58 59 60 61 62
	CU_ASSERT_EQUAL(tmp,0);
}


int belle_sip_cast_test_suite(){
	CU_pSuite pSuite = CU_add_suite("Object inheritence", init_cast_suite, cleanup_cast_suite);

63
	if (NULL == CU_add_test(pSuite, "casting requests and responses", cast_test)) {
Simon Morlat's avatar
Simon Morlat committed
64 65
		return CU_get_error();
	}
66
	return 0;
67
}
Simon Morlat's avatar
Simon Morlat committed
68