3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
#include "cdma-smsutil.h"
32
static inline void check_text(const char *decoded, const char *expected)
34
if (expected == NULL) {
35
g_assert(decoded == NULL);
39
g_assert(decoded != NULL);
40
g_assert(g_str_equal(decoded, expected));
43
struct wmt_deliver_test {
50
guint8 wmt_deliver_1[] = { 0x00, 0x00, 0x02, 0x10, 0x02, 0x02, 0x05, 0x01,
51
0xC4, 0x8D, 0x15, 0x9C, 0x08, 0x0D, 0x00,
52
0x03, 0x1B, 0xEE, 0xF0, 0x01, 0x06, 0x10,
53
0x2C, 0x8C, 0xBB, 0x36, 0x6F };
55
guint8 wmt_deliver_2[] = { 0x00, 0x00, 0x02, 0x10, 0x02, 0x02, 0x07, 0x02,
56
0xA1, 0x62, 0x51, 0x55, 0xA6, 0x40, 0x08,
57
0x18, 0x00, 0x03, 0x10, 0x00, 0x40, 0x01,
58
0x06, 0x10, 0x25, 0x4C, 0xBC, 0xFA, 0x00,
59
0x03, 0x06, 0x03, 0x08, 0x20, 0x13, 0x43,
60
0x12, 0x0D, 0x01, 0x01 };
62
static struct wmt_deliver_test wmt_deliver_data_1 = {
63
.tpdu = wmt_deliver_1,
64
.tpdu_len = sizeof(wmt_deliver_1),
69
static struct wmt_deliver_test wmt_deliver_data_2 = {
70
.tpdu = wmt_deliver_2,
71
.tpdu_len = sizeof(wmt_deliver_2),
76
static void test_wmt_deliver(gconstpointer data)
78
const struct wmt_deliver_test *test = data;
84
memset(&s, 0, sizeof(struct cdma_sms));
86
ret = cdma_sms_decode(test->tpdu, test->tpdu_len, &s);
88
g_assert(ret == TRUE);
90
g_assert(s.type == CDMA_SMS_TP_MSG_TYPE_P2P);
92
g_assert(s.p2p_msg.teleservice_id == CDMA_SMS_TELESERVICE_ID_WMT);
94
addr = cdma_sms_address_to_string(&s.p2p_msg.oaddr);
95
check_text(addr, test->oaddr);
97
message = cdma_sms_decode_text(&s.p2p_msg.bd.wmt_deliver.ud);
98
check_text(message, test->text);
103
int main(int argc, char **argv)
105
g_test_init(&argc, &argv, NULL);
107
g_test_add_data_func("/test-cdmasms/WMT DELIVER 1",
108
&wmt_deliver_data_1, test_wmt_deliver);
110
g_test_add_data_func("/test-cdmasms/WMT DELIVER 2",
111
&wmt_deliver_data_2, test_wmt_deliver);