-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathtests.jl
44 lines (36 loc) · 961 Bytes
/
tests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
include("Shor.jl")
using Test
"""Euler theorem states that the order is a devisor of Eulerφ (or the size of Z* group of `N`)"""
function check_Euler_theorem(N::Int)
Z = NumberTheory.Z_star(N)
Nz = length(Z) # Eulerφ
for x in Z
@test powermod(x,Nz,N) == 1 # the order is a devisor of Eulerφ
end
end
@testset "Euler" begin
check_Euler_theorem(150)
end
@testset "shor_classical" begin
Random.seed!(129)
L = 35
f = shor(L, Val(:classical))
@test f == 5 || f == 7
L = 25
f = shor(L, Val(:classical))
@test f == 5
L = 7*11
f = shor(L, Val(:classical))
@test f == 7 || f == 11
L = 14
f = shor(L, Val(:classical))
@test f == 2 || f == 7
@test NumberTheory.factor_a_power_b(25) == (5, 2)
@test NumberTheory.factor_a_power_b(15) == nothing
end
@testset "shor quantum" begin
Random.seed!(129)
L = 15
f = shor(L, Val(:quantum))
@test f == 5 || f == 3
end