test_tcp.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. int i;
  22. char** server_expect;
  23. char* status;
  24. bool verbose;
  25. bool exact_match;
  26. int server_expect_count = 3;
  27. plan_tests(8);
  28. server_expect = malloc(sizeof(char*) * server_expect_count);
  29. server_expect[0] = strdup("AA");
  30. server_expect[1] = strdup("bb");
  31. server_expect[2] = strdup("CC");
  32. ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, false, true, false) == true,
  33. "Test matching any string at the beginning (first expect string)");
  34. ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, false, true, false) == true,
  35. "Test matching any string at the beginning (second expect string)");
  36. ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, false, true, false) == false,
  37. "Test with strings not matching at the beginning");
  38. ok(np_expect_match("XX CC XX", server_expect, server_expect_count, false, true, false) == false,
  39. "Test matching any string");
  40. ok(np_expect_match("XX", server_expect, server_expect_count, false, false, false) == false,
  41. "Test not matching any string");
  42. ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, true, false, false) == true,
  43. "Test matching all strings");
  44. ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, true, false, false) == false,
  45. "Test not matching all strings");
  46. ok(np_expect_match("XX XX", server_expect, server_expect_count, true, false, false) == false,
  47. "Test not matching any string (testing all)");
  48. return exit_status();
  49. }