File: inlinefy_string.c

package info (click to toggle)
newsraft 0.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,140 kB
  • sloc: ansic: 12,318; makefile: 76; sh: 28; xml: 21
file content (28 lines) | stat: -rw-r--r-- 690 bytes parent folder | download
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
#include <string.h>
#include "newsraft.h"

static const char *test_cases[][2] = {
	// Input                    Output
	{"King Stephen",            "King Stephen"},
	{"\t \n Hensonn",           " Hensonn"},
	{"OFFL1NX \r  \n",          "OFFL1NX "},
	{"  \n Vakhtang \n",        " Vakhtang "},
	{"Hollywood\n \n\t\tBurns", "Hollywood Burns"},
	{NULL,                      NULL},
};

int
main(void)
{
	struct string *str = crtes(100);
	for (size_t i = 0; test_cases[i][0] != NULL; ++i) {
		cpyas(&str, test_cases[i][0], strlen(test_cases[i][0]));
		inlinefy_string(str);
		if (strcmp(str->ptr, test_cases[i][1]) != 0) {
			free_string(str);
			return 1;
		}
	}
	free_string(str);
	return 0;
}