mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 20:41:27 -04:00
Add unit tests for version methods and feature-based backend selection
svn:r1211
This commit is contained in:
parent
7cf8a7b0e0
commit
122e934e92
@ -1368,7 +1368,7 @@ test_methods(void *ptr)
|
|||||||
++n_methods;
|
++n_methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_methods == 1) {
|
if (n_methods > 1) {
|
||||||
/* only one method supported; can't continue. */
|
/* only one method supported; can't continue. */
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -1390,9 +1390,61 @@ end:
|
|||||||
event_config_free(cfg);
|
event_config_free(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_version(void *arg)
|
||||||
|
{
|
||||||
|
const char *vstr;
|
||||||
|
ev_uint32_t vint;
|
||||||
|
int major, minor, patch, n;
|
||||||
|
|
||||||
|
vstr = event_get_version();
|
||||||
|
vint = event_get_version_number();
|
||||||
|
|
||||||
|
tt_assert(vstr);
|
||||||
|
tt_assert(vint);
|
||||||
|
|
||||||
|
tt_str_op(vstr, ==, LIBEVENT_VERSION);
|
||||||
|
tt_int_op(vint, ==, LIBEVENT_VERSION_NUMBER);
|
||||||
|
|
||||||
|
n = sscanf(vstr, "%d.%d.%d", &major, &minor, &patch);
|
||||||
|
tt_assert(3 == n);
|
||||||
|
tt_int_op(vint, ==, ((major<<24)|(minor<<16)|(patch<<8)));
|
||||||
|
end:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_base_features(void *arg)
|
||||||
|
{
|
||||||
|
struct event_base *base = NULL;
|
||||||
|
struct event_config *cfg = NULL;
|
||||||
|
|
||||||
|
cfg = event_config_new();
|
||||||
|
|
||||||
|
tt_assert(0 == event_config_require_features(cfg, EV_FEATURE_ET));
|
||||||
|
|
||||||
|
base = event_base_new_with_config(cfg);
|
||||||
|
if (base) {
|
||||||
|
tt_int_op(EV_FEATURE_ET, ==,
|
||||||
|
event_base_get_features(base) & EV_FEATURE_ET);
|
||||||
|
} else {
|
||||||
|
base = event_base_new();
|
||||||
|
tt_int_op(0, ==, event_base_get_features(base) & EV_FEATURE_ET);
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (base)
|
||||||
|
event_base_free(base);
|
||||||
|
if (cfg)
|
||||||
|
event_config_free(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct testcase_t main_testcases[] = {
|
struct testcase_t main_testcases[] = {
|
||||||
/* Some converted-over tests */
|
/* Some converted-over tests */
|
||||||
{ "methods", test_methods, TT_FORK, NULL, NULL },
|
{ "methods", test_methods, TT_FORK, NULL, NULL },
|
||||||
|
{ "version", test_version, 0, NULL, NULL },
|
||||||
|
{ "base_features", test_base_features, TT_FORK, NULL, NULL },
|
||||||
|
|
||||||
/* These are still using the old API */
|
/* These are still using the old API */
|
||||||
LEGACY(persistent_timeout, TT_FORK|TT_NEED_BASE),
|
LEGACY(persistent_timeout, TT_FORK|TT_NEED_BASE),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user