blob: bc15e1538c1dc729466c3549fe1b44f57fe2a3f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include "linktemplates_tests.h"
#define LINK_TEMPLATES_TEST_FILE TEST_DATA_DIR "/links"
#define TEST_REGULAR_LINK "http://example.com/test/testpage.html"
#define TEST_IGNORED_LINK "http://example.com/ignoredpage.html"
#define TEST_STREAM_LINK "http://example.com/video/videopage.html"
void link_templates_fixture_setup(LinkTemplatesFixture *fixture,
G_GNUC_UNUSED gconstpointer test_data)
{
fixture->templates = link_templates_create();
g_assert(fixture->templates != NULL);
link_templates_load(fixture->templates, LINK_TEMPLATES_TEST_FILE);
}
void link_templates_fixture_teardown(LinkTemplatesFixture *fixture,
G_GNUC_UNUSED gconstpointer test_data)
{
link_templates_delete(fixture->templates);
fixture->templates = NULL;
}
void test_link_templates_load(LinkTemplatesFixture *fixture,
G_GNUC_UNUSED gconstpointer test_data)
{
g_assert(link_templates_size(fixture->templates) >= 1);
}
void test_link_templates_get(LinkTemplatesFixture *fixture,
G_GNUC_UNUSED gconstpointer test_data)
{
const struct LinkAction *action;
action = link_templates_get_action(fixture->templates, TEST_REGULAR_LINK);
g_assert(action);
g_assert(link_action_get_type(action) == LINK_ACTION_PARSE);
action = link_templates_get_action(fixture->templates, TEST_IGNORED_LINK);
g_assert(!action);
action = link_templates_get_action(fixture->templates, TEST_STREAM_LINK);
g_assert(action);
g_assert(link_action_get_type(action) == LINK_ACTION_EXTERNAL_COMMAND);
const char *command = link_action_get_command(action);
g_assert(command);
g_assert(strcmp(command, "test_command") == 0);
}
|