source: trunk/libtransmission/quark-test.c @ 14666

Last change on this file since 14666 was 14666, checked in by mikedld, 6 years ago

Use TR_BAD_SIZE instead of -1 in tr_quark_new() calls

Extend quark test to improve branch coverage.

  • 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 14666 2016-01-07 19:20:14Z 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  tr_quark q1, q2;
21
22  for (i=0; i<TR_N_KEYS; i++)
23    {
24      tr_quark q;
25      size_t len;
26      const char * str;
27
28      str = tr_quark_get_string (i, &len);
29      check_int_eq (strlen(str), len);
30      check (tr_quark_lookup (str, len, &q));
31      check_int_eq (i, q);
32    }
33
34  for (i=0; i+1<TR_N_KEYS; i++)
35    {
36      size_t len1, len2;
37      const char *str1, *str2;
38
39      str1 = tr_quark_get_string (i, &len1);
40      str2 = tr_quark_get_string (i+1, &len2);
41
42      check (strcmp (str1, str2) < 0);
43    }
44
45  const tr_quark q = tr_quark_new (NULL, TR_BAD_SIZE);
46  check_int_eq (TR_KEY_NONE, q);
47  check_streq ("", tr_quark_get_string (q, NULL));
48
49  return 0;
50}
51
52MAIN_SINGLE_TEST(test_static_quarks)
Note: See TracBrowser for help on using the repository browser.