File: xwcswidth.c

package info (click to toggle)
swirc 3.5.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,092 kB
  • sloc: cpp: 19,125; ansic: 18,465; sh: 1,012; python: 254; makefile: 108; javascript: 20
file content (42 lines) | stat: -rw-r--r-- 693 bytes parent folder | download | duplicates (2)
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
#include "common.h"

#include <setjmp.h>
#ifdef UNIT_TESTING
#undef UNIT_TESTING
#endif
#include <cmocka.h>

#include "dataClassify.h"

static int expected = -1;

static void
test1(void **state)
{
	const wchar_t str[] = L"Ӽe̲̅v̲̅o̲̅l̲̅u̲̅t̲̅i̲̅o̲̅ɳ̲̅ᕗ";

	expected = 11;
	assert_true(xwcswidth(str, 2) == expected);
	UNUSED_PARAM(state);
}

static void
test2(void **state)
{
	const wchar_t str[] = L"你a好b世c界";

	expected = 11;
	assert_true(xwcswidth(str, 2) == expected);
	UNUSED_PARAM(state);
}

int
main(void)
{
	const struct CMUnitTest tests[] = {
		cmocka_unit_test(test1),
		cmocka_unit_test(test2),
	};

	return cmocka_run_group_tests(tests, NULL, NULL);
}