fast-import: use mem_pool_calloc()
[git.git] / t / t0016-oidmap.sh
blob0faef1f4f110dc0ce5006bcc9195d2a6216cd76a
1 #!/bin/sh
3 test_description='test oidmap'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 # This purposefully is very similar to t0011-hashmap.sh
10 test_oidmap () {
11 echo "$1" | test-tool oidmap $3 >actual &&
12 echo "$2" >expect &&
13 test_cmp expect actual
17 test_expect_success 'setup' '
19 test_commit one &&
20 test_commit two &&
21 test_commit three &&
22 test_commit four
26 test_expect_success 'put' '
28 test_oidmap "put one 1
29 put two 2
30 put invalidOid 4
31 put three 3" "NULL
32 NULL
33 Unknown oid: invalidOid
34 NULL"
38 test_expect_success 'replace' '
40 test_oidmap "put one 1
41 put two 2
42 put three 3
43 put invalidOid 4
44 put two deux
45 put one un" "NULL
46 NULL
47 NULL
48 Unknown oid: invalidOid
54 test_expect_success 'get' '
56 test_oidmap "put one 1
57 put two 2
58 put three 3
59 get two
60 get four
61 get invalidOid
62 get one" "NULL
63 NULL
64 NULL
66 NULL
67 Unknown oid: invalidOid
72 test_expect_success 'remove' '
74 test_oidmap "put one 1
75 put two 2
76 put three 3
77 remove one
78 remove two
79 remove invalidOid
80 remove four" "NULL
81 NULL
82 NULL
85 Unknown oid: invalidOid
86 NULL"
90 test_expect_success 'iterate' '
91 test-tool oidmap >actual.raw <<-\EOF &&
92 put one 1
93 put two 2
94 put three 3
95 iterate
96 EOF
98 # sort "expect" too so we do not rely on the order of particular oids
99 sort >expect <<-EOF &&
100 NULL
101 NULL
102 NULL
103 $(git rev-parse one) 1
104 $(git rev-parse two) 2
105 $(git rev-parse three) 3
108 sort <actual.raw >actual &&
109 test_cmp expect actual
112 test_done