]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11453 [mod_rayo] convert to fst testing
authorChris Rienzo <chris@signalwire.com>
Fri, 12 Oct 2018 22:00:31 +0000 (22:00 +0000)
committerChris Rienzo <chris@signalwire.com>
Thu, 20 Dec 2018 15:18:14 +0000 (10:18 -0500)
24 files changed:
configure.ac
src/include/test/switch_test.h
src/mod/event_handlers/mod_rayo/Makefile.am
src/mod/event_handlers/mod_rayo/iks_helpers.h
src/mod/event_handlers/mod_rayo/mod_rayo.h
src/mod/event_handlers/mod_rayo/nlsml.h
src/mod/event_handlers/mod_rayo/rayo_components.h
src/mod/event_handlers/mod_rayo/rayo_cpa_component.h
src/mod/event_handlers/mod_rayo/rayo_cpa_detector.h
src/mod/event_handlers/mod_rayo/sasl.h
src/mod/event_handlers/mod_rayo/srgs.h
src/mod/event_handlers/mod_rayo/test.h [deleted file]
src/mod/event_handlers/mod_rayo/test/Makefile.am [new file with mode: 0644]
src/mod/event_handlers/mod_rayo/test/test_iks.c [new file with mode: 0644]
src/mod/event_handlers/mod_rayo/test/test_nlsml.c [moved from src/mod/event_handlers/mod_rayo/test_nlsml/main.c with 86% similarity]
src/mod/event_handlers/mod_rayo/test/test_srgs.c [moved from src/mod/event_handlers/mod_rayo/test_srgs/main.c with 57% similarity]
src/mod/event_handlers/mod_rayo/test_iks/Makefile [deleted file]
src/mod/event_handlers/mod_rayo/test_iks/main.c [deleted file]
src/mod/event_handlers/mod_rayo/test_iks/test_iks.c [deleted file]
src/mod/event_handlers/mod_rayo/test_nlsml/Makefile [deleted file]
src/mod/event_handlers/mod_rayo/test_nlsml/test_nlsml.c [deleted file]
src/mod/event_handlers/mod_rayo/test_srgs/Makefile [deleted file]
src/mod/event_handlers/mod_rayo/test_srgs/test_srgs.c [deleted file]
src/mod/event_handlers/mod_rayo/xmpp_streams.h

