check_csync_misc.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 "common/utility.h"
  21. #include <cstdlib>
  22. #include "torture.h"
  23. static void check_csync_normalize_etag(void **state)
  24. {
  25. QByteArray str;
  26. (void) state; /* unused */
  27. #define CHECK_NORMALIZE_ETAG(TEST, EXPECT) \
  28. str = OCC::Utility::normalizeEtag(TEST); \
  29. assert_string_equal(str.constData(), EXPECT); \
  30. CHECK_NORMALIZE_ETAG("foo", "foo");
  31. CHECK_NORMALIZE_ETAG("\"foo\"", "foo");
  32. CHECK_NORMALIZE_ETAG("\"nar123\"", "nar123");
  33. CHECK_NORMALIZE_ETAG("", "");
  34. CHECK_NORMALIZE_ETAG("\"\"", "");
  35. /* Test with -gzip (all combinaison) */
  36. CHECK_NORMALIZE_ETAG("foo-gzip", "foo");
  37. CHECK_NORMALIZE_ETAG("\"foo\"-gzip", "foo");
  38. CHECK_NORMALIZE_ETAG("\"foo-gzip\"", "foo");
  39. }
  40. int torture_run_tests(void)
  41. {
  42. const struct CMUnitTest tests[] = {
  43. cmocka_unit_test(check_csync_normalize_etag),
  44. };
  45. return cmocka_run_group_tests(tests, nullptr, nullptr);
  46. }