test_tcp.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /******************************************************************************
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  13. $Id$
  14. ******************************************************************************/
  15. #include "common.h"
  16. #include "utils_tcp.h"
  17. #include "tap.h"
  18. int
  19. main (int argc, char **argv)
  20. {
  21. char** server_expect;
  22. int server_expect_count = 3;
  23. plan_tests(8);
  24. server_expect = malloc(sizeof(char*) * server_expect_count);
  25. server_expect[0] = strdup("AA");
  26. server_expect[1] = strdup("bb");
  27. server_expect[2] = strdup("CC");
  28. ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
  29. "Test matching any string at the beginning (first expect string)");
  30. ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
  31. "Test matching any string at the beginning (second expect string)");
  32. ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
  33. "Test with strings not matching at the beginning");
  34. ok(np_expect_match("XX CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
  35. "Test matching any string");
  36. ok(np_expect_match("XX", server_expect, server_expect_count, FALSE, FALSE, FALSE) == FALSE,
  37. "Test not matching any string");
  38. ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == TRUE,
  39. "Test matching all strings");
  40. ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
  41. "Test not matching all strings");
  42. ok(np_expect_match("XX XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
  43. "Test not matching any string (testing all)");
  44. return exit_status();
  45. }