index 4106fa0b1950a1ad65530aaa9dd8374eee14e838..377eea25ec3884cc72cd153c4d2f93bfa97ee302 100644 (file)
@@ -1929,6 +1929,7 @@ AC_CONFIG_FILES([Makefile
                src/mod/event_handlers/mod_radius_cdr/Makefile
                src/mod/event_handlers/mod_odbc_cdr/Makefile
                src/mod/event_handlers/mod_rayo/Makefile
+               src/mod/event_handlers/mod_rayo/test/Makefile
                src/mod/event_handlers/mod_smpp/Makefile
                src/mod/event_handlers/mod_snmp/Makefile
                src/mod/event_handlers/mod_event_zmq/Makefile
index cb6ba306debdf4eb39c00344e31e9a6809ddbc41..97fb9500d16b2fadd372e28ce43c3ef8be5330b4 100644 (file)
@@ -37,7 +37,6 @@
 
 /**
  * Get environment variable and save to var
- ( )
  */
 static char *fst_getenv_default(const char *env, char *default_value, switch_bool_t required)
 {
@@ -171,7 +170,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  */
 #define fst_check_int_range(actual, expected, precision) \
        fct_xchk( \
-               abs((val - expected)) <= precision, \
+               abs((actual - expected)) <= precision, \
                "fst_check_int_range: %d != %d +/- %d", \
                (actual), \
                (expected), \
@@ -183,13 +182,39 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  */
 #define fst_check_double_range(actual, expected, precision) \
        fct_xchk( \
-               fabs((val - expected)) <= precision, \
+               fabs((actual - expected)) <= precision, \
                "fst_check_double_range: %f != %f +/- %f", \
                (actual), \
                (expected), \
                (precision) \
        );
 
+/**
+ * Run test without loading FS core
+ */
+#define FST_BEGIN() \
+       FCT_BGN() \
+       { \
+               int fst_core = 0; \
+               switch_time_t fst_time_start = 0; \
+               switch_timer_t fst_timer = { 0 }; \
+               switch_memory_pool_t *fst_pool = NULL; \
+               fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
+               if (fst_core) { \
+                       fst_init_core_and_modload(NULL, NULL); /* shuts up compiler */ \
+               } \
+               { \
+
+
+#define FST_END() \
+               } \
+               if (fst_time_start) { \
+                       /* shut up compiler */ \
+                       fst_time_start = 0; \
+               } \
+       } \
+       FCT_END()
+
 /**
  * Define the beginning of a freeswitch core test driver.  Only one per test application allowed.
  * @param confdir directory containing freeswitch.xml configuration
@@ -197,12 +222,13 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 #define FST_CORE_BEGIN(confdir) \
        FCT_BGN() \
        { \
+               int fst_core = 1; \
                switch_time_t fst_time_start = 0; \
                switch_timer_t fst_timer = { 0 }; \
                switch_memory_pool_t *fst_pool = NULL; \
                fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
                fst_init_core_and_modload(confdir, NULL); \
-               { \
+               {
 
 /**
  * Define the end of a freeswitch core test driver.
@@ -210,6 +236,10 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 #define FST_CORE_END() \
                /*switch_core_destroy();*/ \
                } \
+               if (fst_time_start) { \
+                       /* shut up compiler */ \
+                       fst_time_start = 0; \
+               } \
        } \
        FCT_END()
 
@@ -222,6 +252,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 #define FST_MODULE_BEGIN(modname,suite) \
        { \
                const char *fst_test_module = #modname; \
+               fst_requires(fst_core); \
                if (!zstr(fst_test_module)) { \
                        const char *err; \
                        switch_loadable_module_load_module((char *)"../.libs", (char *)fst_test_module, SWITCH_FALSE, &err); \
@@ -259,10 +290,12 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  */
 #define FST_SETUP_BEGIN() \
        FCT_SETUP_BGN() \
-               switch_core_new_memory_pool(&fst_pool); \
-               fst_requires(fst_pool != NULL); \
-               fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \
-               fst_time_mark();
+               if (fst_core) { \
+                       switch_core_new_memory_pool(&fst_pool); \
+                       fst_requires(fst_pool != NULL); \
+                       fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \
+                       fst_time_mark(); \
+               }
 
 /**
  * Define the end of test suite setup.
@@ -275,8 +308,10 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  */
 #define FST_TEARDOWN_BEGIN() \
        FCT_TEARDOWN_BGN() \
-               switch_core_destroy_memory_pool(&fst_pool); \
-               switch_core_timer_destroy(&fst_timer);
+               if (fst_core) { \
+                       switch_core_destroy_memory_pool(&fst_pool); \
+                       switch_core_timer_destroy(&fst_timer); \
+               }
 
 /**
  * Define the test suite teardown end.
@@ -323,6 +358,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
                switch_core_session_t *fst_session = NULL; \
                switch_event_t *fst_originate_vars = NULL; \
                switch_call_cause_t fst_cause = SWITCH_CAUSE_NORMAL_CLEARING; \
+               fst_requires(fst_core); \
                if (fst_test_module) { \
                        fst_requires_module(fst_test_module); \
                } \
@@ -387,6 +423,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
        char *fst_asr_result = NULL; \
        switch_asr_handle_t ah = { 0 }; \
        switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; \
+       fst_requires(fst_core); \
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Open recognizer: %s\n", recognizer); \
        /* open ASR interface and feed recorded audio into it and collect result */ \
        fst_requires(switch_core_asr_open(&ah, recognizer, "L16", 8000, "", &flags, fst_pool) == SWITCH_STATUS_SUCCESS); \
@@ -419,6 +456,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
        fst_asr_result = NULL; \
        file_handle.channels = 1; \
        file_handle.native_rate = 8000; \
+       fst_requires(fst_core); \
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Test recognizer: input = %s\n", input_filename); \
        fst_requires(switch_core_asr_load_grammar(&ah, grammar, "") == SWITCH_STATUS_SUCCESS); \
        fst_requires(switch_core_file_open(&file_handle, input_filename, file_handle.channels, 8000, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS); \
@@ -461,6 +499,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  *    switch_core_asr_pause(&ah) == SWITCH_STATUS_SUCCESS
  */
 #define fst_test_core_asr_pause() \
+       fst_requires(fst_core); \
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Pause recognizer\n"); \
        flags = SWITCH_ASR_FLAG_NONE; \
        fst_requires(switch_core_asr_pause(&ah) == SWITCH_STATUS_SUCCESS);
@@ -472,6 +511,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  *    switch_core_asr_resume(&ah) == SWITCH_STATUS_SUCCESS
  */
 #define fst_test_core_asr_resume() \
+       fst_requires(fst_core); \
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Resume recognizer\n"); \
        flags = SWITCH_ASR_FLAG_NONE; \
        fst_requires(switch_core_asr_resume(&ah) == SWITCH_STATUS_SUCCESS);     
@@ -483,6 +523,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  *   switch_core_asr_close(&ah, flags) == SWITCH_STATUS_SUCCESS
  */
 #define fst_test_core_asr_close() \
+       fst_requires(fst_core); \
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Close recognizer\n"); \
        flags = SWITCH_ASR_FLAG_NONE; \
        fst_requires(switch_core_asr_close(&ah, &flags) == SWITCH_STATUS_SUCCESS); \
@@ -500,7 +541,8 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
  */
 #define fst_play_and_detect_speech_test_begin() \
 { \
-       const char *fst_asr_result = NULL;
+       const char *fst_asr_result = NULL; \
+       fst_requires(fst_core);
 
 /**
  * Use play_and_detect_speech APP to test recognizer
@@ -524,6 +566,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 #define fst_play_and_detect_speech_app_test(recognizer, grammar, prompt_filename, input_filename) \
 { \
        char *args = NULL; \
+       fst_requires(fst_core); \
        fst_requires_module("mod_dptools"); \
        switch_channel_set_variable(fst_channel, "detect_speech_result", ""); \
        fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
@@ -555,6 +598,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 { \
        char *args = NULL; \
        fst_asr_result = NULL; \
+       fst_requires(fst_core); \
        fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
        switch_status_t status = switch_ivr_play_and_detect_speech(fst_session, prompt_filename, recognizer, grammar, (char **)&fst_asr_result, 0, input_args); \
        fst_check(fst_asr_result != NULL); \
@@ -580,6 +624,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 { \
        switch_stream_handle_t stream = { 0 }; \
        SWITCH_STANDARD_STREAM(stream); \
+       fst_requires(fst_core); \
        fst_requires_module("mod_commands"); \
        switch_status_t api_result = switch_api_execute("sched_api", switch_core_session_sprintf(fst_session, "%s none uuid_recv_dtmf %s %s", when, switch_core_session_get_uuid(fst_session), digits), NULL, &stream); \
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fst_session), SWITCH_LOG_INFO, "Injecting DTMF %s at %s\n", digits, when); \
index 5c0c5b40088542adbed8a952fd78fb8e5788d490..872329fde3d78812de0af9aa9e86948bb7d744a2 100644 (file)
@@ -17,3 +17,5 @@ BUILT_SOURCES=$(IKS_LA)
 $(IKS_LA): $(IKS_BUILDDIR) $(IKS_DIR) $(IKS_DIR)/.update
        @cd $(IKS_BUILDDIR) && $(MAKE)
        @$(TOUCH_TARGET)
+
+SUBDIRS=. test
index 2017134713fb4741bb5a0c6a1186c36beb6b0581..e221abe390f3fc7061233d9a3ff7d942acf05961 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -51,50 +51,50 @@ struct xmpp_error {
 
 #undef XMPP_ERROR
 #define XMPP_ERROR(def_name, name, type) \
-       extern const struct xmpp_error def_name##_val; \
-       extern const struct xmpp_error *def_name;
+       SWITCH_DECLARE(const struct xmpp_error) def_name##_val; \
+       SWITCH_DECLARE(const struct xmpp_error *) def_name;
 #include "xmpp_errors.def"
 
 /* See RFC-3920 XMPP core for error definitions */
-extern iks *iks_new_presence(const char *name, const char *namespace, const char *from, const char *to);
-extern iks *iks_new_error(iks *iq, const struct xmpp_error *err);
-extern iks *iks_new_error_detailed(iks *iq, const struct xmpp_error *err, const char *detail_text);
-extern iks *iks_new_error_detailed_printf(iks *iq, const struct xmpp_error *err, const char *detail_text_format, ...);
-extern iks *iks_new_iq_result(iks *iq);
-extern const char *iks_find_attrib_soft(iks *xml, const char *attrib);
-extern const char *iks_find_attrib_default(iks *xml, const char *attrib, const char *def);
-extern int iks_find_bool_attrib(iks *xml, const char *attrib);
-extern int iks_find_int_attrib(iks *xml, const char *attrib);
-extern char iks_find_char_attrib(iks *xml, const char *attrib);
-extern double iks_find_decimal_attrib(iks *xml, const char *attrib);
-extern const char *iks_node_type_to_string(int type);
-extern const char *iks_net_error_to_string(int err);
-extern iks *iks_insert_attrib_printf(iks *xml, const char *name, const char *fmt, ...);
+SWITCH_DECLARE(iks *) iks_new_presence(const char *name, const char *namespace, const char *from, const char *to);
+SWITCH_DECLARE(iks *) iks_new_error(iks *iq, const struct xmpp_error *err);
+SWITCH_DECLARE(iks *) iks_new_error_detailed(iks *iq, const struct xmpp_error *err, const char *detail_text);
+SWITCH_DECLARE(iks *) iks_new_error_detailed_printf(iks *iq, const struct xmpp_error *err, const char *detail_text_format, ...);
+SWITCH_DECLARE(iks *) iks_new_iq_result(iks *iq);
+SWITCH_DECLARE(const char *) iks_find_attrib_soft(iks *xml, const char *attrib);
+SWITCH_DECLARE(const char *) iks_find_attrib_default(iks *xml, const char *attrib, const char *def);
+SWITCH_DECLARE(int) iks_find_bool_attrib(iks *xml, const char *attrib);
+SWITCH_DECLARE(int) iks_find_int_attrib(iks *xml, const char *attrib);
+SWITCH_DECLARE(char) iks_find_char_attrib(iks *xml, const char *attrib);
+SWITCH_DECLARE(double) iks_find_decimal_attrib(iks *xml, const char *attrib);
+SWITCH_DECLARE(const char *) iks_node_type_to_string(int type);
+SWITCH_DECLARE(const char *) iks_net_error_to_string(int err);
+SWITCH_DECLARE(iks *) iks_insert_attrib_printf(iks *xml, const char *name, const char *fmt, ...);
 
-extern char *iks_server_dialback_key(const char *secret, const char *receiving_server, const char *originating_server, const char *stream_id);
-extern void iks_sha_print_base64(iksha *sha, char *buf);
+SWITCH_DECLARE(char *) iks_server_dialback_key(const char *secret, const char *receiving_server, const char *originating_server, const char *stream_id);
+SWITCH_DECLARE(void) iks_sha_print_base64(iksha *sha, char *buf);
 
 /** A function to validate attribute value */
 typedef int (*iks_attrib_validation_function)(const char *);
 
-extern int validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib);
+SWITCH_DECLARE(int) validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib);
 
-#define ELEMENT_DECL(name) extern int VALIDATE_##name(iks *node);
+#define ELEMENT_DECL(name) SWITCH_DECLARE(int) VALIDATE_##name(iks *node);
 #define ELEMENT(name) int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0;
 #define ATTRIB(name, def, rule) result &= iks_attrib_is_##rule(iks_find_attrib_default(node, #name, #def));
 #define OPTIONAL_ATTRIB(name, def, rule) result &= validate_optional_attrib(iks_attrib_is_##rule, iks_find_attrib_default(node, #name, #def));
 #define STRING_ATTRIB(name, def, rule) result &= value_matches(iks_find_attrib_default(node, #name, #def), rule);
 #define ELEMENT_END return result; }
 
-extern int value_matches(const char *value, const char *rule);
+SWITCH_DECLARE(int) value_matches(const char *value, const char *rule);
 
-extern int iks_attrib_is_bool(const char *value);
-extern int iks_attrib_is_not_negative(const char *value);
-extern int iks_attrib_is_positive(const char *value);
-extern int iks_attrib_is_positive_or_neg_one(const char *value);
-extern int iks_attrib_is_any(const char *value);
-extern int iks_attrib_is_decimal_between_zero_and_one(const char *value);
-extern int iks_attrib_is_dtmf_digit(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_bool(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_not_negative(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_positive(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_positive_or_neg_one(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_any(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_decimal_between_zero_and_one(const char *value);
+SWITCH_DECLARE(int) iks_attrib_is_dtmf_digit(const char *value);
 
 #endif
 
index cefd4e17827272d429342983b4fed775ca814cba..2d066c4e21364c491c66cd3a0d9bac836ce1877c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -129,20 +129,20 @@ struct rayo_component {
 #define RAYO_CALL(x) ((struct rayo_call *)x)
 #define RAYO_MIXER(x) ((struct rayo_mixer *)x)
 
-extern void rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, int dup, int reply, const char *file, int line);
-extern void rayo_message_destroy(struct rayo_message *msg);
-extern iks *rayo_message_remove_payload(struct rayo_message *msg);
+SWITCH_DECLARE(void) rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, int dup, int reply, const char *file, int line);
+SWITCH_DECLARE(void) rayo_message_destroy(struct rayo_message *msg);
+SWITCH_DECLARE(iks *) rayo_message_remove_payload(struct rayo_message *msg);
 #define RAYO_SEND_MESSAGE(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 0, 0, __FILE__, __LINE__)
 #define RAYO_SEND_MESSAGE_DUP(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 1, 0, __FILE__, __LINE__)
 #define RAYO_SEND_REPLY(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 0, 1, __FILE__, __LINE__)
 #define RAYO_SEND_REPLY_DUP(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 1, 1, __FILE__, __LINE__)
 
-extern struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line);
-extern struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int line);
-extern int rayo_actor_seq_next(struct rayo_actor *actor);
-extern void rayo_actor_retain(struct rayo_actor *actor, const char *file, int line);
-extern void rayo_actor_release(struct rayo_actor *actor, const char *file, int line);
-extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
+SWITCH_DECLARE(struct rayo_actor *) rayo_actor_locate(const char *jid, const char *file, int line);
+SWITCH_DECLARE(struct rayo_actor *) rayo_actor_locate_by_id(const char *id, const char *file, int line);
+SWITCH_DECLARE(int) rayo_actor_seq_next(struct rayo_actor *actor);
+SWITCH_DECLARE(void) rayo_actor_retain(struct rayo_actor *actor, const char *file, int line);
+SWITCH_DECLARE(void) rayo_actor_release(struct rayo_actor *actor, const char *file, int line);
+SWITCH_DECLARE(void) rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
 
 #define RAYO_LOCATE(jid) rayo_actor_locate(jid, __FILE__, __LINE__)
 #define RAYO_LOCATE_BY_ID(id) rayo_actor_locate_by_id(id, __FILE__, __LINE__)
@@ -156,21 +156,21 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
 #define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__)
 #define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x))
 
-extern int rayo_call_is_joined(struct rayo_call *call);
-extern int rayo_call_is_faxing(struct rayo_call *call);
-extern void rayo_call_set_faxing(struct rayo_call *call, int faxing);
-extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
+SWITCH_DECLARE(int) rayo_call_is_joined(struct rayo_call *call);
+SWITCH_DECLARE(int) rayo_call_is_faxing(struct rayo_call *call);
+SWITCH_DECLARE(void) rayo_call_set_faxing(struct rayo_call *call, int faxing);
+SWITCH_DECLARE(const char *) rayo_call_get_dcp_jid(struct rayo_call *call);
 
 #define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
 
 #define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, NULL, __FILE__, __LINE__)
 #define rayo_component_init_cleanup(component, pool, type, subtype, id, parent, client_jid, cleanup) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, cleanup, __FILE__, __LINE__)
-extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line);
-extern switch_bool_t is_component_actor(struct rayo_actor *);
+SWITCH_DECLARE(struct rayo_component *) _rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line);
+SWITCH_DECLARE(switch_bool_t) is_component_actor(struct rayo_actor *);
 
 typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_message *, void *);
-extern void rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn);
-extern void rayo_actor_event_handler_add(const char *from_type, const char *from_subtype, const char *to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn);
+SWITCH_DECLARE(void) rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn);
+SWITCH_DECLARE(void) rayo_actor_event_handler_add(const char *from_type, const char *from_subtype, const char *to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn);
 
 #endif
 
index 475abd091e7a33930f9965d1a2962f9ff0d03cee..35f79adc26f958cd4870f9e26d5b31fbd0dc5500 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013-2014, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -39,12 +39,12 @@ enum nlsml_match_type {
        NMT_NOMATCH
 };
 
-extern int nlsml_init(void);
-extern void nlsml_destroy(void);
-enum nlsml_match_type nlsml_parse(const char *result, const char *uuid);
-iks *nlsml_normalize(const char *result);
-extern iks *nlsml_create_dtmf_match(const char *digits, const char *interpretation);
-extern iks *nlsml_create_match(const char *digits, const char *interpretation, const char *mode, int confidence);
+SWITCH_DECLARE(int) nlsml_init(void);
+SWITCH_DECLARE(void) nlsml_destroy(void);
+SWITCH_DECLARE(enum nlsml_match_type) nlsml_parse(const char *result, const char *uuid);
+SWITCH_DECLARE(iks *) nlsml_normalize(const char *result);
+SWITCH_DECLARE(iks *) nlsml_create_dtmf_match(const char *digits, const char *interpretation);
+SWITCH_DECLARE(iks *) nlsml_create_match(const char *digits, const char *interpretation, const char *mode, int confidence);
 
 #endif
 
index 6cd30757a11a63de2a37207b1dc122dfdd03b0b2..9be7881a4efb403fa02c5fabcdab16e96bb6e5a1 100644 (file)
 #define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS
 #define COMPONENT_COMPLETE_DONE "done", RAYO_EXT_COMPLETE_NS
 
-extern switch_status_t rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern switch_status_t rayo_exec_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-
-extern switch_status_t rayo_components_shutdown(void);
-extern switch_status_t rayo_input_component_shutdown(void);
-extern switch_status_t rayo_output_component_shutdown(void);
-extern switch_status_t rayo_prompt_component_shutdown(void);
-extern switch_status_t rayo_record_component_shutdown(void);
-extern switch_status_t rayo_fax_components_shutdown(void);
-extern switch_status_t rayo_exec_component_shutdown(void);
-
-extern void rayo_component_send_start(struct rayo_component *component, iks *iq);
-extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type);
-extern void rayo_component_send_iq_error_detailed(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type, const char *detail);
-extern void rayo_component_send_complete(struct rayo_component *component, const char *reason, const char *reason_namespace);
-extern void rayo_component_send_complete_event(struct rayo_component *component, iks *response);
-extern void rayo_component_send_complete_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
-extern void rayo_component_send_complete_with_metadata_string(struct rayo_component *component, const char *reason, const char *reason_namespace, const char *meta, int child_of_complete);
-
-extern iks *rayo_component_create_complete_event(struct rayo_component *component, const char *reason, const char *reason_namespace);
-extern iks *rayo_component_create_complete_event_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
-
-extern void rayo_component_api_execute_async(struct rayo_component *component, const char *cmd, const char *args);
+SWITCH_DECLARE(switch_status_t) rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(switch_status_t) rayo_exec_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+
+SWITCH_DECLARE(switch_status_t) rayo_components_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_input_component_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_output_component_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_prompt_component_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_record_component_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_fax_components_shutdown(void);
+SWITCH_DECLARE(switch_status_t) rayo_exec_component_shutdown(void);
+
+SWITCH_DECLARE(void) rayo_component_send_start(struct rayo_component *component, iks *iq);
+SWITCH_DECLARE(void) rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type);
+SWITCH_DECLARE(void) rayo_component_send_iq_error_detailed(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type, const char *detail);
+SWITCH_DECLARE(void) rayo_component_send_complete(struct rayo_component *component, const char *reason, const char *reason_namespace);
+SWITCH_DECLARE(void) rayo_component_send_complete_event(struct rayo_component *component, iks *response);
+SWITCH_DECLARE(void) rayo_component_send_complete_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
+SWITCH_DECLARE(void) rayo_component_send_complete_with_metadata_string(struct rayo_component *component, const char *reason, const char *reason_namespace, const char *meta, int child_of_complete);
+
+SWITCH_DECLARE(iks *) rayo_component_create_complete_event(struct rayo_component *component, const char *reason, const char *reason_namespace);
+SWITCH_DECLARE(iks *) rayo_component_create_complete_event_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
+
+SWITCH_DECLARE(void) rayo_component_api_execute_async(struct rayo_component *component, const char *cmd, const char *args);
 
 #define RAYO_COMPONENT_LOCATE(id) rayo_component_locate(id, __FILE__, __LINE__)
