cast_test.c 2.32 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 35 36
	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);
	belle_sip_server_transaction_t *st=belle_sip_provider_create_server_transaction(provider,NULL);
	belle_sip_client_transaction_t *ct=belle_sip_provider_create_client_transaction(provider,NULL);
37
	belle_sip_transaction_t *t;
Simon Morlat's avatar
Simon Morlat committed
38 39 40 41 42 43 44
	int tmp;
	
	CU_ASSERT_PTR_NOT_NULL(stack);
	CU_ASSERT_PTR_NOT_NULL(lp);
	CU_ASSERT_PTR_NOT_NULL(provider);
	CU_ASSERT_PTR_NOT_NULL(st);
	CU_ASSERT_PTR_NOT_NULL(ct);
45
	
Simon Morlat's avatar
Simon Morlat committed
46
	belle_sip_message("Casting belle_sip_server_transaction_t to belle_sip_transaction_t");
47
	t=BELLE_SIP_TRANSACTION(st);
Simon Morlat's avatar
Simon Morlat committed
48 49 50
	CU_ASSERT_PTR_NOT_NULL(t);
	belle_sip_message("Ok.");
	belle_sip_message("Casting belle_sip_client_transaction_t to belle_sip_transaction_t");
51
	t=BELLE_SIP_TRANSACTION(ct);
Simon Morlat's avatar
Simon Morlat committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	CU_ASSERT_PTR_NOT_NULL(t);
	belle_sip_message("Ok.");
	tmp=BELLE_SIP_IS_INSTANCE_OF(st,belle_sip_client_transaction_t);
	belle_sip_message("Casting belle_sip_server_transaction_t to belle_sip_client_transaction_t: %s",tmp ? "yes" : "no");
	CU_ASSERT_EQUAL(tmp,0);
	//ct=BELLE_SIP_CLIENT_TRANSACTION(st);
}


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

	if (NULL == CU_add_test(pSuite, "casting transactions", cast_test)) {
		return CU_get_error();
	}
67
}
Simon Morlat's avatar
Simon Morlat committed
68