Holger Hans Peter Freyther | a7328a5 | 2013-07-13 17:09:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2013 by Holger Hans Peter Freyther |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | #include <openbsc/debug.h> |
| 24 | |
| 25 | #include <osmocom/core/application.h> |
| 26 | #include <osmocom/core/backtrace.h> |
| 27 | |
| 28 | #include "smpp_smsc.h" |
| 29 | |
| 30 | struct coding_test { |
| 31 | uint8_t dcs; |
| 32 | uint8_t coding; |
| 33 | int mode; |
| 34 | int res; |
| 35 | }; |
| 36 | |
| 37 | static struct coding_test codecs[] = { |
| 38 | { .dcs = 0xf6 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 }, |
| 39 | { .dcs = 0xf2 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 }, |
| 40 | { .dcs = 0x02 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 }, |
| 41 | { .dcs = 0x06 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 }, |
| 42 | { .dcs = 0x0A , .coding = 0x08, .mode = MODE_8BIT, .res = 0 }, |
| 43 | { .dcs = 0x0E , .coding = 0xFF, .mode = 0xFF, .res = -1 }, |
| 44 | { .dcs = 0xE0 , .coding = 0xFF, .mode = 0xFF, .res = -1 }, |
| 45 | }; |
| 46 | |
| 47 | static void test_coding_scheme(void) |
| 48 | { |
| 49 | int i; |
| 50 | printf("Testing coding scheme support\n"); |
| 51 | |
| 52 | for (i = 0; i < ARRAY_SIZE(codecs); ++i) { |
| 53 | uint8_t coding; |
| 54 | int mode, res; |
| 55 | |
| 56 | res = smpp_determine_scheme(codecs[i].dcs, &coding, &mode); |
| 57 | OSMO_ASSERT(res == codecs[i].res); |
| 58 | if (res != -1) { |
| 59 | OSMO_ASSERT(mode == codecs[i].mode); |
| 60 | OSMO_ASSERT(coding == codecs[i].coding); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | int main(int argc, char **argv) |
| 66 | { |
| 67 | osmo_init_logging(&log_info); |
| 68 | log_set_use_color(osmo_stderr_target, 0); |
| 69 | log_set_print_filename(osmo_stderr_target, 0); |
| 70 | |
| 71 | test_coding_scheme(); |
| 72 | return EXIT_SUCCESS; |
| 73 | } |