summaryrefslogtreecommitdiffstats
path: root/unit/test-simutil.c
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2009-07-18 03:29:57 +0200
committerDenis Kenzior <denkenz@gmail.com>2009-07-17 23:48:29 -0500
commitd1a9ac78122b1c084b73175bca0fac18bf0224be (patch)
treefe3c6c4e15d2f8858059fd40974f5ca37767b8f6 /unit/test-simutil.c
parent35c48071f8f26ab0af1b6a2cbf154b41a6819067 (diff)
downloadofono-d1a9ac78122b1c084b73175bca0fac18bf0224be.tar.bz2
Test EONS handling.
Diffstat (limited to 'unit/test-simutil.c')
-rw-r--r--unit/test-simutil.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/unit/test-simutil.c b/unit/test-simutil.c
new file mode 100644
index 00000000..5945af00
--- /dev/null
+++ b/unit/test-simutil.c
@@ -0,0 +1,79 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <glib.h>
+
+#include "simutil.h"
+
+const unsigned char valid_efopl[] = {
+ 0x42, 0xf6, 0x1d, 0x00, 0x00, 0xff, 0xfe, 0x01,
+};
+
+const unsigned char valid_efpnn[][28] = {
+ { 0x43, 0x0a, 0x00, 0x54, 0x75, 0x78, 0x20, 0x43, 0x6f, 0x6d,
+ 0x6d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, },
+ { 0x43, 0x05, 0x00, 0x4C, 0x6F, 0x6E, 0x67, 0x45, 0x06, 0x00,
+ 0x53, 0x68, 0x6F, 0x72, 0x74, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }
+};
+
+static void test_eons()
+{
+ const struct sim_eons_operator_info *op_info;
+ struct sim_eons *eons_info;
+
+ eons_info = sim_eons_new(2);
+
+ g_assert(sim_eons_pnn_is_empty(eons_info));
+
+ sim_eons_add_pnn_record(eons_info, 1,
+ valid_efpnn[0], sizeof(valid_efpnn[0]));
+ g_assert(!sim_eons_pnn_is_empty(eons_info));
+
+ sim_eons_add_pnn_record(eons_info, 2,
+ valid_efpnn[1], sizeof(valid_efpnn[1]));
+ g_assert(!sim_eons_pnn_is_empty(eons_info));
+
+ sim_eons_add_opl_record(eons_info, valid_efopl, sizeof(valid_efopl));
+ sim_eons_optimize(eons_info);
+
+ op_info = sim_eons_lookup(eons_info, "246", "82");
+ g_assert(!op_info);
+ op_info = sim_eons_lookup(eons_info, "246", "81");
+ g_assert(op_info);
+
+ g_assert(!strcmp(op_info->longname, "Tux Comm"));
+ g_assert(!op_info->shortname);
+ g_assert(!op_info->info);
+
+ sim_eons_free(eons_info);
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/testsimutil/EONS Handling", test_eons);
+
+ return g_test_run();
+}