Skip to content

Commit

Permalink
Include int tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Oct 2, 2019
1 parent bfa4c4c commit 9c411d7
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/int.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@testset "add_to! / add!" begin
@test MA.mutability(Int, MA.add_to!, Int, Int) isa MA.NotMutable
@test MA.mutability(Int, MA.add!, Int) isa MA.NotMutable
a = 5
b = 28
c = 41
@test MA.add_to!(a, b, c) == 69
@test MA.add!(b, c) == 69
a = 165
b = 255
@test MA.add!(a, b) == 420
end

@testset "mul_to! / mul!" begin
@test MA.mutability(Int, MA.mul_to!, Int, Int) isa MA.NotMutable
@test MA.mutability(Int, MA.mul!, Int) isa MA.NotMutable
a = 5
b = 23
c = 3
@test MA.mul_to!(a, b, c) == 69
@test MA.mul!(b, c) == 69
a = 15
b = 28
@test MA.mul!(a, b) == 420
end

@testset "muladd_to! / muladd! / muladd_buf_to! /muladd_buf!" begin
@test MA.mutability(Int, MA.muladd_to!, Int, Int, Int) isa MA.NotMutable
@test MA.mutability(Int, MA.muladd!, Int, Int) isa MA.NotMutable
@test MA.mutability(Int, MA.muladd_buf_to!, Int, Int, Int, Int) isa MA.NotMutable
@test MA.mutability(Int, MA.muladd_buf!, Int, Int, Int) isa MA.NotMutable
a = 5
b = 9
c = 3
d = 20
buf = 24
@test MA.muladd_to!(a, b, c, d) == 69
@test MA.muladd!(b, c, d) == 69
@test MA.muladd_buf_to!(buf, a, b, c, d) == 69
@test MA.muladd_buf!(buf, b, c, d) == 69
a = 148
b = 16
c = 17
@test MA.muladd!(a, b, c) == 420
a = 148
b = 16
c = 17
buf = 56
@test MA.muladd_buf!(buf, a, b, c) == 420
a = 148
b = 16
c = 17
d = 42
buf = 56
@test MA.muladd_buf_to!(buf, d, a, b, c) == 420
end

@testset "zero!" begin
@test MA.mutability(Int, MA.zero!) isa MA.NotMutable
a = 5
@test MA.zero!(a) == 0
end

@testset "one!" begin
@test MA.mutability(Int, MA.one!) isa MA.NotMutable
a = 5
@test MA.one!(a) == 1
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ using Test
import MutableArithmetics
const MA = MutableArithmetics

@testset "Int" begin
include("int.jl")
end
@testset "BigInt" begin
include("bigint.jl")
end
Expand Down

0 comments on commit 9c411d7

Please sign in to comment.