source: trunk/libtransmission/quark-test.c

Last change on this file was 14721, checked in by jordan, 5 years ago

fix a handful of minor compiler warnings, mostly in the unit tests, eg field width shortening or implicit signed/unsigned conversions

  • Property svn:keywords set to Date Rev Author Id
File size: 1.0 KB
Line 
1/*
2 * This file Copyright (C) 2013-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: quark-test.c 14721 2016-03-29 03:04:54Z mikedld $
8 */
9
10#include <string.h> /* strlen() */
11
12#include "transmission.h"
13#include "quark.h"
14#include "libtransmission-test.h"
15
16static int
17test_static_quarks (void)
18{
19  int i;
20
21  for (i=0; i<TR_N_KEYS; i++)
22    {
23      tr_quark q;
24      size_t len;
25      const char * str;
26
27      str = tr_quark_get_string ((tr_quark)i, &len);
28      check_uint_eq (strlen(str), len);
29      check (tr_quark_lookup (str, len, &q));
30      check_int_eq (i, (int)q);
31    }
32
33  for (i=0; i+1<TR_N_KEYS; i++)
34    {
35      size_t len1, len2;
36      const char *str1, *str2;
37
38      str1 = tr_quark_get_string ((tr_quark)i, &len1);
39      str2 = tr_quark_get_string ((tr_quark)(i+1), &len2);
40
41      check (strcmp (str1, str2) < 0);
42    }
43
44  const tr_quark q = tr_quark_new (NULL, TR_BAD_SIZE);
45  check_int_eq (TR_KEY_NONE, (int)q);
46  check_streq ("", tr_quark_get_string (q, NULL));
47
48  return 0;
49}
50
51MAIN_SINGLE_TEST(test_static_quarks)
Note: See TracBrowser for help on using the repository browser.