1#!/bin/sh
2
3test_description='test oidmap'
4. ./test-lib.sh
5
6# This purposefully is very similar to t0011-hashmap.sh
7
8test_oidmap () {
9 echo "$1" | test-tool oidmap $3 >actual &&
10 echo "$2" >expect &&
11 test_cmp expect actual
12}
13
14
15test_expect_success 'setup' '
16
17 test_commit one &&
18 test_commit two &&
19 test_commit three &&
20 test_commit four
21
22'
23
24test_expect_success 'put' '
25
26test_oidmap "put one 1
27put two 2
28put invalidOid 4
29put three 3" "NULL
30NULL
31Unknown oid: invalidOid
32NULL"
33
34'
35
36test_expect_success 'replace' '
37
38test_oidmap "put one 1
39put two 2
40put three 3
41put invalidOid 4
42put two deux
43put one un" "NULL
44NULL
45NULL
46Unknown oid: invalidOid
472
481"
49
50'
51
52test_expect_success 'get' '
53
54test_oidmap "put one 1
55put two 2
56put three 3
57get two
58get four
59get invalidOid
60get one" "NULL
61NULL
62NULL
632
64NULL
65Unknown oid: invalidOid
661"
67
68'
69
70test_expect_success 'remove' '
71
72test_oidmap "put one 1
73put two 2
74put three 3
75remove one
76remove two
77remove invalidOid
78remove four" "NULL
79NULL
80NULL
811
822
83Unknown oid: invalidOid
84NULL"
85
86'
87
88test_expect_success 'iterate' '
89
90test_oidmap "put one 1
91put two 2
92put three 3
93iterate" "NULL
94NULL
95NULL
96$(git rev-parse two) 2
97$(git rev-parse one) 1
98$(git rev-parse three) 3"
99
100'
101
102test_done