File: make-check-bin

package info (click to toggle)
primecount 8.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,648 kB
  • sloc: cpp: 21,887; ansic: 121; sh: 100; makefile: 89
file content (76 lines) | stat: -rwxr-xr-x 1,721 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# autopkgtest check
set -ue
cd $AUTOPKGTEST_TMP

status=0

echo ""

# Test 1
res=$(primecount 10^10)
echo "Count primes using default algorithm: Primes <= 10^10: $res"

if [ "$res" -ne "455052511" ]; then
	echo "Error: Prime count test: correct result is 455052511" 1>&2
	status=1
fi

# Test 2
res=$(primecount 524309 --lehmer)
echo "Count primes using Lehmer's formula: Primes <= 524309: $res"

if [ "$res" -ne "43391" ]; then
	echo "Error: Prime count test: correct result is 43391" 1>&2
	status=1
fi

# Test 3
res=$(primecount 2**31 --legendre)
echo "Count primes using Legendre's formula: Primes <= 2^31: $res"

if [ "$res" -ne "105097565" ]; then
	echo "Error: Prime count test: correct result is 105097565" 1>&2
	status=1
fi

# Test 4
res=$(primecount 2**32 --meissel)
echo "Count primes using Meissel's formula: Primes <= 2**32: $res"

if [ "$res" -ne "203280221" ]; then
	echo "Error: Prime count test: correct result is 203280221" 1>&2
	status=1
fi

# Test 5
res=$(primecount 2**32+15 --deleglise-rivat)
echo "Count primes using the Deleglise-Rivat algorithm: Primes <= 2**32+15: $res"

if [ "$res" -ne "203280222" ]; then
	echo "Error: Prime count test: correct result is 203280222" 1>&2
	status=1
fi

# Test 6
res=$(primecount 2**32-17 --primesieve)
echo "Count primes using the sieve of Eratosthenes: Primes <= 2**32-17: $res"

if [ "$res" -ne "203280220" ]; then
	echo "Error: Prime count test: correct result is 203280220" 1>&2
	status=1
fi

# Test 7
res=$(primecount 10^9 -n)
echo "Calculate the 10^9 th prime: $res"

if [ "$res" -ne "22801763489" ]; then
	echo "Error: Nth prime test: correct result is 22801763489" 1>&2
	status=1
fi

echo ""
echo "All tests passed successfully!"

exit $status