-extern struct rayo_component *rayo_component_locate(const char *id, const char *file, int line);
+SWITCH_DECLARE(struct rayo_component *) rayo_component_locate(const char *id, const char *file, int line);
 
 #endif
 
index 36354c9508548cca864ed2ef43da0e736e3fa8e5..442ec1f4c88da238eb324c6d4481086981451a10 100644 (file)
@@ -34,9 +34,9 @@
 
 #include "mod_rayo.h"
 
-extern switch_status_t rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern void rayo_cpa_component_shutdown(void);
-extern iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data);
+SWITCH_DECLARE(switch_status_t) rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(void) rayo_cpa_component_shutdown(void);
+SWITCH_DECLARE(iks *) rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data);
 
 #endif
 
index fcdc35f2f4bad557ded69247f26fb59bff99d136..fec720dadfdbaa53273c79a59d7985dd8ee48a25 100644 (file)
 
 #include "mod_rayo.h"
 
-extern switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
-extern void rayo_cpa_detector_shutdown(void);
-extern int rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail);
-extern void rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns);
+SWITCH_DECLARE(switch_status_t) rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
+SWITCH_DECLARE(void) rayo_cpa_detector_shutdown(void);
+SWITCH_DECLARE(int) rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail);
+SWITCH_DECLARE(void) rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns);
 
 #endif
 
index 17b4a99f66e601316a67fe6565d43886f67192ce..641bcfa064f48f0bfeb02548b8e9be2a673a0cab 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -29,7 +29,7 @@
 #ifndef SASL_H
 #define SASL_H
 
-extern void parse_plain_auth_message(const char *message, char **authzid, char **authcid, char **password);
+SWITCH_DECLARE(void) parse_plain_auth_message(const char *message, char **authzid, char **authcid, char **password);
 
 #endif
 
index cfe2c6c93a34e19896f12d205d2db942c46713c5..e32b522d3398aa0782d3d9ba20ce8252de242f1f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013-2014, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -45,15 +45,15 @@ enum srgs_match_type {
        SMT_MATCH_END
 };
 
-extern int srgs_init(void);
-extern void srgs_destroy(void);
-extern struct srgs_parser *srgs_parser_new(const char *uuid);
-extern struct srgs_grammar *srgs_parse(struct srgs_parser *parser, const char *document);
-extern const char *srgs_grammar_to_regex(struct srgs_grammar *grammar);
-extern const char *srgs_grammar_to_jsgf(struct srgs_grammar *grammar);
-extern const char *srgs_grammar_to_jsgf_file(struct srgs_grammar *grammar, const char *basedir, const char *ext);
-extern enum srgs_match_type srgs_grammar_match(struct srgs_grammar *grammar, const char *input, const char **interpretation);
-extern void srgs_parser_destroy(struct srgs_parser *parser);
+SWITCH_DECLARE(int) srgs_init(void);
+SWITCH_DECLARE(void) srgs_destroy(void);
+SWITCH_DECLARE(struct srgs_parser *) srgs_parser_new(const char *uuid);
+SWITCH_DECLARE(struct srgs_grammar *) srgs_parse(struct srgs_parser *parser, const char *document);
+SWITCH_DECLARE(const char *) srgs_grammar_to_regex(struct srgs_grammar *grammar);
+SWITCH_DECLARE(const char *) srgs_grammar_to_jsgf(struct srgs_grammar *grammar);
+SWITCH_DECLARE(const char *) srgs_grammar_to_jsgf_file(struct srgs_grammar *grammar, const char *basedir, const char *ext);
+SWITCH_DECLARE(enum srgs_match_type) srgs_grammar_match(struct srgs_grammar *grammar, const char *input, const char **interpretation);
+SWITCH_DECLARE(void) srgs_parser_destroy(struct srgs_parser *parser);
 
 #endif
 
