git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob d472ff5dc6a1b0559427c558686ea67ee35dfc5c 1623 bytes (raw)
name: t/helper/test-prefix-map.c 	 # note: path name is non-authoritative(*)

 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
59
60
61
62
63
64
65
66
67
68
69
 
#include "test-tool.h"
#include "unique-prefix.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: expected: %" \
	      PRIdMAX " got: %" PRIdMAX " (%s) (%s)", \
	      (intmax_t)expect, (intmax_t)actual, #actual, hint)

int cmd__prefix_map(int argc, const char **argv)
{
	size_t i;
	struct prefix_item items[] = {
		{ "unique" },
		{ "hell" },
		{ "hello" },
		{ "wok" },
		{ "world" },
		{ "a" },
		{ "" },
		{ "pq" },
		{ "pq" },
		{ "pqr" },
	};
	struct prefix_item *list[ARRAY_SIZE(items)];
	for (i = 0; i < ARRAY_SIZE(items); i++) {
		list[i] = &items[i];
		list[i]->prefix_length = 12345; /* dummy */
	}

	find_unique_prefixes(list, ARRAY_SIZE(list), 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);
	EXPECT_PREFIX_LENGTH_EQUALS(1, 5);
	EXPECT_PREFIX_LENGTH_EQUALS(0, 6);
	EXPECT_PREFIX_LENGTH_EQUALS(0, 7);
	EXPECT_PREFIX_LENGTH_EQUALS(0, 8);
	EXPECT_PREFIX_LENGTH_EQUALS(3, 9);

	return !!failed_count;
}

debug log:

solving d472ff5dc6 ...
found d472ff5dc6 in https://public-inbox.org/git/20190828163419.30620-1-szeder.dev@gmail.com/
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/2] 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

applying [2/2] https://public-inbox.org/git/20190828163419.30620-1-szeder.dev@gmail.com/
diff --git a/t/helper/test-prefix-map.c b/t/helper/test-prefix-map.c
index 3f1c90eaf0..d472ff5dc6 100644

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

index at:
100644 d472ff5dc6a1b0559427c558686ea67ee35dfc5c	t/helper/test-prefix-map.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public 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).