File: format_position.c

package info (click to toggle)
vifm 0.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,252 kB
  • sloc: ansic: 179,567; sh: 5,445; makefile: 723; perl: 347; python: 76; xml: 26
file content (56 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (3)
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
#include <stic.h>

#include "../../src/utils/utils.h"

TEST(all)
{
	char buf[32];

	format_position(buf, sizeof(buf), 0, 1, 10);
	assert_string_equal("All", buf);

	format_position(buf, sizeof(buf), 0, 9, 10);
	assert_string_equal("All", buf);

	format_position(buf, sizeof(buf), 0, 10, 10);
	assert_string_equal("All", buf);
}

TEST(top)
{
	char buf[32];

	format_position(buf, sizeof(buf), 0, 11, 10);
	assert_string_equal("Top", buf);

	format_position(buf, sizeof(buf), 0, 100, 10);
	assert_string_equal("Top", buf);
}

TEST(bottom)
{
	char buf[32];

	format_position(buf, sizeof(buf), 1, 11, 10);
	assert_string_equal("Bot", buf);

	format_position(buf, sizeof(buf), 1, 101, 100);
	assert_string_equal("Bot", buf);
}

TEST(percent)
{
	char buf[32];

	format_position(buf, sizeof(buf), 1, 12, 10);
	assert_string_equal("50%", buf);

	format_position(buf, sizeof(buf), 1, 13, 10);
	assert_string_equal("33%", buf);

	format_position(buf, sizeof(buf), 2, 13, 10);
	assert_string_equal("66%", buf);
}

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */