aboutsummaryrefslogtreecommitdiff
blob: 917f24383279e0dad53b4bacf2a40fe97edc459e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

oneTimeSetUp()
{
	unset -f KV_to_int
	. ../helpers/shell-compat-KV.sh
}

check_kv()
{
	local input="$1" actual= expected="$2"
	actual=$(KV_to_int "$input" 2>/dev/null)
	assertEquals "$?" "0"
	assertEquals "$expected" "$actual"
}

expect_fail_kv()
{
	local input="$1" actual=
	actual=$(KV_to_int "$input" 2>&1)
	assertEquals "$?" "1"
	assertEquals "" "$actual"
}

testTooOld()
{
	expect_fail_kv 2.1.0
	expect_fail_kv 2.1.1
	expect_fail_kv 2.1.2
}

testOneDigit()
{
	check_kv 3	196608
}

testTwoDigit()
{
	check_kv 2.6	132608
	check_kv 3.0	196608
	check_kv 3.1	196864
}

testThreeDigit()
{
	check_kv 2.6.0	132608
	check_kv 2.6.1	132609
	check_kv 2.6.2	132610
	check_kv 2.6.35	132643
	check_kv 3.0.1	196609
}

testFourDigit()
{
	check_kv 2.6.35.1	132643
	check_kv 2.6.35.995	132643
}

testSuffixNormal()
{
	check_kv 2.6.35-2suf	132643
	check_kv 3.0-2suf	196608
}

testSuffixSpecial()
{
	check_kv 2.6.35.1+1suf	132643
	check_kv 2.6.35.1%3suf	132643
	check_kv 2.6.35.1x4suf	132643

	check_kv 2.6.35+1suf	132643
	check_kv 2.6.35%3suf	132643
	check_kv 2.6.35x4suf	132643

	check_kv 3.0+1suf	196608
	check_kv 3.0%3suf	196608
	check_kv 3.0x4suf	196608
}

. ./shunit2