3
3
test_description=' basic tests for the SHA1 array implementation'
4
4
. ./test-lib.sh
5
5
6
- echo20 () {
6
+ echoid () {
7
7
prefix=" ${1: +$1 } "
8
8
shift
9
9
while test $# -gt 0
10
10
do
11
- echo " $prefix $1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1 "
11
+ echo " $prefix$ZERO_OID " | sed -e " s/00/ $1 /g "
12
12
shift
13
13
done
14
14
}
15
15
16
16
test_expect_success ' ordered enumeration' '
17
- echo20 "" 44 55 88 aa >expect &&
17
+ echoid "" 44 55 88 aa >expect &&
18
18
{
19
- echo20 append 88 44 aa 55 &&
19
+ echoid append 88 44 aa 55 &&
20
20
echo for_each_unique
21
21
} | test-tool sha1-array >actual &&
22
22
test_cmp expect actual
23
23
'
24
24
25
25
test_expect_success ' ordered enumeration with duplicate suppression' '
26
- echo20 "" 44 55 88 aa >expect &&
26
+ echoid "" 44 55 88 aa >expect &&
27
27
{
28
- echo20 append 88 44 aa 55 &&
29
- echo20 append 88 44 aa 55 &&
28
+ echoid append 88 44 aa 55 &&
29
+ echoid append 88 44 aa 55 &&
30
30
echo for_each_unique
31
31
} | test-tool sha1-array >actual &&
32
32
test_cmp expect actual
33
33
'
34
34
35
35
test_expect_success ' lookup' '
36
36
{
37
- echo20 append 88 44 aa 55 &&
38
- echo20 lookup 55
37
+ echoid append 88 44 aa 55 &&
38
+ echoid lookup 55
39
39
} | test-tool sha1-array >actual &&
40
40
n=$(cat actual) &&
41
41
test "$n" -eq 1
42
42
'
43
43
44
44
test_expect_success ' lookup non-existing entry' '
45
45
{
46
- echo20 append 88 44 aa 55 &&
47
- echo20 lookup 33
46
+ echoid append 88 44 aa 55 &&
47
+ echoid lookup 33
48
48
} | test-tool sha1-array >actual &&
49
49
n=$(cat actual) &&
50
50
test "$n" -lt 0
51
51
'
52
52
53
53
test_expect_success ' lookup with duplicates' '
54
54
{
55
- echo20 append 88 44 aa 55 &&
56
- echo20 append 88 44 aa 55 &&
57
- echo20 lookup 55
55
+ echoid append 88 44 aa 55 &&
56
+ echoid append 88 44 aa 55 &&
57
+ echoid lookup 55
58
58
} | test-tool sha1-array >actual &&
59
59
n=$(cat actual) &&
60
60
test "$n" -ge 2 &&
@@ -63,28 +63,33 @@ test_expect_success 'lookup with duplicates' '
63
63
64
64
test_expect_success ' lookup non-existing entry with duplicates' '
65
65
{
66
- echo20 append 88 44 aa 55 &&
67
- echo20 append 88 44 aa 55 &&
68
- echo20 lookup 66
66
+ echoid append 88 44 aa 55 &&
67
+ echoid append 88 44 aa 55 &&
68
+ echoid lookup 66
69
69
} | test-tool sha1-array >actual &&
70
70
n=$(cat actual) &&
71
71
test "$n" -lt 0
72
72
'
73
73
74
74
test_expect_success ' lookup with almost duplicate values' '
75
+ # n-1 5s
76
+ root=$(echoid "" 55) &&
77
+ root=${root%5} &&
75
78
{
76
- echo "append 5555555555555555555555555555555555555555" &&
77
- echo "append 555555555555555555555555555555555555555f" &&
78
- echo20 lookup 55
79
+ id1="${root}5" &&
80
+ id2="${root}f" &&
81
+ echo "append $id1" &&
82
+ echo "append $id2" &&
83
+ echoid lookup 55
79
84
} | test-tool sha1-array >actual &&
80
85
n=$(cat actual) &&
81
86
test "$n" -eq 0
82
87
'
83
88
84
89
test_expect_success ' lookup with single duplicate value' '
85
90
{
86
- echo20 append 55 55 &&
87
- echo20 lookup 55
91
+ echoid append 55 55 &&
92
+ echoid lookup 55
88
93
} | test-tool sha1-array >actual &&
89
94
n=$(cat actual) &&
90
95
test "$n" -ge 0 &&
0 commit comments