mirror of https://github.com/sipwise/sems.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.2 KiB
49 lines
2.2 KiB
#include "fct.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "AmSipHeaders.h"
|
|
#include "AmSipMsg.h"
|
|
#include "AmUtils.h"
|
|
|
|
FCTMF_SUITE_BGN(test_headers) {
|
|
|
|
FCT_TEST_BGN(getHeader_simple) {
|
|
fct_chk( getHeader("P-My-Test: myval" CRLF, "P-My-Test") == "myval");
|
|
} FCT_TEST_END();
|
|
|
|
FCT_TEST_BGN(getHeader_multi) {
|
|
fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", true) == "myval" );
|
|
fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", false) == "myval, myval2" );
|
|
fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Otherheader: myval2" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", false) == "myval, myval2" );
|
|
} FCT_TEST_END();
|
|
|
|
FCT_TEST_BGN(getHeader_atend) {
|
|
|
|
fct_chk(getHeader("P-My-Test: mykey=myval;myotherkey=myval" ,
|
|
"P-My-Test", true) == "mykey=myval;myotherkey=myval");
|
|
fct_chk(getHeader("P-My-Test: mykey=myval;myotherkey=myval\n" ,
|
|
"P-My-Test", true) == "mykey=myval;myotherkey=myval");
|
|
fct_chk(getHeader("P-My-Test: mykey=myval;myotherkey=myval\r" ,
|
|
"P-My-Test", true) == "mykey=myval;myotherkey=myval");
|
|
fct_chk(getHeader("P-My-Test: mykey=myval;myotherkey=myval\r\n" ,
|
|
"P-My-Test", true) == "mykey=myval;myotherkey=myval");
|
|
fct_chk(getHeader("P-My-Test: mykey=myval;myotherkey=myval\r\nP-anotherheader:xy" ,
|
|
"P-My-Test", true) == "mykey=myval;myotherkey=myval");
|
|
|
|
} FCT_TEST_END();
|
|
|
|
FCT_TEST_BGN(getHeader_keyvalue) {
|
|
fct_chk(get_header_keyvalue("mykey=myval;myotherkey=myval", "mykey") == "myval");
|
|
fct_chk(get_header_keyvalue("mykey=myval;myotherkey=myval", "myotherkey") == "myval");
|
|
fct_chk(get_header_keyvalue("mykey=myval;myotherkey=", "myotherkey") == "");
|
|
fct_chk(get_header_keyvalue(getHeader("P-My-Test: mykey=myval;myotherfunkykey=myval" CRLF, "P-My-Test", true), "mykey") == "myval" );
|
|
|
|
fct_chk(get_header_keyvalue(getHeader("P-My-Test: mykey=myval;myotherfunkykey=myval", "P-My-Test", true), "mykey") == "myval" );
|
|
|
|
fct_chk(get_header_keyvalue(getHeader("P-My-Test: mykey=myval;myotherfunkykey=myval2", "P-My-Test", true), "myotherfunkykey") == "myval2" );
|
|
|
|
} FCT_TEST_END();
|
|
|
|
} FCTMF_SUITE_END();
|