t: add t0016-oidmap.sh
Add actual tests for operations using `struct oidmap` from oidmap.{c,h}. Helped-by: SZEDER Gábor <szeder.dev@gmail.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jun 15, 2019 at 12:07 UTC
c1f7f53834636081af83743737a45e3c7fee7ee0
1 file changed
+84
t/t0016-oidmap.sh
new
+84
@@ -0,0 +1,84 @@
1
+#!/bin/sh
2
+
3
+test_description='test oidmap'
4
+. ./test-lib.sh
5
+
6
+# This purposefully is very similar to t0011-hashmap.sh
7
+
8
+test_oidmap () {
9
+ echo "$1" | test-tool oidmap $3 >actual &&
10
+ echo "$2" >expect &&
11
+ test_cmp expect actual
12
+}
13
+
14
+
15
+test_expect_success 'setup' '
16
+
17
+ test_commit one &&
18
+ test_commit two &&
19
+ test_commit three &&
20
+ test_commit four
21
+
22
+'
23
+
24
+test_expect_success 'put' '
25
+
26
+test_oidmap "put one 1
27
+put two 2
28
+put invalidOid 4
29
+put three 3" "NULL
30
+NULL
31
+Unknown oid: invalidOid
32
+NULL"
33
+
34
+'
35
+
36
+test_expect_success 'replace' '
37
+
38
+test_oidmap "put one 1
39
+put two 2
40
+put three 3
41
+put invalidOid 4
42
+put two deux
43
+put one un" "NULL
44
+NULL
45
+NULL
46
+Unknown oid: invalidOid
47
+2
48
+1"
49
+
50
+'
51
+
52
+test_expect_success 'get' '
53
+
54
+test_oidmap "put one 1
55
+put two 2
56
+put three 3
57
+get two
58
+get four
59
+get invalidOid
60
+get one" "NULL
61
+NULL
62
+NULL
63
+2
64
+NULL
65
+Unknown oid: invalidOid
66
+1"
67
+
68
+'
69
+
70
+test_expect_success 'iterate' '
71
+
72
+test_oidmap "put one 1
73
+put two 2
74
+put three 3
75
+iterate" "NULL
76
+NULL
77
+NULL
78
+$(git rev-parse two) 2
79
+$(git rev-parse one) 1
80
+$(git rev-parse three) 3"
81
+
82
+'
83
+
84
+test_done