Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_htmlclean.c « htmlclean « libraries - github.com/jangernert/FeedReader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d8c37ad6dc15d498350b5e965fccc4da2a5bd880 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <glib.h>

#include "htmlclean.h"

typedef struct {
	const char* input;
	const char* output;
} inout_t;

static void test_change(const void* vinout)
{
	const inout_t* inout = vinout;
	g_assert_cmpstr (htmlclean_strip_html(inout->input), ==, inout->output);
}

static void test_no_change(const void* input)
{
	const inout_t inout = {
		.input = input,
		.output = input
	};
	test_change(&inout);
}

int main(int argc, char** argv)
{
	g_test_init (&argc, &argv, NULL);

	g_test_add_data_func (
		"/htmlclean/change/removehtml",
		&(inout_t){
			"this <pre>string</pre> contains html",
			"this string contains html"
		},
		test_change);

	g_test_add_data_func (
		"/htmlclean/change/stripinput",
		&(inout_t){
			"  this has spaces around it  ",
			"this has spaces around it"
		},
		test_change);

	g_test_add_data_func (
		"/htmlclean/nochange/basic",
		"this is a normal string",
		test_no_change
	);

	// g_test_add_data_func (
	// 	"/htmlclean/nochange/escapedhtml",
	// 	"this string contains &amp; escaped HTML",
	// 	test_no_change
	// );

	// Previous versions of the parser crashed or hung when given these inputs
	g_test_add_data_func (
		"/htmlclean/nochange/justopen",
		"<",
		test_no_change
	);

	g_test_add_data_func (
		"/htmlclean/nochange/justamp",
		"&",
		test_no_change
	);

	return g_test_run ();
}