[network-manager-applet/aleksander/mobile-providers: 19/19] libnm-gtk: added unit tests for the mobile provider database



commit d89e1f5d7ed005fbdc510b32d5334969ff1bc3ed
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Tue Nov 27 20:39:17 2012 +0100

    libnm-gtk: added unit tests for the mobile provider database

 .gitignore                                    |    2 +-
 configure.ac                                  |    1 +
 src/libnm-gtk/Makefile.am                     |    2 +
 src/libnm-gtk/tests/Makefile.am               |   22 +
 src/libnm-gtk/tests/iso3166-test.xml          |   69 ++++
 src/libnm-gtk/tests/serviceproviders-test.xml |   53 +++
 src/libnm-gtk/tests/test-mobile-providers.c   |  522 +++++++++++++++++++++++++
 7 files changed, 670 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ef5d40c..9b1d8b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,10 +41,10 @@ src/connection-editor/nm-connection-editor-service-glue.h
 src/libnm-gtk/libnm-gtk.pc
 src/libnm-gtk/NMGtk-1.0.gir
 src/libnm-gtk/NMGtk-1.0.typelib
+src/libnm-gtk/tests/test-mobile-providers
 src/marshallers/nma-marshal.*
 src/nm-applet
 src/nm-applet-migration-tool
 src/applet-dbus-bindings.h
 
 src/gconf-helpers/tests/test-upgrade