diff --git a/src/mod/event_handlers/mod_rayo/test.h b/src/mod/event_handlers/mod_rayo/test.h
deleted file mode 100644 (file)
index 4b5d1e0..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013, Grasshopper
- *
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- *
- * The Initial Developer of the Original Code is Grasshopper
- * Portions created by the Initial Developer are Copyright (C)
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Chris Rienzo <chris.rienzo@grasshopper.com>
- *
- * test.h -- simple unit testing macros
- *
- */
-#ifndef TEST_H
-#define TEST_H
-
-#define assert_equals(test, expected_str, expected, actual, file, line) \
-{ \
-       int actual_val = actual; \
-       if (expected != actual_val) { \
-               printf("TEST\t%s\tFAIL\t%s\t%i\t!=\t%i\t%s:%i\n", test, expected_str, expected, actual_val, file, line); \
-               exit(1); \
-       } else { \
-               printf("TEST\t%s\tPASS\n", test); \
-       } \
-}
-
-#define assert_string_equals(test, expected, actual, file, line) \
-{ \
-       const char *actual_str = actual; \
-       if (!actual_str || strcmp(expected, actual_str)) { \
-               printf("TEST\t%s\tFAIL\t\t%s\t!=\t%s\t%s:%i\n", test, expected, actual_str, file, line); \
-               exit(1); \
-       } else { \
-               printf("TEST\t%s\tPASS\n", test); \
-       } \
-}
-
-#define assert_not_null(test, actual, file, line) \
-{ \
-       const void *actual_val = actual; \
-       if (!actual_val) { \
-               printf("TEST\t%s\tFAIL\t\t\t\t\t%s:%i\n", test, file, line); \
-               exit(1); \
-       } else { \
-               printf("TEST\t%s\tPASS\n", test); \
-       } \
-}
-
-#define assert_null(test, actual, file, line) \
-{ \
-       const void *actual_val = actual; \
-       if (actual_val) { \
-               printf("TEST\t%s\tFAIL\t\t\t\t\t%s:%i\n", test, file, line); \
-               exit(1); \
-       } else { \
-               printf("TEST\t%s\tPASS\n", test); \
-       } \
-}
-
-#define ASSERT_EQUALS(expected, actual) assert_equals(#actual, #expected, expected, actual, __FILE__, __LINE__)
-#define ASSERT_STRING_EQUALS(expected, actual) assert_string_equals(#actual, expected, actual, __FILE__, __LINE__)
-#define ASSERT_NOT_NULL(actual) assert_not_null(#actual " not null", actual, __FILE__, __LINE__)
-#define ASSERT_NULL(actual) assert_null(#actual " is null", actual, __FILE__, __LINE__)
-
-#define SKIP_ASSERT_EQUALS(expected, actual) if (0) { ASSERT_EQUALS(expected, actual); }
-
-#define TEST(name) printf("TEST BEGIN\t" #name "\n"); name(); printf("TEST END\t"#name "\tPASS\n");
-
-#define SKIP_TEST(name) if (0) { TEST(name) };
-
-#define TEST_INIT switch_core_init(0, SWITCH_TRUE, &err);
-
-#endif
-
-/* For Emacs:
- * Local Variables:
- * mode:c
- * indent-tabs-mode:t
- * tab-width:4
- * c-basic-offset:4
- * End:
- * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet
- */
-
diff --git a/src/mod/event_handlers/mod_rayo/test/Makefile.am b/src/mod/event_handlers/mod_rayo/test/Makefile.am
new file mode 100644 (file)
index 0000000..0648275
--- /dev/null
@@ -0,0 +1,13 @@
+include $(top_srcdir)/build/modmake.rulesam
+bin_PROGRAMS = test_iks test_nlsml test_srgs
+
+test_iks_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
+test_iks_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
+
+test_nlsml_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
+test_nlsml_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
+
+test_srgs_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
+test_srgs_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
+
+TESTS = $(bin_PROGRAMS)
diff --git a/src/mod/event_handlers/mod_rayo/test/test_iks.c b/src/mod/event_handlers/mod_rayo/test/test_iks.c
new file mode 100644 (file)
index 0000000..02a1730
--- /dev/null
@@ -0,0 +1,204 @@
+
+
+#include <switch.h>
+#include <iksemel.h>
+#include <test/switch_test.h>
+#include <iks_helpers.h>
+
+static const char *voxeo_grammar =
+       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]]]></grammar></input></iq>";
+
+
+static const char *repeating_bracket =
+       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]>]]]]]]]]] ]] ]]></grammar></input></iq>";
+
+
+static const char *normal_cdata =
+       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[1 DIGITS]]></grammar></input></iq>";
+
+
+static const char *empty_cdata =
+       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[]]></grammar></input></iq>";
+
+static const char *rayo_test_srgs =
+       "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" root=\"MAINRULE\">\n"
+       "  <rule id=\"MAINRULE\">\n"
+       "    <one-of>\n"
+       "      <item>\n"
+       "        <item repeat=\"0-1\"> need a</item>\n"
+       "        <item repeat=\"0-1\"> i need a</item>\n"
+       "        <one-of>\n"
+       "          <item> clue </item>\n"
+       "        </one-of>\n"
+       "        <tag> out.concept = \"clue\";</tag>\n"
+       "      </item>\n"
+       "      <item>\n"
+       "        <item repeat=\"0-1\"> have an</item>\n"
+       "        <item repeat=\"0-1\"> i have an</item>\n"
+       "        <one-of>\n"
+       "          <item> answer </item>\n"
+       "        </one-of>\n"
+       "        <tag> out.concept = \"answer\";</tag>\n"
+       "      </item>\n"
+       "    </one-of>\n"
+       "  </rule>\n"
+       "</grammar>";
+
+
+#define MATCH 1
+#define NO_MATCH 0
+
+
+/**
+ * main program
+ */
+FST_BEGIN()
+
+FST_SUITE_BEGIN(iks)
+
+FST_SETUP_BEGIN()
+{
+}
+FST_SETUP_END()
+
+FST_TEARDOWN_BEGIN()
+{
+}
+FST_TEARDOWN_END()
+
+
+FST_TEST_BEGIN(iks_cdata_bug)
+{
+       iks *iq = NULL;
+       iks *input = NULL;
+       iksparser *p = iks_dom_new(&iq);
+       const char *cdata;
+       fst_check(IKS_OK == iks_parse(p, voxeo_grammar, 0, 1));
+       iks_parser_delete(p);
+       fst_check((input = iks_find(iq, "input")));
+       fst_check((cdata = iks_find_cdata(input, "grammar")));
+       fst_check_string_equals("[1 DIGITS]", cdata);
+       iks_delete(iq);
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(repeating_bracket)
+{
+       iks *iq = NULL;
+       iks *input = NULL;
+       iksparser *p = iks_dom_new(&iq);
+       const char *cdata;
+       fst_check(IKS_OK == iks_parse(p, repeating_bracket, 0, 1));
+       iks_parser_delete(p);
+       fst_check((input = iks_find(iq, "input")));
+       fst_check((cdata = iks_find_cdata(input, "grammar")));
+       fst_check_string_equals("[1 DIGITS]>]]]]]]]]] ]] ", cdata);
+       iks_delete(iq);
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(normal_cdata)
+{
+       iks *iq = NULL;
+       iks *input = NULL;
+       iksparser *p = iks_dom_new(&iq);
+       const char *cdata;
+       fst_check(IKS_OK == iks_parse(p, normal_cdata, 0, 1));
+       iks_parser_delete(p);
+       fst_check((input = iks_find(iq, "input")));
+       fst_check((cdata = iks_find_cdata(input, "grammar")));
+       fst_check_string_equals("1 DIGITS", cdata);
+       iks_delete(iq);
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(empty_cdata)
+{
+       iks *iq = NULL;
+       iks *input = NULL;
+       iksparser *p = iks_dom_new(&iq);
+       const char *cdata;
+       fst_check(IKS_OK == iks_parse(p, empty_cdata, 0, 1));
+       iks_parser_delete(p);
+       fst_check((input = iks_find(iq, "input")));
+       fst_check(NULL == (cdata = iks_find_cdata(input, "grammar")));
+       iks_delete(iq);
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(rayo_test_srgs)
+{
+       iks *grammar = NULL;
+       iksparser *p = iks_dom_new(&grammar);
+       fst_check(IKS_OK == iks_parse(p, rayo_test_srgs, 0, 1));
+       iks_parser_delete(p);
+       iks_delete(grammar);
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(iks_helper_value_matches)
+{
+       fst_check(MATCH == value_matches("1", "1,2,3"));
+       fst_check(MATCH == value_matches("2", "1,2,3"));
+       fst_check(MATCH == value_matches("3", "1,2,3"));
+       fst_check(NO_MATCH == value_matches("4", "1,2,3"));
+       fst_check(NO_MATCH == value_matches("1,2", "1,2,3"));
+       fst_check(NO_MATCH == value_matches(NULL, "1,2,3"));
+       fst_check(NO_MATCH == value_matches(NULL, NULL));
+       fst_check(NO_MATCH == value_matches("1", NULL));
+       fst_check(NO_MATCH == value_matches("", "1,2,3"));
+       fst_check(NO_MATCH == value_matches("", ""));
+       fst_check(NO_MATCH == value_matches("1", ""));
+       fst_check(MATCH == value_matches("duplex", "duplex,send,recv"));
+       fst_check(MATCH == value_matches("send", "duplex,send,recv"));
+       fst_check(MATCH == value_matches("recv", "duplex,send,recv"));
+       fst_check(NO_MATCH == value_matches("sendrecv", "duplex,send,recv"));
+       fst_check(MATCH == value_matches("duplex1", "duplex1,duplex2,duplex3"));
+       fst_check(MATCH == value_matches("duplex2", "duplex1,duplex2,duplex3"));
+       fst_check(MATCH == value_matches("duplex3", "duplex1,duplex2,duplex3"));
+       fst_check(NO_MATCH == value_matches("duplex4", "duplex1,duplex2,duplex3"));
+       fst_check(NO_MATCH == value_matches("duplex", "duplex1,duplex2,duplex3"));
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(dialback_key)
+{
+       fst_check_string_equals("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", ""));
+       fst_check(NULL == iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F"));
+       fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL));
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(validate_dtmf)
+{
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("1"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("A"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("a"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("D"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("d"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("*"));
+       fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("#"));
+       fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit("E"));
+       fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit(NULL));
+       fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit(""));
+       fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit("11"));
+       fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "A"));
+       fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "1"));
+       fst_check(SWITCH_FALSE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "Z"));
+       fst_check(SWITCH_FALSE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "11"));
+       fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, NULL));
+       fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, ""));
+}
+FST_TEST_END()
+
+
+FST_SUITE_END()
+
+FST_END()
similarity index 86%
rename from src/mod/event_handlers/mod_rayo/test_nlsml/main.c
rename to src/mod/event_handlers/mod_rayo/test/test_nlsml.c
index 0577288b7cfb36584902dd6a6f1718e2d356cf63..df5948f05a30e915a1d51ef2f7b76375147c327d 100644 (file)
@@ -1,8 +1,8 @@
 
 
 #include <switch.h>
