Commit ca4ca81d authored by Dafydd Harries's avatar Dafydd Harries

add test for address code

darcs-hash:20070209191650-c9803-d69bcbde2e472c1b30e65889ab65a1c3b0aeef3e.gz
parent 24bceaa9
......@@ -3,6 +3,8 @@ include $(top_srcdir)/common.mk
AM_CFLAGS = -Wall -Werror $(GLIB_CFLAGS)
# library
noinst_LTLIBRARIES = libaddress.la
libaddress_la_SOURCES = \
......@@ -11,3 +13,11 @@ libaddress_la_SOURCES = \
pkginclude_HEADERS = address.h
# tests
check_PROGRAMS = test
test_LDADD = libaddress.la $(GLIB_LIBS)
TESTS = $(check_PROGRAMS)
#include <string.h>
#include "address.h"
int
main (void)
{
NiceAddress addr = {0,};
NiceAddress other = {0,};
gchar *str;
nice_address_set_ipv4 (&addr, 0x01020304);
g_assert (addr.type == NICE_ADDRESS_TYPE_IPV4);
str = nice_address_to_string (&addr);
g_assert (0 == strcmp (str, "1.2.3.4"));
g_free (str);
/* same address */
nice_address_set_ipv4 (&other, 0x01020304);
g_assert (TRUE == nice_address_equal (&addr, &other));
/* different IP */
nice_address_set_ipv4 (&other, 0x01020305);
g_assert (FALSE == nice_address_equal (&addr, &other));
/* different port */
nice_address_set_ipv4 (&other, 0x01020304);
addr.port = 1;
g_assert (FALSE == nice_address_equal (&addr, &other));
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment