more tests

This commit is contained in:
kalmar 2017-05-18 12:19:52 +02:00
parent 148c8e2611
commit c7477dd25f
1 changed files with 132 additions and 65 deletions

View File

@ -3,76 +3,143 @@ using Base.Test
using Nemo
# write your own tests here
@testset "GroupRing constructors: PermutationGroup" begin
G = PermutationGroup(3)
@testset "GroupRings" begin
@testset "Constructors: PermutationGroup" begin
G = PermutationGroup(3)
@test isa(GroupRing(G), Nemo.Ring)
@test isa(GroupRing(G), GroupRing)
@test isa(GroupRing(G), Nemo.Ring)
@test isa(GroupRing(G), GroupRing)
RG = GroupRing(G)
@test isdefined(RG, :pm) == false
@test isdefined(RG, :basis) == false
@test isdefined(RG, :basis_dict) == false
RG = GroupRing(G)
@test isdefined(RG, :pm) == false
@test isdefined(RG, :basis) == false
@test isdefined(RG, :basis_dict) == false
@test isa(complete(RG), GroupRing)
@test size(RG.pm) == (6,6)
@test length(RG.basis) == 6
@test isa(complete(RG), GroupRing)
@test size(RG.pm) == (6,6)
@test length(RG.basis) == 6
@test RG.basis_dict == GroupRings.reverse_dict(elements(G))
@test RG.basis_dict == GroupRings.reverse_dict(elements(G))
@test isa(GroupRing(G, collect(elements(G))), GroupRing)
S = collect(elements(G))
pm = create_pm(S)
@test isa(GroupRing(G, S), GroupRing)
@test isa(GroupRing(G, S, pm), GroupRing)
@test isa(GroupRing(G, collect(elements(G))), GroupRing)
S = collect(elements(G))
pm = create_pm(S)
@test isa(GroupRing(G, S), GroupRing)
@test isa(GroupRing(G, S, pm), GroupRing)
A = GroupRing(G, S)
B = GroupRing(G, S, pm)
A = GroupRing(G, S)
B = GroupRing(G, S, pm)
@test RG == A
@test RG == B
end
@testset "GroupRing constructors FreeGroup" begin
using Groups
F = FreeGroup(3)
S = generators(F)
append!(S, [inv(s) for s in S])
S = unique(S)
basis, sizes = Groups.generate_balls(S, F(), radius=4)
d = GroupRings.reverse_dict(basis)
@test_throws KeyError create_pm(basis)
pm = create_pm(basis, d, sizes[2])
@test isa(GroupRing(F, basis, pm), GroupRing)
@test isa(GroupRing(F, basis, d, pm), GroupRing)
A = GroupRing(F, basis, pm)
B = GroupRing(F, basis, d, pm)
@test A == B
end
@testset "GroupRingElems constructors/basic manipulation" begin
G = PermutationGroup(3)
RG = GroupRing(G, full=true)
a = rand(6)
@test isa(GroupRingElem(a, RG), GroupRingElem)
@test isa(RG(a), GroupRingElem)
@test_throws String GroupRingElem([1,2,3], RG)
@test isa(RG(G([2,3,1])), GroupRingElem)
p = G([2,3,1])
a = RG(p)
@test length(a) == 6
@test isa(a.coeffs, SparseVector)
@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 == A
@test RG == B
end
@testset "GroupRing constructors FreeGroup" begin
using Groups
F = FreeGroup(3)
S = generators(F)
append!(S, [inv(s) for s in S])
S = unique(S)
basis, sizes = Groups.generate_balls(S, F(), radius=4)
d = GroupRings.reverse_dict(basis)
@test_throws KeyError create_pm(basis)
pm = create_pm(basis, d, sizes[2])
@test isa(GroupRing(F, basis, pm), GroupRing)
@test isa(GroupRing(F, basis, d, pm), GroupRing)
A = GroupRing(F, basis, pm)
B = GroupRing(F, basis, d, pm)
@test A == B
end
@testset "GroupRingElems constructors/basic manipulation" begin
G = PermutationGroup(3)
RG = GroupRing(G, full=true)
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])
a = RG(p)
@test length(a) == 6
@test isa(a.coeffs, SparseVector)
@test a.coeffs[5] == 1
@test a[5] == 1
@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