-#include "test.h"
-#include "nlsml.h"
+#include <test/switch_test.h>
+#include <nlsml.h>
 
 static const char *nlsml_good =
        "<result x-model=\"http://theYesNoModel\""
@@ -224,22 +224,6 @@ static const char *nlsml_no_match =
        "  </interpretation>\n"
        "</result>\n";
 
-/**
- * Test parsing NLSML example results
- */
-static void test_parse_nlsml_examples(void)
-{
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_good, "1234"));
-       ASSERT_EQUALS(NMT_BAD_XML, nlsml_parse(nlsml_bad, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_match_with_model_instance, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_multi_input, "1234"));
-       ASSERT_EQUALS(NMT_NOINPUT, nlsml_parse(nlsml_no_input, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_multi_input_dtmf, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_meta, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_simple_ambiguity, "1234"));
-       ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_mixed_initiative, "1234"));
-       ASSERT_EQUALS(NMT_NOMATCH, nlsml_parse(nlsml_no_match, "1234"));
-}
 
 static const char *nlsml_dtmf_result =
        "<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
@@ -248,76 +232,105 @@ static const char *nlsml_dtmf_result =
        "<instance>1 2 3 4</instance>"
        "</interpretation></result>";
 
+
+static const char *nlsml_good_normalized =
+       "<result x-model='http://theYesNoModel'"
+       " xmlns:xf='http://www.w3.org/2000/xforms'"
+       " grammar='http://theYesNoGrammar'"
+       " xmlns='http://www.ietf.org/xml/ns/mrcpv2'>"
+       "<interpretation>"
+       "<xf:instance>"
+       "<myApp:yes_no>"
+       "<response>yes</response>"
+       "</myApp:yes_no>"
+       "</xf:instance>"
+       "<input>ok</input>"
+       "</interpretation>"
+       "</result>";
+
+
+static const char *nlsml_dtmf_instance_result =
+       "<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
+       "xmlns:xf='http://www.w3.org/2000/xforms'><interpretation>"
+       "<input mode='dtmf' confidence='100'>1</input>"
+       "<instance>foo</instance>"
+       "</interpretation></result>";
+
+
+FST_BEGIN()
+
+FST_SUITE_BEGIN(nlsml)
+
+FST_SETUP_BEGIN()
+{
+       fst_requires(nlsml_init());
+}
+FST_SETUP_END()
+
+FST_TEARDOWN_BEGIN()
+{
+}
+FST_TEARDOWN_END()
+
+/**
+ * Test parsing NLSML example results
+ */
+FST_TEST_BEGIN(parse_nlsml_examples)
+{
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_good, "1234"));
+       fst_check(NMT_BAD_XML == nlsml_parse(nlsml_bad, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_match_with_model_instance, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_multi_input, "1234"));
+       fst_check(NMT_NOINPUT == nlsml_parse(nlsml_no_input, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_multi_input_dtmf, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_meta, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_simple_ambiguity, "1234"));
+       fst_check(NMT_MATCH == nlsml_parse(nlsml_mixed_initiative, "1234"));
+       fst_check(NMT_NOMATCH == nlsml_parse(nlsml_no_match, "1234"));
+}
+FST_TEST_END()
+
 /**
  * Test creating DTMF match result
  */
-static void test_create_dtmf_match(void)
+FST_TEST_BEGIN(create_dtmf_match)
 {
        iks *result = nlsml_create_dtmf_match("1234", NULL);
        char *result_str;
-       ASSERT_NOT_NULL(result);
+       fst_requires(result);
        result_str = iks_string(NULL, result);
-       ASSERT_STRING_EQUALS(nlsml_dtmf_result, result_str);
+       fst_check_string_equals(nlsml_dtmf_result, result_str);
        iks_free(result_str);
 }
+FST_TEST_END()
 
-static const char *nlsml_dtmf_instance_result =
-       "<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
-       "xmlns:xf='http://www.w3.org/2000/xforms'><interpretation>"
-       "<input mode='dtmf' confidence='100'>1</input>"
-       "<instance>foo</instance>"
-       "</interpretation></result>";
 
 /**
  * Test creating DTMF match result with instance interpretation
  */
-static void test_create_dtmf_instance(void)
+FST_TEST_BEGIN(create_dtmf_instance)
 {
        iks *result = nlsml_create_dtmf_match("1", "foo");
        char *result_str;
-       ASSERT_NOT_NULL(result);
+       fst_requires(result);
        result_str = iks_string(NULL, result);
-       ASSERT_STRING_EQUALS(nlsml_dtmf_instance_result, result_str);
+       fst_check_string_equals(nlsml_dtmf_instance_result, result_str);
        iks_free(result_str);
 }
-
-static const char *nlsml_good_normalized =
-       "<result x-model='http://theYesNoModel'"
-       " xmlns:xf='http://www.w3.org/2000/xforms'"
-       " grammar='http://theYesNoGrammar'"
-       " xmlns='http://www.ietf.org/xml/ns/mrcpv2'>"
-       "<interpretation>"
-       "<xf:instance>"
-       "<myApp:yes_no>"
-       "<response>yes</response>"
-       "</myApp:yes_no>"
-       "</xf:instance>"
-       "<input>ok</input>"
-       "</interpretation>"
-       "</result>";
+FST_TEST_END()
 
 /**
  * Test NLSML normalization
  */
-static void test_normalize(void)
+FST_TEST_BEGIN(normalize)
 {
        iks *result = nlsml_normalize(nlsml_good);
-       ASSERT_NOT_NULL(result);
-       ASSERT_STRING_EQUALS(nlsml_good_normalized, iks_string(NULL, result));
+       fst_requires(result);
+       fst_check_string_equals(nlsml_good_normalized, iks_string(NULL, result));
 }
+FST_TEST_END()
 
-/**
- * main program
- */
-int main(int argc, char **argv)
-{
-       const char *err;
-       TEST_INIT
-       nlsml_init();
-       TEST(test_parse_nlsml_examples);
-       TEST(test_create_dtmf_match);
-       TEST(test_create_dtmf_instance);
-       TEST(test_normalize);
-       return 0;
-}
 
+FST_SUITE_END()
+
+FST_END()
similarity index 57%
rename from src/mod/event_handlers/mod_rayo/test_srgs/main.c
rename to src/mod/event_handlers/mod_rayo/test/test_srgs.c
index a8f8a944f74b2dc9cba100cef191f670bd0a650e..97284639bb3edfab58b05499d63966f806035ade 100644 (file)
@@ -1,8 +1,8 @@
 
 
 #include <switch.h>
-#include "test.h"
-#include "srgs.h"
+#include <test/switch_test.h>
+#include <srgs.h>
 
 
 static const char *adhearsion_menu_grammar =
@@ -91,108 +91,6 @@ static const char *adhearsion_large_menu_grammar =
        "  </rule>\n"
        "</grammar>\n";
 
-/**
- * Test matching against adhearsion menu grammar
- */
-static void test_match_adhearsion_menu_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, adhearsion_menu_grammar)));
-
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_STRING_EQUALS("0", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_STRING_EQUALS("1", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_STRING_EQUALS("7", interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "715", &interpretation));
-       ASSERT_STRING_EQUALS("4", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_STRING_EQUALS("3", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-       ASSERT_NULL(interpretation);
-
-       srgs_parser_destroy(parser);
-}
-
-/**
- * Test matching against adhearsion menu grammar
- */
-static void test_match_adhearsion_large_menu_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, adhearsion_large_menu_grammar)));
-
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_STRING_EQUALS("0", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_STRING_EQUALS("1", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_STRING_EQUALS("2", interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "715", &interpretation));
-       ASSERT_STRING_EQUALS("4", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_STRING_EQUALS("3", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "761", &interpretation));
-       ASSERT_STRING_EQUALS("50", interpretation);
-
-       srgs_parser_destroy(parser);
-}
-
 static const char *duplicate_tag_grammar =
        "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" version=\"1.0\" xml:lang=\"en-US\" mode=\"dtmf\" root=\"options\" tag-format=\"semantics/1.0-literals\">"
        "  <rule id=\"options\" scope=\"public\">\n"
@@ -205,54 +103,6 @@ static const char *duplicate_tag_grammar =
        "  </rule>\n"
        "</grammar>\n";
 
