1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-07-30 06:05:31 +02:00

more tests

This commit is contained in:
kalmar 2017-05-18 12:19:52 +02:00
parent 148c8e2611
commit c7477dd25f

View File

@ -3,8 +3,8 @@ using Base.Test
using Nemo
# write your own tests here
@testset "GroupRing constructors: PermutationGroup" begin
@testset "GroupRings" begin
@testset "Constructors: PermutationGroup" begin
G = PermutationGroup(3)
@test isa(GroupRing(G), Nemo.Ring)
@ -61,6 +61,11 @@ end
a = rand(6)
@test isa(GroupRingElem(a, RG), GroupRingElem)
@test isa(RG(a), GroupRingElem)
for g in elements(G)
@test isa(RG(g), GroupRingElem)
end
@test_throws String GroupRingElem([1,2,3], RG)
@test isa(RG(G([2,3,1])), GroupRingElem)
p = G([2,3,1])
@ -70,9 +75,71 @@ end
@test a.coeffs[5] == 1
@test a[5] == 1
@test RG([0,0,0,0,1,0]) == a
@test a[p] == 1
@test a[G([1,2,3])] == 0
@test string(a) == "1*[2, 3, 1]"
@test RG([0,0,0,0,1,0]) == a
end
@testset "Arithmetic" begin
G = PermutationGroup(3)
RG = GroupRing(G, full=true)
a = RG(ones(Int, order(G)))
@testset "scalar operators" begin
@test isa(-a, GroupRingElem)
@test (-a).coeffs == -(a.coeffs)
@test isa(2*a, GroupRingElem)
@test eltype(2*a) == typeof(2)
@test (2*a).coeffs == 2.*(a.coeffs)
@test isa(2.0*a, GroupRingElem)
@test eltype(2.0*a) == typeof(2.0)
@test (2.0*a).coeffs == 2.0.*(a.coeffs)
@test isa(a/2, GroupRingElem)
@test eltype(a/2) == typeof(1/2)
@test (a/2).coeffs == 0.5*(a.coeffs)
@test isa(convert(Rational{Int}, a), GroupRingElem)
@test eltype(convert(Rational{Int}, a)) == Rational{Int}
@test convert(Rational{Int}, a).coeffs ==
convert(Vector{Rational{Int}}, a.coeffs)
b = convert(Rational{Int}, a)
@test isa(b//4, GroupRingElem)
@test eltype(b//4) == Rational{Int}
@test isa(b//big(4), GroupElem)
@test eltype(b//(big(4)//1)) == Rational{BigInt}
@test isa(a//1, GroupRingElem)
@test eltype(a//1) == Rational{Int}
@test_throws MethodError (1.0*a)//1
end
@testset "Additive structure" begin
@test RG(ones(Int, order(G))) == sum(RG(g) for g in elements(G))
a = RG(ones(Int, order(G)))
b = sum((-1)^parity(g)*RG(g) for g in elements(G))
end
@testset "Multiplicative structure" begin
for g in elements(G), h in elements(G)
a = RG(g)
b = RG(h)
@test a*b == RG(g*h)
@test (a+b)*(a+b) == a*a + a*b + b*a + b*b
@test
end
end
end
end