Skip to content

Commit

Permalink
Increased line coverage of base/combinatorics.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
mfasi committed May 16, 2015
1 parent 8f7531b commit f0acfe3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ a = randcycle(10)
@test collect(combinations("abc",2)) == Any[['a','b'],['a','c'],['b','c']]
@test collect(combinations("abc",1)) == Any[['a'],['b'],['c']]
@test collect(combinations("abc",0)) == Any[Char[]]
@test collect(combinations("abc",-1)) == Any[]
@test collect(permutations("abc")) == Any[['a','b','c'],['a','c','b'],['b','a','c'],
['b','c','a'],['c','a','b'],['c','b','a']]

Expand All @@ -45,6 +46,8 @@ a = randcycle(10)
@test collect(partitions([1,2,3,4],1)) == Any[Any[[1, 2, 3, 4]]]
@test collect(partitions([1,2,3,4],5)) == []

@test length(partitions(0)) == 1
@test length(partitions(-1)) == 0
@test length(collect(partitions(30))) == length(partitions(30))
@test length(collect(partitions(90,4))) == length(partitions(90,4))
@test length(collect(partitions('a':'h'))) == length(partitions('a':'h'))
Expand All @@ -57,6 +60,16 @@ for n = 0:7, k = 1:factorial(n)
end

@test factorial(7) == 5040
@test factorial(Int8(7)) == 5040
@test factorial(UInt8(7)) == 5040
@test factorial(Int16(7)) == 5040
@test factorial(UInt16(7)) == 5040
@test factorial(Int32(7)) == 5040
@test factorial(UInt32(7)) == 5040
@test factorial(Int64(7)) == 5040
@test factorial(UInt64(7)) == 5040
@test factorial(Int128(7)) == 5040
@test factorial(UInt128(7)) == 5040
@test factorial(7,3) == 7*6*5*4
@test_throws DomainError factorial(3,7)
@test_throws DomainError factorial(-3,-7)
Expand Down
5 changes: 5 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2206,9 +2206,14 @@ end
@test_throws DomainError nextpow(2,0)
@test_throws DomainError prevpow(2,0)

@test_throws ArgumentError nextprod([2,3,5],Int128(typemax(Int))+1)
@test nextprod([2,3,5],30) == 30
@test nextprod([2,3,5],33) == 36

@test_throws ArgumentError prevprod([2,3,5],Int128(typemax(Int))+1)
@test prevprod([2,3,5],30) == 30
@test prevprod([2,3,5],33) == 32

@test nextfloat(0.0) == 5.0e-324
@test prevfloat(0.0) == -5.0e-324
@test nextfloat(-0.0) == 5.0e-324
Expand Down

0 comments on commit f0acfe3

Please sign in to comment.