git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
3f1c90eaf04361c9cbaf8d32e1178985e4d051f5 blob 1308 bytes (raw)

 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
 
#include "test-tool.h"
#include "cache.h"
#include "prefix-map.h"

static size_t test_count, failed_count;

static void check(int succeeded, const char *file, size_t line_no,
		  const char *fmt, ...)
{
	va_list ap;

	test_count++;
	if (succeeded)
		return;

	va_start(ap, fmt);
	fprintf(stderr, "%s:%d: ", file, (int)line_no);
	vfprintf(stderr, fmt, ap);
	fputc('\n', stderr);
	va_end(ap);

	failed_count++;
}

#define EXPECT_SIZE_T_EQUALS(expect, actual, hint) \
	check(expect == actual, __FILE__, __LINE__, \
	      "size_t's do not match: %" \
	      PRIdMAX " != %" PRIdMAX " (%s) (%s)", \
	      (intmax_t)expect, (intmax_t)actual, #actual, hint)

int cmd__prefix_map(int argc, const char **argv)
{
#define NR 5
	struct prefix_item items[NR] = {
		{ "unique" },
		{ "hell" },
		{ "hello" },
		{ "wok" },
		{ "world" },
	};
	struct prefix_item *list[NR] = {
		items, items + 1, items + 2, items + 3, items + 4
	};

	find_unique_prefixes(list, NR, 1, 3);

#define EXPECT_PREFIX_LENGTH_EQUALS(expect, index) \
	EXPECT_SIZE_T_EQUALS(expect, list[index]->prefix_length, \
			     list[index]->name)

	EXPECT_PREFIX_LENGTH_EQUALS(1, 0);
	EXPECT_PREFIX_LENGTH_EQUALS(0, 1);
	EXPECT_PREFIX_LENGTH_EQUALS(0, 2);
	EXPECT_PREFIX_LENGTH_EQUALS(3, 3);
	EXPECT_PREFIX_LENGTH_EQUALS(3, 4);

	return !!failed_count;
}
debug log:

solving 3f1c90eaf0 ...
found 3f1c90eaf0 in https://public-inbox.org/git/db1ede363645b0620d4924639efe5ec708441aa7.1554917868.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/3000d7d08dfb64511b4ebf9d05617897dd7252f7.1563289115.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/e02a52c3acf64657c012744108d7ccc3ecdf1b43.1557768471.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/c5a699b6b27e04cf341a20258702bb6d3df917e5.1566910672.git.gitgitgadget@gmail.com/

applying [1/4] https://public-inbox.org/git/db1ede363645b0620d4924639efe5ec708441aa7.1554917868.git.gitgitgadget@gmail.com/
diff --git a/t/helper/test-prefix-map.c b/t/helper/test-prefix-map.c
new file mode 100644
index 0000000000..3f1c90eaf0

Checking patch t/helper/test-prefix-map.c...
Applied patch t/helper/test-prefix-map.c cleanly.

skipping https://public-inbox.org/git/3000d7d08dfb64511b4ebf9d05617897dd7252f7.1563289115.git.gitgitgadget@gmail.com/ for 3f1c90eaf0
skipping https://public-inbox.org/git/e02a52c3acf64657c012744108d7ccc3ecdf1b43.1557768471.git.gitgitgadget@gmail.com/ for 3f1c90eaf0
skipping https://public-inbox.org/git/c5a699b6b27e04cf341a20258702bb6d3df917e5.1566910672.git.gitgitgadget@gmail.com/ for 3f1c90eaf0
index at:
100644 3f1c90eaf04361c9cbaf8d32e1178985e4d051f5	t/helper/test-prefix-map.c

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).