Skip to content

Commit 7045289

Browse files
committed
Improve test coverage for corner casese
1 parent afe8123 commit 7045289

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

test/factorials.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ using Base.Test
1111
@test_throws OverflowError factorial(1000,80)
1212

1313
# derangement
14-
@test derangement(4) == 9
14+
@test derangement(4) == subfactorial(4) == 9
1515
@test derangement(24) == parse(BigInt,"228250211305338670494289")
1616

1717
# doublefactorial
1818
@test doublefactorial(70) == parse(BigInt,"355044260642859198243475901411974413130137600000000")
19+
@test_throws DomainError doublefactorial(-1)
1920

2021
# hyperfactorial
2122
@test hyperfactorial(8) == parse(BigInt,"55696437941726556979200000")
2223

2324
# multifactorial
2425
@test multifactorial(40,2) == doublefactorial(40)
26+
@test_throws DomainError multifactorial(-1,1)
2527

2628
# multinomial
2729
@test multinomial(1,4,4,2) == 34650
2830

2931
# primorial
3032
@test primorial(17) == 510510
31-
33+
@test_throws DomainError primorial(-1)
3234

test/numbers.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ using Base.Test
88
# fibonacci
99
@test fibonaccinum(5) == 5
1010
@test fibonaccinum(101) == parse(BigInt,"573147844013817084101")
11+
@test_throws DomainError fibonaccinum(-1)
1112

1213
# lassalle
1314
@test lassallenum(14) == parse(BigInt,"270316008395632253340")
@@ -18,6 +19,7 @@ using Base.Test
1819
# lucas
1920
@test lucasnum(10) == 123
2021
@test lucasnum(100) == parse(BigInt,"792070839848372253127")
22+
@test_throws DomainError lucasnum(-1)
2123

2224
# stirlings1
2325
@test sum([abs(stirlings1(8, i)) for i = 0:8]) == factorial(8)

test/partitions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Combinatorics: partitions, prevprod
2020
@test length(collect(partitions('a':'h',5))) == length(partitions('a':'h',5))
2121

2222
# integer_partitions
23+
@test integer_partitions(0) == []
2324
@test integer_partitions(5) == Any[[1, 1, 1, 1, 1], [2, 1, 1, 1], [2, 2, 1], [3, 1, 1], [3, 2], [4, 1], [5]]
2425
@test_throws DomainError integer_partitions(-1)
2526

test/youngdiagrams.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using Combinatorics
22
using Base.Test
33

44
@test ([5,4,2,2]\[2,1]) == ([5, 4, 2, 2],[2, 1])
5+
@test leglength([5,4,2,2], [2,1]) == leglength(([5, 4, 2, 2],[2, 1])) == 3
56
@test isrimhook([4,3,2], [2,2,2])
67
@test !isrimhook([4,3,2], [2,2,1])
78
@test !isrimhook([4,3,2], [1,1])

0 commit comments

Comments
 (0)