]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0069-oidtree.sh
The third batch
[thirdparty/git.git] / t / t0069-oidtree.sh
1 #!/bin/sh
2
3 test_description='basic tests for the oidtree implementation'
4 TEST_PASSES_SANITIZE_LEAK=true
5 . ./test-lib.sh
6
7 maxhexsz=$(test_oid hexsz)
8 echoid () {
9 prefix="${1:+$1 }"
10 shift
11 while test $# -gt 0
12 do
13 shortoid="$1"
14 shift
15 difference=$(($maxhexsz - ${#shortoid}))
16 printf "%s%s%0${difference}d\\n" "$prefix" "$shortoid" "0"
17 done
18 }
19
20 test_expect_success 'oidtree insert and contains' '
21 cat >expect <<-\EOF &&
22 0
23 0
24 0
25 1
26 1
27 0
28 EOF
29 {
30 echoid insert 444 1 2 3 4 5 a b c d e &&
31 echoid contains 44 441 440 444 4440 4444 &&
32 echo clear
33 } | test-tool oidtree >actual &&
34 test_cmp expect actual
35 '
36
37 test_expect_success 'oidtree each' '
38 echoid "" 123 321 321 >expect &&
39 {
40 echoid insert f 9 8 123 321 a b c d e &&
41 echo each 12300 &&
42 echo each 3211 &&
43 echo each 3210 &&
44 echo each 32100 &&
45 echo clear
46 } | test-tool oidtree >actual &&
47 test_cmp expect actual
48 '
49
50 test_done