2014-01-19 01:09:44 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2013-2014 Mnemosyne LLC
|
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-12-22 20:35:19 +00:00
|
|
|
#include <string.h> /* strlen() */
|
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "quark.h"
|
|
|
|
#include "libtransmission-test.h"
|
|
|
|
|
|
|
|
static int
|
|
|
|
test_static_quarks (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<TR_N_KEYS; i++)
|
|
|
|
{
|
|
|
|
tr_quark q;
|
|
|
|
size_t len;
|
|
|
|
const char * str;
|
|
|
|
|
2016-03-29 03:04:54 +00:00
|
|
|
str = tr_quark_get_string ((tr_quark)i, &len);
|
|
|
|
check_uint_eq (strlen(str), len);
|
2012-12-22 20:35:19 +00:00
|
|
|
check (tr_quark_lookup (str, len, &q));
|
2016-03-29 03:04:54 +00:00
|
|
|
check_int_eq (i, (int)q);
|
2012-12-22 20:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i+1<TR_N_KEYS; i++)
|
|
|
|
{
|
|
|
|
size_t len1, len2;
|
|
|
|
const char *str1, *str2;
|
|
|
|
|
2016-03-29 03:04:54 +00:00
|
|
|
str1 = tr_quark_get_string ((tr_quark)i, &len1);
|
|
|
|
str2 = tr_quark_get_string ((tr_quark)(i+1), &len2);
|
2012-12-22 20:35:19 +00:00
|
|
|
|
|
|
|
check (strcmp (str1, str2) < 0);
|
|
|
|
}
|
|
|
|
|
2016-01-07 19:20:14 +00:00
|
|
|
const tr_quark q = tr_quark_new (NULL, TR_BAD_SIZE);
|
2016-03-29 03:04:54 +00:00
|
|
|
check_int_eq (TR_KEY_NONE, (int)q);
|
2016-01-07 19:20:14 +00:00
|
|
|
check_streq ("", tr_quark_get_string (q, NULL));
|
|
|
|
|
2012-12-22 20:35:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MAIN_SINGLE_TEST(test_static_quarks)
|