Some solutions for the julia path

This commit is contained in:
2025-08-04 19:44:03 +02:00
parent 5c52e8e34d
commit 8296c79f68
104 changed files with 4373 additions and 0 deletions

30
julia/secrets/runtests.jl Normal file
View File

@@ -0,0 +1,30 @@
using Test
include("secrets.jl")
@testset verbose = true "tests" begin
@testset "1. Shift back the bits" begin
@test shift_back(8, 2) == 2
# The original Java code uses a signed integer, so we use Int32 here
# Fails with Int64!
@test shift_back(Int32(-2_144_333_657), 3) == 268_829_204
end
@testset "2. Set bits" begin
@test set_bits(5, 3) == 7
@test set_bits(5_652, 26_150) == 30_262
end
@testset "3. Flip bits" begin
@test flip_bits(5, 11) == 14
@test flip_bits(38_460, 15_471) == 43_603
end
@testset "4. Clear bits" begin
@test clear_bits(5, 11) == 4
@test clear_bits(90, 240) == 10
end
end