summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2014-04-08 20:48:15 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2014-05-15 09:44:00 -0400
commit218667da2ad1411b4ab722858e67c2a8c7e716e8 (patch)
treeab0891475254f88b5b903559cc31bf097b6abea8 /tests
parentf8a095da3bca0574289b83b5ec0e561c9831324d (diff)
downloadlibnice-218667da2ad1411b4ab722858e67c2a8c7e716e8.tar.gz
test-priority: Unit test various configurations of candidate priorities
Diffstat (limited to 'tests')
-rw-r--r--tests/test-priority.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/test-priority.c b/tests/test-priority.c
index 7a52c3c..df8a629 100644
--- a/tests/test-priority.c
+++ b/tests/test-priority.c
@@ -47,22 +47,37 @@ main (void)
/* test 1 */
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_HOST);
+ g_assert (nice_candidate_jingle_priority (candidate) == 1000);
+ /* Host UDP */
candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
candidate->component_id = 1;
g_assert (nice_candidate_ice_priority (candidate, FALSE, FALSE) == 0x780001FF);
- g_assert (nice_candidate_jingle_priority (candidate) == 1000);
+ /* Host UDP-tunneled reliable */
+ g_assert (nice_candidate_ice_priority (candidate, TRUE, FALSE) == 0x4B0001FF);
+ /* Host tcp-active unreliable */
+ candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
+ g_assert (nice_candidate_ice_priority (candidate, FALSE, FALSE) == 0x3BC001FF);
+ /* Host tcp-active reliable */
+ candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
+ /* Host tcp-active reliable */
+ g_assert (nice_candidate_ice_priority (candidate, TRUE, FALSE) == 0x78C001FF);
+ /* srv-reflexive tcp-active reliable */
+ candidate->type = NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE;
+ candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
+ g_assert (nice_candidate_ice_priority (candidate, TRUE, FALSE) == 0x648001FF);
+ /* nat-assisted srv-reflexive tcp-active reliable */
+ g_assert (nice_candidate_ice_priority (candidate, TRUE, TRUE) == 0x698001FF);
nice_candidate_free (candidate);
/* test 2 */
-
- /* 2^32*MIN(O,A) + 2*MAX(O,A) + (O>A?1:0)
- = 2^32*1 + 2*5000 + 0
+ /* 2^32*MIN(O,A) + 2*MAX(O,A) + (O>A?1:0)
+ = 2^32*1 + 2*5000 + 0
= 4294977296 */
g_assert (nice_candidate_pair_priority (1,5000) == 4294977296LL);
/* 2^32*1 + 2*5000 + 1 = 4294977297 */
g_assert (nice_candidate_pair_priority (5000, 1) == 4294977297LL);
-
+
return 0;
}