-/**
- * Test matching with duplicate tags
- */
-static void test_match_duplicate_tag_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, duplicate_tag_grammar)));
-
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_STRING_EQUALS("2", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_STRING_EQUALS("2", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_STRING_EQUALS("4", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_STRING_EQUALS("4", interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-       ASSERT_NULL(interpretation);
-
-       srgs_parser_destroy(parser);
-}
-
 
 static const char *adhearsion_ask_grammar =
        "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" version=\"1.0\" xml:lang=\"en-US\" mode=\"dtmf\" root=\"inputdigits\">"
@@ -274,38 +124,6 @@ static const char *adhearsion_ask_grammar =
        "  </rule>\n"
        "</grammar>\n";
 
-/**
- * Test matching against adhearsion ask grammar
- */
-static void test_match_adhearsion_ask_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, adhearsion_ask_grammar)));
-
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_NULL(interpretation);
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-
-       srgs_parser_destroy(parser);
-}
 
 static const char *multi_digit_grammar =
        "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" version=\"1.0\" xml:lang=\"en-US\" mode=\"dtmf\" root=\"misc\">"
@@ -328,37 +146,6 @@ static const char *multi_digit_grammar =
        "  </rule>\n"
        "</grammar>\n";
 
-/**
- * Test matching against grammar with multiple digits per item
- */
-static void test_match_multi_digit_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, multi_digit_grammar)));
-
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-
-       srgs_parser_destroy(parser);
-}
 
 static const char *multi_rule_grammar =
        "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" version=\"1.0\" xml:lang=\"en-US\" mode=\"dtmf\">"
@@ -385,34 +172,6 @@ static const char *multi_rule_grammar =
        "  </rule>\n"
        "</grammar>\n";
 
-static void test_match_multi_rule_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, multi_rule_grammar)));
-
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-
-       srgs_parser_destroy(parser);
-}
 
 static const char *rayo_example_grammar =
        "<grammar mode=\"dtmf\" version=\"1.0\""
@@ -449,37 +208,6 @@ static const char *rayo_example_grammar =
        "    </rule>\n"
        "</grammar>\n";
 
-static void test_match_rayo_example_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, rayo_example_grammar)));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "0", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "2", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "3", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "4", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "5", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "6", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "7", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "8", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "9", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "*", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "*9", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "2321#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "27", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "223", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "0123456789*#", &interpretation));
-
-       srgs_parser_destroy(parser);
-}
-
 static const char *bad_ref_grammar =
        "<grammar mode=\"dtmf\" version=\"1.0\""
        "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
@@ -535,21 +263,6 @@ static const char *adhearsion_ask_grammar_bad =
        "  </rule>\n"
        "</grammar>\n";
 
-static void test_parse_grammar(void)
-{
-       struct srgs_parser *parser;
-
-       parser = srgs_parser_new("1234");
-
-       ASSERT_NOT_NULL(srgs_parse(parser, adhearsion_ask_grammar));
-       ASSERT_NULL(srgs_parse(parser, adhearsion_ask_grammar_bad));
-       ASSERT_NULL(srgs_parse(parser, NULL));
-       ASSERT_NULL(srgs_parse(NULL, adhearsion_ask_grammar));
-       ASSERT_NULL(srgs_parse(NULL, adhearsion_ask_grammar_bad));
-       ASSERT_NULL(srgs_parse(parser, bad_ref_grammar));
-
-       srgs_parser_destroy(parser);
-}
 
 static const char *repeat_item_grammar_bad =
        "<grammar mode=\"dtmf\" version=\"1.0\""
@@ -816,91 +529,6 @@ static const char *repeat_item_plus_grammar =
        "    </rule>\n"
        "</grammar>\n";
 
-static void test_repeat_item_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad));
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad2));
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad3));
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad4));
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad5));
-       ASSERT_NULL(srgs_parse(parser, repeat_item_grammar_bad6));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_grammar)));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1111#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1111", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1234", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "11115#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "11115", &interpretation));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_range_grammar)));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1111#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1111", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1234", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "11115#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "11115", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "111156#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "111156", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111567#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111567", &interpretation));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_optional_grammar)));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1234", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "11115#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "11115", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "111156#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "111156", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111567#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "1111567", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_plus_grammar)));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1111#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1111", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1234", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "11115#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "11115", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "111156#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "111156", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "111157#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "111157", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_star_grammar)));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1111#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1111", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1234#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1234", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "11115#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "11115", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "111156#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "111156", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "111157#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "111157", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_PARTIAL, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A#", &interpretation));
-       ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "A", &interpretation));
-
-       srgs_parser_destroy(parser);
-}
 
 static const char *repeat_item_range_ambiguous_grammar =
        "<grammar mode=\"dtmf\" version=\"1.0\""
@@ -929,18 +557,6 @@ static const char *repeat_item_range_ambiguous_grammar =
        "    </rule>\n"
        "</grammar>\n";
 
-static void test_repeat_item_range_ambiguous_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
-
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_range_ambiguous_grammar)));
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "12", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "123", &interpretation));
-}
 
 static const char *repeat_item_range_optional_pound_grammar =
        "<grammar mode=\"dtmf\" version=\"1.0\""
@@ -974,20 +590,7 @@ static const char *repeat_item_range_optional_pound_grammar =
        "       </one-of>\n"
        "    </rule>\n"
        "</grammar>\n";
-static void test_repeat_item_range_optional_pound_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *interpretation;
 
-       parser = srgs_parser_new("1234");
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, repeat_item_range_optional_pound_grammar)));
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "1", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "1#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "12", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "12#", &interpretation));
-       ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "123", &interpretation));
-}
 
 /*
 <polite> = please | kindly | oh mighty computer;
@@ -1045,25 +648,6 @@ static const char *rayo_test_srgs =
        "  </rule>\n"
        "</grammar>";
 
-static void test_jsgf(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       const char *jsgf;
-       parser = srgs_parser_new("1234");
-
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, adhearsion_ask_grammar)));
-       ASSERT_NOT_NULL((jsgf = srgs_grammar_to_jsgf(grammar)));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, voice_srgs1)));
-       ASSERT_NOT_NULL((jsgf = srgs_grammar_to_jsgf(grammar)));
-       ASSERT_STRING_EQUALS(voice_jsgf, jsgf);
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, multi_rule_grammar)));
-       ASSERT_NOT_NULL((jsgf = srgs_grammar_to_jsgf(grammar)));
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, rayo_test_srgs)));
-       ASSERT_NOT_NULL((jsgf = srgs_grammar_to_jsgf(grammar)));
-       ASSERT_NULL(srgs_grammar_to_jsgf(NULL));
-       srgs_parser_destroy(parser);
-}
 
 /* removed the ruleref to URL from example */
 static const char *w3c_example_grammar =
@@ -1121,15 +705,6 @@ static const char *w3c_example_grammar =
        "\n"
        "</grammar>";
 
-static void test_w3c_example_grammar(void)
-{
-       struct srgs_parser *parser;
-       struct srgs_grammar *grammar;
-       parser = srgs_parser_new("1234");
-
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, w3c_example_grammar)));
-       ASSERT_NOT_NULL(srgs_grammar_to_jsgf(grammar));
-}
 
 static const char *metadata_grammar =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -1193,38 +768,508 @@ static const char *metadata_grammar =
        "\n"
        "</grammar>";
 
-static void test_metadata_grammar(void)
+
+FST_BEGIN()
+
+FST_SUITE_BEGIN(srgs)
+
+FST_SETUP_BEGIN()
+{
+       fst_requires(srgs_init());
+}
+FST_SETUP_END()
+
+FST_TEARDOWN_BEGIN()
+{
+}
+FST_TEARDOWN_END()
+
+/**
+ * Test matching against adhearsion menu grammar
+ */
+FST_TEST_BEGIN(match_adhearsion_menu_grammar)
 {
        struct srgs_parser *parser;
        struct srgs_grammar *grammar;
+       const char *interpretation;
+
        parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, adhearsion_menu_grammar)));
