2013-11-26 22:55:28 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2013-11-26 22:54:42 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "utils_tcp.h"
|
|
|
|
#include "tap.h"
|
|
|
|
|
|
|
|
int
|
2013-11-26 23:00:46 +00:00
|
|
|
main(void)
|
2013-11-26 22:54:42 +00:00
|
|
|
{
|
2013-11-26 23:00:46 +00:00
|
|
|
char **server_expect;
|
2013-11-26 22:54:42 +00:00
|
|
|
int server_expect_count = 3;
|
2013-11-26 23:00:46 +00:00
|
|
|
|
|
|
|
plan_tests(9);
|
2013-11-26 22:54:42 +00:00
|
|
|
|
|
|
|
server_expect = malloc(sizeof(char*) * server_expect_count);
|
|
|
|
|
|
|
|
server_expect[0] = strdup("AA");
|
|
|
|
server_expect[1] = strdup("bb");
|
|
|
|
server_expect[2] = strdup("CC");
|
|
|
|
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test matching any string at the beginning (first expect string)");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test matching any string at the beginning (second expect string)");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("b", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_RETRY,
|
|
|
|
"Test matching any string at the beginning (substring match)");
|
|
|
|
ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test with strings not matching at the beginning");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("XX CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test matching any string");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("XX", server_expect, server_expect_count, 0) == NP_MATCH_RETRY,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test not matching any string");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_SUCCESS,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test matching all strings");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test not matching all strings");
|
2013-11-26 23:00:46 +00:00
|
|
|
ok(np_expect_match("XX XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY,
|
2013-11-26 22:54:42 +00:00
|
|
|
"Test not matching any string (testing all)");
|
|
|
|
|
|
|
|
|
|
|
|
return exit_status();
|
|
|
|
}
|