-
diff --git a/configure.ac b/configure.ac
index b41f015..c202fe6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -250,6 +250,7 @@ AC_CONFIG_FILES([
 Makefile
 src/Makefile
 src/libnm-gtk/Makefile
+src/libnm-gtk/tests/Makefile
 src/libnm-gtk/libnm-gtk.pc
 src/marshallers/Makefile
 src/utils/Makefile
diff --git a/src/libnm-gtk/Makefile.am b/src/libnm-gtk/Makefile.am
index 5a9266e..70039af 100644
--- a/src/libnm-gtk/Makefile.am
+++ b/src/libnm-gtk/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = . tests
+
 uidir = $(datadir)/libnm-gtk
 ui_DATA = wifi.ui
 
diff --git a/src/libnm-gtk/tests/Makefile.am b/src/libnm-gtk/tests/Makefile.am
new file mode 100644
index 0000000..ef1e117
--- /dev/null
+++ b/src/libnm-gtk/tests/Makefile.am
@@ -0,0 +1,22 @@
+
+noinst_PROGRAMS = \
+	test-mobile-providers
+
+test_mobile_providers_SOURCES = \
+	test-mobile-providers.c
+
+test_mobile_providers_CPPFLAGS = \
+	$(NMA_CFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/src/libnm-gtk \
+	-DTEST_DATA_DIR=\""$(abs_top_srcdir)/src/libnm-gtk/tests"\"
+
+test_mobile_providers_LDADD = \
+	$(top_builddir)/src/libnm-gtk/libnm-gtk.la \
+	$(NMA_LIBS)
+
+check-local: test-mobile-providers
+	$(abs_builddir)/test-mobile-providers
+
+
+EXTRA_DIST =
diff --git a/src/libnm-gtk/tests/iso3166-test.xml b/src/libnm-gtk/tests/iso3166-test.xml
new file mode 100644
index 0000000..c733ce6
--- /dev/null
+++ b/src/libnm-gtk/tests/iso3166-test.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+      This file is just a chunk of the original iso 3166 database file,
+      used solely for testing purposes.
+-->
+
+<!--
+This file gives a list of all countries in the ISO 3166
+standard, and is used to provide translations via gettext
+
+Copyright (C) 2002, 2004, 2006 Alastair McKinstry <mckinstry computer org>
+Copyright (C) 2004 Andreas Jochens <aj andaco de>
+Copyright (C) 2004, 2007 Christian Perrier <bubulle debian org>
+Copyright (C) 2005, 2006, 2007 Tobias Quathamer <toddy debian org>
+
+    This file is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This file 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this file; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Source: <http://www.iso.org/iso/country_codes>
+-->
+
+<!DOCTYPE iso_3166_entries [
+	<!ELEMENT iso_3166_entries (iso_3166_entry+, iso_3166_3_entry*)>
+	<!ELEMENT iso_3166_entry EMPTY>
+	<!ATTLIST iso_3166_entry
+		alpha_2_code		CDATA	#REQUIRED
+		alpha_3_code		CDATA	#REQUIRED
+		numeric_code		CDATA	#REQUIRED
+		common_name		CDATA	#IMPLIED
+		name			CDATA	#REQUIRED
+		official_name		CDATA	#IMPLIED
+	>
+	<!ELEMENT iso_3166_3_entry EMPTY>
+	<!ATTLIST iso_3166_3_entry
+		alpha_4_code		CDATA	#REQUIRED
+		alpha_3_code		CDATA	#REQUIRED
+		numeric_code		CDATA	#IMPLIED
+		date_withdrawn		CDATA	#IMPLIED
+		names			CDATA	#REQUIRED
+		comment			CDATA	#IMPLIED
+	>
+]>
+
+<iso_3166_entries>
+	<iso_3166_entry
+		alpha_2_code="ES"
+		alpha_3_code="ESP"
+		numeric_code="724"
+		name="Spain"
+		official_name="Kingdom of Spain" />
+	<iso_3166_entry
+		alpha_2_code="US"
+		alpha_3_code="USA"
+		numeric_code="840"
+		name="United States"
+		official_name="United States of America" />
+</iso_3166_entries>
diff --git a/src/libnm-gtk/tests/serviceproviders-test.xml b/src/libnm-gtk/tests/serviceproviders-test.xml
new file mode 100644
index 0000000..0d6d4fd
--- /dev/null
+++ b/src/libnm-gtk/tests/serviceproviders-test.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!-- -*- Mode: XML; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- -->
+
+<!DOCTYPE serviceproviders SYSTEM "serviceproviders.2.dtd">
+
+<serviceproviders format="2.0">
+
+  <!-- United States -->
+  <country code="us">
+    <provider>
+      <name>AT&amp;T</name>
+      <gsm>
+	    <network-id mcc="310" mnc="038"/>
+	    <network-id mcc="310" mnc="090"/>
+	    <network-id mcc="310" mnc="150"/>
+		<apn value="wap.cingular">
+		  <plan type="postpaid"/>
+		  <usage type="internet"/>
+		  <name>MEdia Net (phones)</name>
+		</apn>
+      </gsm>
+    </provider>
+    <provider>
+      <name>Verizon</name>
+      <cdma>
+	    <sid value="2"/>
+	    <sid value="4"/>
+	    <sid value="5"/>
+      </cdma>
+    </provider>
+  </country>
+
+  <!-- Spain -->
+  <country code="es">
+    <provider>
+      <name>Movistar (TelefÃnica)</name>
+      <gsm>
+	    <network-id mcc="214" mnc="05"/>
+	    <network-id mcc="214" mnc="07"/>
+		<apn value="movistar.es">
+		  <plan type="postpaid"/>
+		  <usage type="internet"/>
+		  <username>movistar</username>
+		  <password>movistar</password>
+		  <dns>194.179.1.100</dns>
+		  <dns>194.179.1.101</dns>
+		</apn>
+      </gsm>
+    </provider>
+  </country>
+
+</serviceproviders>
diff --git a/src/libnm-gtk/tests/test-mobile-providers.c b/src/libnm-gtk/tests/test-mobile-providers.c
new file mode 100644
index 0000000..513c3a6
--- /dev/null
+++ b/src/libnm-gtk/tests/test-mobile-providers.c
@@ -0,0 +1,522 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * 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 2 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:
+ *
+ * Copyright (C) 2012 Aleksander Morgado <aleksander gnu org>
+ */
+
+#include <locale.h>
+#include <string.h>
+
+#include "nm-mobile-providers.h"
+
+#if defined TEST_DATA_DIR
+#  define COUNTRY_CODES_FILE     TEST_DATA_DIR "/iso3166-test.xml"
+#  define SERVICE_PROVIDERS_FILE TEST_DATA_DIR "/serviceproviders-test.xml"
+#else
+#  error You broke it!
+#endif
+
+/******************************************************************************/
+/* Common test utilities */
+
+static NMAMobileProvidersDatabase *
+common_create_mpd_sync (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	GError *error = NULL;
+
+	mpd = nma_mobile_providers_database_new_sync (COUNTRY_CODES_FILE,
+	                                              SERVICE_PROVIDERS_FILE,
+	                                              NULL, /* cancellable */
+	                                              &error);
+	g_assert_no_error (error);
+	g_assert (NMA_IS_MOBILE_PROVIDERS_DATABASE (mpd));
+
+	return mpd;
+}
+
+typedef struct {
+	NMAMobileProvidersDatabase *mpd;
+	GMainLoop *loop;
+} NewAsyncContext;
+
+static void
+new_ready (GObject *source,
+           GAsyncResult *res,
+		   NewAsyncContext *ctx)
+{
+	GError *error = NULL;
+
+	ctx->mpd = nma_mobile_providers_database_new_finish (res, &error);
+	g_assert_no_error (error);
+	g_assert (NMA_IS_MOBILE_PROVIDERS_DATABASE (ctx->mpd));
+
+	g_main_loop_quit (ctx->loop);
+}
+
+static NMAMobileProvidersDatabase *
+common_create_mpd_async (void)
+{
+	NewAsyncContext ctx;
+
+	ctx.loop = g_main_loop_new (NULL, FALSE);
+	ctx.mpd = NULL;
+
+	nma_mobile_providers_database_new (COUNTRY_CODES_FILE,
+									   SERVICE_PROVIDERS_FILE,
+	                                   NULL, /* cancellable */
+	                                   (GAsyncReadyCallback)new_ready,
+	                                   &ctx);
+	g_main_loop_run (ctx.loop);
+	g_main_loop_unref (ctx.loop);
+
+	return ctx.mpd;
+}
+
+/******************************************************************************/
+
+static void
+new_sync (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+
+	mpd = common_create_mpd_sync ();
+	g_object_unref (mpd);
+}
+
+static void
+new_async (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+
+	mpd = common_create_mpd_async ();
+	g_object_unref (mpd);
+}
+
+/******************************************************************************/
+
+static void
+dump (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	nma_mobile_providers_database_dump (mpd);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	nma_mobile_providers_database_dump (mpd);
+	g_object_unref (mpd);
+}
+
+/******************************************************************************/
+
+static void
+lookup_country (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMACountryInfo *country_info;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	country_info = nma_mobile_providers_database_lookup_country (mpd, "US");
+	g_assert (country_info != NULL);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	country_info = nma_mobile_providers_database_lookup_country (mpd, "US");
+	g_assert (country_info != NULL);
+	g_object_unref (mpd);
+}
+
+static void
+lookup_unknown_country (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMACountryInfo *country_info;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	country_info = nma_mobile_providers_database_lookup_country (mpd, "KK");
+	g_assert (country_info == NULL);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	country_info = nma_mobile_providers_database_lookup_country (mpd, "KK");
+	g_assert (country_info == NULL);
+	g_object_unref (mpd);
+}
+
+/******************************************************************************/
+
+static void
+lookup_3gpp_mccmnc_1 (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Look for a 3 digit MNC using a 3 digit MNC */
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "310150");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "AT&T");
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "310150");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "AT&T");
+	g_object_unref (mpd);
+}
+
+static void
+lookup_3gpp_mccmnc_2 (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Look for a 3 digit MNC using a 2 digit MNC */
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "31038");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "AT&T");
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "31038");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "AT&T");
+	g_object_unref (mpd);
+}
+
+static void
+lookup_3gpp_mccmnc_3 (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Look for a 2 digit MNC using a 2 digit MNC */
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "21405");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Movistar (TelefÃnica)");
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "21405");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Movistar (TelefÃnica)");
+	g_object_unref (mpd);
+}
+
+static void
+lookup_3gpp_mccmnc_4 (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Look for a 2 digit MNC using a 3 digit MNC */
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "214005");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Movistar (TelefÃnica)");
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "214005");
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Movistar (TelefÃnica)");
+	g_object_unref (mpd);
+}
+
+static void
+lookup_unknown_3gpp_mccmnc (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "12345");
+	g_assert (provider == NULL);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "12345");
+	g_assert (provider == NULL);
+	g_object_unref (mpd);
+}
+
+static void
+ensure_movistar (NMAMobileProvider *provider)
+{
+	NMAMobileAccessMethod *method;
+
+	/* Check Name */
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Movistar (TelefÃnica)");
+
+	/* Check MCCMNC values */
+	{
+		const gchar **mcc_mnc;
+		guint i;
+		gboolean found_21405 = FALSE;
+		gboolean found_21407 = FALSE;
+
+		mcc_mnc = nma_mobile_provider_get_3gpp_mcc_mnc (provider);
+		g_assert (mcc_mnc != NULL);
+		for (i = 0; mcc_mnc[i]; i++) {
+			if (!strcmp (mcc_mnc[i], "21405")) {
+				g_assert (!found_21405);
+				found_21405 = TRUE;
+			} else if (!strcmp (mcc_mnc[i], "21407")) {
+				g_assert (!found_21407);
+				found_21407 = TRUE;
+			} else
+				g_assert_not_reached ();
+		}
+		g_assert (found_21405);
+		g_assert (found_21407);
+	}
+
+	/* Check SID */
+	g_assert (nma_mobile_provider_get_cdma_sid (provider) == NULL);
+
+	/* Check access methods */
+	{
+		GSList *methods;
+
+		methods = nma_mobile_provider_get_methods (provider);
+		g_assert_cmpuint (g_slist_length (methods), ==, 1);
+		method = methods->data;
+	}
+
+	/* Check access method name, APN and type */
+	g_assert_cmpstr (nma_mobile_access_method_get_name (method), ==, "Default");
+	g_assert_cmpint (nma_mobile_access_method_get_family (method), ==, NMA_MOBILE_FAMILY_3GPP);
+	g_assert_cmpstr (nma_mobile_access_method_get_3gpp_apn (method), ==, "movistar.es");
+
+	/* Check DNS */
+	{
+		const gchar **dns;
+		guint i;
+		gboolean found_100 = FALSE;
+		gboolean found_101 = FALSE;
+
+		dns = nma_mobile_access_method_get_dns (method);
+		g_assert (dns != NULL);
+		for (i = 0; dns[i]; i++) {
+			if (!strcmp (dns[i], "194.179.1.100")) {
+				g_assert (!found_100);
+				found_100 = TRUE;
+			} else if (!strcmp (dns[i], "194.179.1.101")) {
+				g_assert (!found_101);
+				found_101 = TRUE;
+			} else
+				g_assert_not_reached ();
+		}
+		g_assert (found_100);
+		g_assert (found_101);
+	}
+
+	/* Check Username and Password */
+	g_assert_cmpstr (nma_mobile_access_method_get_username (method), ==, "movistar");
+	g_assert_cmpstr (nma_mobile_access_method_get_password (method), ==, "movistar");
+}
+
+static void
+ensure_provider_contents_3gpp (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "21405");
+	g_assert (provider != NULL);
+	ensure_movistar (provider);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_3gpp_mcc_mnc (mpd, "21405");
+	g_assert (provider != NULL);
+	ensure_movistar (provider);
+	g_object_unref (mpd);
+}
+
+/******************************************************************************/
+
+static void
+lookup_cdma_sid (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_cdma_sid (mpd, 2);
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Verizon");
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_cdma_sid (mpd, 2);
+	g_assert (provider != NULL);
+	g_assert_cmpstr (nma_mobile_provider_get_name (provider), ==, "Verizon");
+	g_object_unref (mpd);
+}
+
+static void
+lookup_unknown_cdma_sid (void)
+{
+	NMAMobileProvidersDatabase *mpd;
+	NMAMobileProvider *provider;
+
+	/* Sync */
+	mpd = common_create_mpd_sync ();
+	provider = nma_mobile_providers_database_lookup_cdma_sid (mpd, 42);
+	g_assert (provider == NULL);
+	g_object_unref (mpd);
+
+	/* Async */
+	mpd = common_create_mpd_async ();
+	provider = nma_mobile_providers_database_lookup_cdma_sid (mpd, 42);
+	g_assert (provider == NULL);
+	g_object_unref (mpd);
+}
+
+/******************************************************************************/
+
+static void
+split_mccmnc_1 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("123456", &mcc, &mnc));
+	g_assert_cmpstr (mcc, == , "123");
+	g_assert_cmpstr (mnc, == , "456");
+	g_free (mcc);
+	g_free (mnc);
+}
+
+static void
+split_mccmnc_2 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("12345", &mcc, &mnc));
+	g_assert_cmpstr (mcc, == , "123");
+	g_assert_cmpstr (mnc, == , "45");
+	g_free (mcc);
+	g_free (mnc);
+}
+
+static void
+split_mccmnc_error_1 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("1", &mcc, &mnc) == FALSE);
+	g_assert (mcc == NULL);
+	g_assert (mnc == NULL);
+}
+
+static void
+split_mccmnc_error_2 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("123", &mcc, &mnc) == FALSE);
+	g_assert (mcc == NULL);
+	g_assert (mnc == NULL);
+}
+
+static void
+split_mccmnc_error_3 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("1234567", &mcc, &mnc) == FALSE);
+	g_assert (mcc == NULL);
+	g_assert (mnc == NULL);
+}
+
+static void
+split_mccmnc_error_4 (void)
+{
+	gchar *mcc = NULL;
+	gchar *mnc = NULL;
+
+	g_assert (nma_mobile_providers_split_3gpp_mcc_mnc ("123ab", &mcc, &mnc) == FALSE);
+	g_assert (mcc == NULL);
+	g_assert (mnc == NULL);
+}
+
+/******************************************************************************/
+
+int main (int argc, char **argv)
+{
+    setlocale (LC_ALL, "");
+
+    g_type_init ();
+    g_test_init (&argc, &argv, NULL);
+
+    g_test_add_func ("/MobileProvidersDatabase/new-sync",  new_sync);
+    g_test_add_func ("/MobileProvidersDatabase/new-async", new_async);
+
+    g_test_add_func ("/MobileProvidersDatabase/dump",  dump);
+
+    g_test_add_func ("/MobileProvidersDatabase/lookup-country",         lookup_country);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-unknown-country", lookup_unknown_country);
+
+    g_test_add_func ("/MobileProvidersDatabase/lookup-3gpp-mccmnc-1",          lookup_3gpp_mccmnc_1);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-3gpp-mccmnc-2",          lookup_3gpp_mccmnc_2);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-3gpp-mccmnc-3",          lookup_3gpp_mccmnc_3);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-3gpp-mccmnc-4",          lookup_3gpp_mccmnc_4);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-unknown-3gpp-mccmnc",    lookup_unknown_3gpp_mccmnc);
+	g_test_add_func ("/MobileProvidersDatabase/ensure-providers-content-3gpp", ensure_provider_contents_3gpp);
+
+    g_test_add_func ("/MobileProvidersDatabase/lookup-cdma-sid",         lookup_cdma_sid);
+    g_test_add_func ("/MobileProvidersDatabase/lookup-unknown-cdma-sid", lookup_unknown_cdma_sid);
+
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-1",       split_mccmnc_1);
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-2",       split_mccmnc_2);
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-error-1", split_mccmnc_error_1);
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-error-2", split_mccmnc_error_2);
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-error-3", split_mccmnc_error_3);
+    g_test_add_func ("/MobileProvidersDatabase/split-mccmnc-error-4", split_mccmnc_error_4);
+
+    return g_test_run ();
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]