+
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check_string_equals("0", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check_string_equals("1", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check_string_equals("7", interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "715", &interpretation));
+       fst_check_string_equals("4", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check_string_equals("3", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+       fst_check(NULL == interpretation);
 
-       ASSERT_NOT_NULL((grammar = srgs_parse(parser, metadata_grammar)));
-       ASSERT_NOT_NULL(srgs_grammar_to_jsgf(grammar));
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+/**
+ * Test matching against adhearsion menu grammar
+ */
+FST_TEST_BEGIN(match_adhearsion_large_menu_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, adhearsion_large_menu_grammar)));
+
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check_string_equals("0", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check_string_equals("1", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check_string_equals("2", interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "715", &interpretation));
+       fst_check_string_equals("4", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check_string_equals("3", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "761", &interpretation));
+       fst_check_string_equals("50", interpretation);
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+/**
+ * Test matching with duplicate tags
+ */
+FST_TEST_BEGIN(match_duplicate_tag_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, duplicate_tag_grammar)));
+
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check_string_equals("2", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check_string_equals("2", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check_string_equals("4", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check_string_equals("4", interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+       fst_check(NULL == interpretation);
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+
+/**
+ * Test matching against adhearsion ask grammar
+ */
+FST_TEST_BEGIN(match_adhearsion_ask_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, adhearsion_ask_grammar)));
+
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(NULL == interpretation);
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+
+       srgs_parser_destroy(parser);
 }
+FST_TEST_END()
+
 
 /**
- * main program
+ * Test matching against grammar with multiple digits per item
  */
-int main(int argc, char **argv)
+FST_TEST_BEGIN(match_multi_digit_grammar)
 {
-       const char *err;
-       TEST_INIT
-       srgs_init();
-       TEST(test_parse_grammar);
-       TEST(test_match_adhearsion_menu_grammar);
-       TEST(test_match_adhearsion_large_menu_grammar);
-       TEST(test_match_duplicate_tag_grammar);
-       TEST(test_match_adhearsion_ask_grammar);
-       TEST(test_match_multi_digit_grammar);
-       TEST(test_match_multi_rule_grammar);
-       TEST(test_match_rayo_example_grammar);
-       TEST(test_repeat_item_grammar);
-       TEST(test_jsgf);
-       TEST(test_w3c_example_grammar);
-       TEST(test_metadata_grammar);
-       TEST(test_repeat_item_range_ambiguous_grammar);
-       TEST(test_repeat_item_range_optional_pound_grammar);
-       return 0;
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, multi_digit_grammar)));
+
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+
+       srgs_parser_destroy(parser);
 }
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(match_multi_rule_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, multi_rule_grammar)));
+
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(match_rayo_example_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, rayo_example_grammar)));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "0", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "2", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "3", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "4", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "5", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "6", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "7", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "8", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "9", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "*", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "*9", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "2321#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "27", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "223", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "0123456789*#", &interpretation));
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+
+FST_TEST_BEGIN(parse_grammar)
+{
+       struct srgs_parser *parser;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+
+       fst_check(srgs_parse(parser, adhearsion_ask_grammar));
+       fst_check(NULL == srgs_parse(parser, adhearsion_ask_grammar_bad));
+       fst_check(NULL == srgs_parse(parser, NULL));
+       fst_check(NULL == srgs_parse(NULL, adhearsion_ask_grammar));
+       fst_check(NULL == srgs_parse(NULL, adhearsion_ask_grammar_bad));
+       fst_check(NULL == srgs_parse(parser, bad_ref_grammar));
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(repeat_item_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad));
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad2));
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad3));
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad4));
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad5));
+       fst_check(NULL == srgs_parse(parser, repeat_item_grammar_bad6));
+       fst_requires((grammar = srgs_parse(parser, repeat_item_grammar)));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1111#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1111", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1234", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "11115#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "11115", &interpretation));
+       fst_requires((grammar = srgs_parse(parser, repeat_item_range_grammar)));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1111#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1111", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1234", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "11115#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "11115", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "111156#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "111156", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111567#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111567", &interpretation));
+       fst_requires((grammar = srgs_parse(parser, repeat_item_optional_grammar)));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1234", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "11115#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "11115", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "111156#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "111156", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111567#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "1111567", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_requires((grammar = srgs_parse(parser, repeat_item_plus_grammar)));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1111#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1111", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1234", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "11115#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "11115", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "111156#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "111156", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "111157#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "111157", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+       fst_requires((grammar = srgs_parse(parser, repeat_item_star_grammar)));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1111#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1111", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1234#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1234", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "11115#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "11115", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "111156#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "111156", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "111157#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "111157", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1#", &interpretation));
+       fst_check(SMT_MATCH_PARTIAL == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A#", &interpretation));
+       fst_check(SMT_NO_MATCH == srgs_grammar_match(grammar, "A", &interpretation));
+
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(repeat_item_range_ambiguous_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, repeat_item_range_ambiguous_grammar)));
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "12", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "123", &interpretation));
+}
+FST_TEST_END()
+
+FST_TEST_BEGIN(repeat_item_range_optional_pound_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *interpretation;
+
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+       fst_requires((grammar = srgs_parse(parser, repeat_item_range_optional_pound_grammar)));
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "1", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "1#", &interpretation));
+       fst_check(SMT_MATCH == srgs_grammar_match(grammar, "12", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "12#", &interpretation));
+       fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "123", &interpretation));
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(jsgf)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       const char *jsgf;
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+
+       fst_requires((grammar = srgs_parse(parser, adhearsion_ask_grammar)));
+       fst_check((jsgf = srgs_grammar_to_jsgf(grammar)));
+       fst_requires((grammar = srgs_parse(parser, voice_srgs1)));
+       fst_check((jsgf = srgs_grammar_to_jsgf(grammar)));
+       fst_check_string_equals(voice_jsgf, jsgf);
+       fst_requires((grammar = srgs_parse(parser, multi_rule_grammar)));
+       fst_check((jsgf = srgs_grammar_to_jsgf(grammar)));
+       fst_requires((grammar = srgs_parse(parser, rayo_test_srgs)));
+       fst_check((jsgf = srgs_grammar_to_jsgf(grammar)));
+       fst_check(NULL == srgs_grammar_to_jsgf(NULL));
+       srgs_parser_destroy(parser);
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(w3c_example_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+
+       fst_requires((grammar = srgs_parse(parser, w3c_example_grammar)));
+       fst_check(srgs_grammar_to_jsgf(grammar));
+}
+FST_TEST_END()
+
+
+FST_TEST_BEGIN(metadata_grammar)
+{
+       struct srgs_parser *parser;
+       struct srgs_grammar *grammar;
+       parser = srgs_parser_new("1234");
+       fst_requires(parser);
+
+       fst_requires((grammar = srgs_parse(parser, metadata_grammar)));
+       fst_check(srgs_grammar_to_jsgf(grammar));
+}
+FST_TEST_END()
+
+FST_SUITE_END()
+
+FST_END()
 
