summaryrefslogtreecommitdiff
path: root/algorithms/list_test.c
blob: 23990c25e66cf2bc622987501481f94db9a0075b (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
#include <stdio.h>
#include <stdlib.h>
#include "list.h"


void
test1(void)
{
	char test1str[]="Hier gibts nichts mit Kommata zu splitten.";
	List *l;
	char *str;

	l = list_split(test1str, ",");
	str = list_join(l, "Das hier darf nicht vorkommen");
	printf("Soll: %s\n", test1str);
	printf("Ist:  %s\n", str);
	list_free(l);
	free(str);
	l = list_split(test1str, " ");
	str = list_join(l, "um ");
	printf("Soll: %s\n", "Hierum gibtsum nichtsum mitum"
		" Kommataum zuum splitten.");
	printf("Ist:  %s\n", str);
	list_free(l);
	free(str);
}

void
test2(void)
{
	char test2str[]="3, 4, 5, ";
	List *l;
	char *str;

	l = list_split(test2str, ", ");
	str = list_join(l, "/");
	printf("Soll: %s\n", "3/4/5/");
	printf("Ist:  %s\n", str);
	list_free(l);
	free(str);
}

int main(void)
{
	test1();
	test2();

	return 0;
}