Commit 21872080 authored by Simon Morlat's avatar Simon Morlat

Test parser assignation to numbers.

parent 818f9a68
......@@ -68,14 +68,21 @@ private:
// no op.
}
template <typename _valueT>
inline void _invokeWithValue(_parserElementT obj, typename std::enable_if<std::is_convertible<_valueT, int>::value, const std::string&>::type value){
inline void _invokeWithValue(_parserElementT obj, typename std::enable_if<std::is_integral<_valueT>::value, const std::string&>::type value){
mFunc(universal_pointer_cast<typename _functorT::first_argument_type>(obj), std::atoi(value.c_str()));
}
template <typename _valueT>
inline void _invokeWithValue(_parserElementT obj, typename std::enable_if<std::is_floating_point<_valueT>::value, const std::string&>::type value){
mFunc(universal_pointer_cast<typename _functorT::first_argument_type>(obj), std::atof(value.c_str()));
}
template <typename _valueT>
inline void _invokeWithChild(_parserElementT obj, typename std::enable_if<std::is_convertible<_valueT, std::string>::value, _parserElementT>::type child){
}
template <typename _valueT>
inline void _invokeWithChild(_parserElementT obj, typename std::enable_if<std::is_convertible<_valueT, int>::value, _parserElementT>::type child){
inline void _invokeWithChild(_parserElementT obj, typename std::enable_if<std::is_integral<_valueT>::value, _parserElementT>::type child){
}
template <typename _valueT>
inline void _invokeWithChild(_parserElementT obj, typename std::enable_if<std::is_floating_point<_valueT>::value, _parserElementT>::type child){
}
template <typename _valueT>
inline void _invokeWithChild(_parserElementT obj, typename std::enable_if<std::is_convertible<_valueT, _parserElementT>::value, _parserElementT>::type child){
......
......@@ -27,6 +27,7 @@ using namespace::belr;
typedef struct sip_uri{
char *user;
char *host;
int port;
} sip_uri_t;
typedef struct sip_response{
......@@ -47,6 +48,10 @@ void sip_uri_set_host(sip_uri_t *uri, const char *host){
uri->host = bctbx_strdup(host);
}
void sip_uri_set_port(sip_uri_t *uri, int port){
uri->port = port;
}
void sip_uri_destroy(sip_uri_t *uri){
if (uri->host) bctbx_free(uri->host);
if (uri->user) bctbx_free(uri->user);
......@@ -97,7 +102,8 @@ static void parser_connected_to_c_functions(void) {
->setCollector("host", make_fn(&sip_uri_set_host));
parser->setHandler("to", make_fn(&sip_uri_create))
->setCollector("user", make_fn(&sip_uri_set_user))
->setCollector("host", make_fn(&sip_uri_set_host));
->setCollector("host", make_fn(&sip_uri_set_host))
->setCollector("port", make_fn(&sip_uri_set_port));
size_t pos = 0;
void * elem = parser->parseInput("response", sipmessage, &pos);
BC_ASSERT_PTR_NOT_NULL(elem);
......@@ -115,6 +121,7 @@ static void parser_connected_to_c_functions(void) {
BC_ASSERT_STRING_EQUAL(to->user, "smorlat2");
BC_ASSERT_STRING_EQUAL(from->host, "siptest.linphone.org");
BC_ASSERT_STRING_EQUAL(to->host, "siptest.linphone.org");
BC_ASSERT_EQUAL(to->port, 5060, int, "%i");
}
sip_response_destroy(resp);
......
SIP/2.0 403 Forbidden
Via: SIP/2.0/TLS 192.168.0.25:41076;alias;branch=z9hG4bK.m-SPAXXd3;rport=41076;received=78.220.48.77
From: <sip:smorlat2@siptest.linphone.org>;tag=HW3X1aviU
To: <sip:smorlat2@siptest.linphone.org>;tag=yDXec8ej8Hrea
To: <sip:smorlat2@siptest.linphone.org:5060>;tag=yDXec8ej8Hrea
Call-ID: s69J2OQ4h4
CSeq: 21 REGISTER
Server: Flexisip/0.8.0 (sofia-sip-nta/2.0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment