check_csync_misc.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * libcsync -- a library to sync a directory with another
  3. *
  4. * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "torture.h"
  21. #include "csync_misc.h"
  22. #include <stdlib.h>
  23. static void check_csync_normalize_etag(void **state)
  24. {
  25. char *str;
  26. (void) state; /* unused */
  27. #define CHECK_NORMALIZE_ETAG(TEST, EXPECT) \
  28. str = csync_normalize_etag(TEST); \
  29. assert_string_equal(str, EXPECT); \
  30. free(str);
  31. CHECK_NORMALIZE_ETAG("foo", "foo");
  32. CHECK_NORMALIZE_ETAG("\"foo\"", "foo");
  33. CHECK_NORMALIZE_ETAG("\"nar123\"", "nar123");
  34. CHECK_NORMALIZE_ETAG("", "");
  35. CHECK_NORMALIZE_ETAG("\"\"", "");
  36. /* Test with -gzip (all combinaison) */
  37. CHECK_NORMALIZE_ETAG("foo-gzip", "foo");
  38. CHECK_NORMALIZE_ETAG("\"foo\"-gzip", "foo");
  39. CHECK_NORMALIZE_ETAG("\"foo-gzip\"", "foo");
  40. }
  41. int torture_run_tests(void)
  42. {
  43. const UnitTest tests[] = {
  44. unit_test(check_csync_normalize_etag),
  45. };
  46. return run_tests(tests);
  47. }