diff --git a/src/mod/event_handlers/mod_rayo/test_iks/Makefile b/src/mod/event_handlers/mod_rayo/test_iks/Makefile
deleted file mode 100644 (file)
index d75a967..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-BASE=../../../../..
-
-IKS_DIR=$(BASE)/libs/iksemel
-IKS_LA=$(IKS_DIR)/src/libiksemel.la
-LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include 
-LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../iks_helpers.o
-LOCAL_SOURCES= main.c 
-include $(BASE)/build/modmake.rules
-
-$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
-       @cd $(IKS_DIR) && $(MAKE)
-       @$(TOUCH_TARGET)
-
-local_all:
-       libtool --mode=link gcc main.o ../iks_helpers.o -o test test_iks.la
-
-local_clean:
-       -rm test
diff --git a/src/mod/event_handlers/mod_rayo/test_iks/main.c b/src/mod/event_handlers/mod_rayo/test_iks/main.c
deleted file mode 100644 (file)
index 09a368d..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-
-
-#include <switch.h>
-#include <iksemel.h>
-#include "test.h"
-#include "iks_helpers.h"
-
-static const char *voxeo_grammar =
-       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]]]></grammar></input></iq>";
-
-static void test_iks_cdata_bug(void)
-{
-       iks *iq = NULL;
-       iks *input = NULL;
-       iksparser *p = iks_dom_new(&iq);
-       const char *cdata;
-       ASSERT_EQUALS(IKS_OK, iks_parse(p, voxeo_grammar, 0, 1));
-       iks_parser_delete(p);
-       ASSERT_NOT_NULL((input = iks_find(iq, "input")));
-       ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
-       ASSERT_STRING_EQUALS("[1 DIGITS]", cdata);
-       iks_delete(iq);
-}
-
-static const char *repeating_bracket =
-       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]>]]]]]]]]] ]] ]]></grammar></input></iq>";
-
-static void test_repeating_bracket(void)
-{
-       iks *iq = NULL;
-       iks *input = NULL;
-       iksparser *p = iks_dom_new(&iq);
-       const char *cdata;
-       ASSERT_EQUALS(IKS_OK, iks_parse(p, repeating_bracket, 0, 1));
-       iks_parser_delete(p);
-       ASSERT_NOT_NULL((input = iks_find(iq, "input")));
-       ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
-       ASSERT_STRING_EQUALS("[1 DIGITS]>]]]]]]]]] ]] ", cdata);
-       iks_delete(iq);
-}
-
-static const char *normal_cdata =
-       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[1 DIGITS]]></grammar></input></iq>";
-
-static void test_normal_cdata(void)
-{
-       iks *iq = NULL;
-       iks *input = NULL;
-       iksparser *p = iks_dom_new(&iq);
-       const char *cdata;
-       ASSERT_EQUALS(IKS_OK, iks_parse(p, normal_cdata, 0, 1));
-       iks_parser_delete(p);
-       ASSERT_NOT_NULL((input = iks_find(iq, "input")));
-       ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
-       ASSERT_STRING_EQUALS("1 DIGITS", cdata);
-       iks_delete(iq);
-}
-
-static const char *empty_cdata =
-       "<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[]]></grammar></input></iq>";
-
-static void test_empty_cdata(void)
-{
-       iks *iq = NULL;
-       iks *input = NULL;
-       iksparser *p = iks_dom_new(&iq);
-       const char *cdata;
-       ASSERT_EQUALS(IKS_OK, iks_parse(p, empty_cdata, 0, 1));
-       iks_parser_delete(p);
-       ASSERT_NOT_NULL((input = iks_find(iq, "input")));
-       ASSERT_NULL((cdata = iks_find_cdata(input, "grammar")));
-       iks_delete(iq);
-}
-
-static const char *rayo_test_srgs =
-       "<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" root=\"MAINRULE\">\n"
-       "  <rule id=\"MAINRULE\">\n"
-       "    <one-of>\n"
-       "      <item>\n"
-       "        <item repeat=\"0-1\"> need a</item>\n"
-       "        <item repeat=\"0-1\"> i need a</item>\n"
-       "        <one-of>\n"
-       "          <item> clue </item>\n"
-       "        </one-of>\n"
-       "        <tag> out.concept = \"clue\";</tag>\n"
-       "      </item>\n"
-       "      <item>\n"
-       "        <item repeat=\"0-1\"> have an</item>\n"
-       "        <item repeat=\"0-1\"> i have an</item>\n"
-       "        <one-of>\n"
-       "          <item> answer </item>\n"
-       "        </one-of>\n"
-       "        <tag> out.concept = \"answer\";</tag>\n"
-       "      </item>\n"
-       "    </one-of>\n"
-       "  </rule>\n"
-       "</grammar>";
-
-static void test_rayo_test_srgs(void)
-{
-       iks *grammar = NULL;
-       iksparser *p = iks_dom_new(&grammar);
-       ASSERT_EQUALS(IKS_OK, iks_parse(p, rayo_test_srgs, 0, 1));
-       iks_parser_delete(p);
-       iks_delete(grammar);
-}
-
-#define MATCH 1
-#define NO_MATCH 0
-
-static void test_iks_helper_value_matches(void)
-{
-       ASSERT_EQUALS(MATCH, value_matches("1", "1,2,3"));
-       ASSERT_EQUALS(MATCH, value_matches("2", "1,2,3"));
-       ASSERT_EQUALS(MATCH, value_matches("3", "1,2,3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("4", "1,2,3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("1,2", "1,2,3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches(NULL, "1,2,3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches(NULL, NULL));
-       ASSERT_EQUALS(NO_MATCH, value_matches("1", NULL));
-       ASSERT_EQUALS(NO_MATCH, value_matches("", "1,2,3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("", ""));
-       ASSERT_EQUALS(NO_MATCH, value_matches("1", ""));
-       ASSERT_EQUALS(MATCH, value_matches("duplex", "duplex,send,recv"));
-       ASSERT_EQUALS(MATCH, value_matches("send", "duplex,send,recv"));
-       ASSERT_EQUALS(MATCH, value_matches("recv", "duplex,send,recv"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("sendrecv", "duplex,send,recv"));
-       ASSERT_EQUALS(MATCH, value_matches("duplex1", "duplex1,duplex2,duplex3"));
-       ASSERT_EQUALS(MATCH, value_matches("duplex2", "duplex1,duplex2,duplex3"));
-       ASSERT_EQUALS(MATCH, value_matches("duplex3", "duplex1,duplex2,duplex3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("duplex4", "duplex1,duplex2,duplex3"));
-       ASSERT_EQUALS(NO_MATCH, value_matches("duplex", "duplex1,duplex2,duplex3"));
-}
-
-static void test_dialback_key(void)
-{
-       ASSERT_STRING_EQUALS("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", ""));
-       ASSERT_NULL(iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F"));
-       ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL));
-}
-
-static void test_validate_dtmf(void)
-{
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("1"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("A"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("a"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("D"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("d"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("*"));
-       ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("#"));
-       ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("E"));
-       ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit(NULL));
-       ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit(""));
-       ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("11"));
-       ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "A"));
-       ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "1"));
-       ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "Z"));
-       ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "11"));
-       ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, NULL));
-       ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, ""));
-}
-
-/**
- * main program
- */
-int main(int argc, char **argv)
-{
-       const char *err;
-       TEST_INIT
-       TEST(test_iks_cdata_bug);
-       TEST(test_repeating_bracket);
-       TEST(test_normal_cdata);
-       TEST(test_empty_cdata);
-       TEST(test_rayo_test_srgs);
-       TEST(test_iks_helper_value_matches);
-       TEST(test_dialback_key);
-       TEST(test_validate_dtmf);
-       return 0;
-}
diff --git a/src/mod/event_handlers/mod_rayo/test_iks/test_iks.c b/src/mod/event_handlers/mod_rayo/test_iks/test_iks.c
deleted file mode 100644 (file)
index a095320..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-int dummy(int i)
-{
-       return 0;
-}
-
-
diff --git a/src/mod/event_handlers/mod_rayo/test_nlsml/Makefile b/src/mod/event_handlers/mod_rayo/test_nlsml/Makefile
deleted file mode 100644 (file)
index 8104690..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-BASE=../../../../..
-
-IKS_DIR=$(BASE)/libs/iksemel
-IKS_LA=$(IKS_DIR)/src/libiksemel.la
-LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include
-LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../nlsml.o ../iks_helpers.o
-LOCAL_SOURCES= main.c
-include $(BASE)/build/modmake.rules
-
-$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
-       @cd $(IKS_DIR) && $(MAKE)
-       @$(TOUCH_TARGET)
-
-local_all:
-       libtool --mode=link gcc main.o ../nlsml.o ../iks_helpers.o  test_nlsml.la ../../../../../.libs/libfreeswitch.la ../../../../../libs/iksemel/src/.libs/libiksemel.a -lpcre -lssl -lcrypto -g -ggdb -O2 -pthread -o test
-local_clean:
-       -rm test
diff --git a/src/mod/event_handlers/mod_rayo/test_nlsml/test_nlsml.c b/src/mod/event_handlers/mod_rayo/test_nlsml/test_nlsml.c
deleted file mode 100644 (file)
index a095320..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-int dummy(int i)
-{
-       return 0;
-}
-
-
diff --git a/src/mod/event_handlers/mod_rayo/test_srgs/Makefile b/src/mod/event_handlers/mod_rayo/test_srgs/Makefile
deleted file mode 100644 (file)
index d8f4666..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-BASE=../../../../..
-
-IKS_DIR=$(BASE)/libs/iksemel
-IKS_LA=$(IKS_DIR)/src/libiksemel.la
-LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include
-LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../srgs.o
-LOCAL_SOURCES= main.c
-include $(BASE)/build/modmake.rules
-
-$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
-       @cd $(IKS_DIR) && $(MAKE)
-       @$(TOUCH_TARGET)
-
-local_all:
-       libtool --mode=link gcc main.o ../srgs.o -o test test_srgs.la
-
-local_clean:
-       -rm test
diff --git a/src/mod/event_handlers/mod_rayo/test_srgs/test_srgs.c b/src/mod/event_handlers/mod_rayo/test_srgs/test_srgs.c
deleted file mode 100644 (file)
index a095320..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-int dummy(int i)
-{
-       return 0;
-}
-
-
index 242f39254316fd327d291785476232e64db3f1bc..b7ee04383bd34fedfc58c105c3fbf9d7713a5b8a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2013-2015, Grasshopper
+ * Copyright (C) 2013-2018, Grasshopper
  *
  * Version: MPL 1.1
  *
@@ -37,22 +37,22 @@ typedef int (* xmpp_stream_ready_callback)(struct xmpp_stream *stream);
 typedef void (* xmpp_stream_recv_callback)(struct xmpp_stream *stream, iks *stanza);
 typedef void (* xmpp_stream_destroy_callback)(struct xmpp_stream *stream);
 
-extern struct xmpp_stream_context *xmpp_stream_context_create(const char *domain, const char *domain_secret, xmpp_stream_bind_callback bind_cb, xmpp_stream_ready_callback ready, xmpp_stream_recv_callback recv, xmpp_stream_destroy_callback destroy);
-extern void xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file);
-extern void xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file);
-extern void xmpp_stream_context_add_user(struct xmpp_stream_context *context, const char *user, const char *password);
-extern void xmpp_stream_context_dump(struct xmpp_stream_context *context, switch_stream_handle_t *stream);
-extern void xmpp_stream_context_destroy(struct xmpp_stream_context *context);
-extern void xmpp_stream_context_send(struct xmpp_stream_context *context, const char *jid, iks *stanza);
+SWITCH_DECLARE(struct xmpp_stream_context *) xmpp_stream_context_create(const char *domain, const char *domain_secret, xmpp_stream_bind_callback bind_cb, xmpp_stream_ready_callback ready, xmpp_stream_recv_callback recv, xmpp_stream_destroy_callback destroy);
+SWITCH_DECLARE(void) xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file);
+SWITCH_DECLARE(void) xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file);
+SWITCH_DECLARE(void) xmpp_stream_context_add_user(struct xmpp_stream_context *context, const char *user, const char *password);
+SWITCH_DECLARE(void) xmpp_stream_context_dump(struct xmpp_stream_context *context, switch_stream_handle_t *stream);
+SWITCH_DECLARE(void) xmpp_stream_context_destroy(struct xmpp_stream_context *context);
+SWITCH_DECLARE(void) xmpp_stream_context_send(struct xmpp_stream_context *context, const char *jid, iks *stanza);
 
-extern switch_status_t xmpp_stream_context_listen(struct xmpp_stream_context *context, const char *addr, int port, int is_s2s, const char *acl);
-extern switch_status_t xmpp_stream_context_connect(struct xmpp_stream_context *context, const char *peer_domain, const char *peer_address, int peer_port);
+SWITCH_DECLARE(switch_status_t) xmpp_stream_context_listen(struct xmpp_stream_context *context, const char *addr, int port, int is_s2s, const char *acl);
+SWITCH_DECLARE(switch_status_t) xmpp_stream_context_connect(struct xmpp_stream_context *context, const char *peer_domain, const char *peer_address, int peer_port);
 
-extern int xmpp_stream_is_s2s(struct xmpp_stream *stream);
-extern int xmpp_stream_is_incoming(struct xmpp_stream *stream);
-extern const char *xmpp_stream_get_jid(struct xmpp_stream *stream);
-extern void xmpp_stream_set_private(struct xmpp_stream *stream, void *user_private);
-extern void *xmpp_stream_get_private(struct xmpp_stream *stream);
+SWITCH_DECLARE(int) xmpp_stream_is_s2s(struct xmpp_stream *stream);
+SWITCH_DECLARE(int) xmpp_stream_is_incoming(struct xmpp_stream *stream);
+SWITCH_DECLARE(const char *) xmpp_stream_get_jid(struct xmpp_stream *stream);
+SWITCH_DECLARE(void) xmpp_stream_set_private(struct xmpp_stream *stream, void *user_private);
+SWITCH_DECLARE(void *) xmpp_stream_get_private(struct xmpp_stream *stream);
 
 #endif