]>
Commit | Line | Data |
---|---|---|
c1f7f538 CC |
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 | ||
fbec05c2 CC |
70 | test_expect_success 'remove' ' |
71 | ||
72 | test_oidmap "put one 1 | |
73 | put two 2 | |
74 | put three 3 | |
75 | remove one | |
76 | remove two | |
77 | remove invalidOid | |
78 | remove four" "NULL | |
79 | NULL | |
80 | NULL | |
81 | 1 | |
82 | 2 | |
83 | Unknown oid: invalidOid | |
84 | NULL" | |
85 | ||
86 | ' | |
87 | ||
c1f7f538 | 88 | test_expect_success 'iterate' ' |
e1e7a771 JK |
89 | test-tool oidmap >actual.raw <<-\EOF && |
90 | put one 1 | |
91 | put two 2 | |
92 | put three 3 | |
93 | iterate | |
94 | EOF | |
95 | ||
96 | # sort "expect" too so we do not rely on the order of particular oids | |
97 | sort >expect <<-EOF && | |
98 | NULL | |
99 | NULL | |
100 | NULL | |
101 | $(git rev-parse one) 1 | |
102 | $(git rev-parse two) 2 | |
103 | $(git rev-parse three) 3 | |
104 | EOF | |
105 | ||
106 | sort <actual.raw >actual && | |
107 | test_cmp expect actual | |
c1f7f538 CC |
108 | ' |
109 | ||
110 | test_done |