Skip to content

Commit

Permalink
Added tests for config parsing (including custom-id handling via kwar…
Browse files Browse the repository at this point in the history
…gs in get_config)
  • Loading branch information
erwanlecarpentier committed Jul 5, 2021
1 parent b0ed6a6 commit 2e58b70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/config.jl
@@ -0,0 +1,26 @@
using Cambrian

@testset "Configuration parsing" begin
cfg_filename = string(@__DIR__, "/../cfg/oneplus.yaml")
cfg = get_config(cfg_filename)

@test cfg.n_population == 5
@test cfg.d_fitness == 1
@test cfg.save_gen == 0
@test cfg.n_genes == 10
@test cfg.n_gen == 10
@test cfg.seed == 0
@test cfg.m_rate == 0.3
@test cfg.n_elite == 1
@test cfg.log_gen == 0
@test haskey(cfg, :id)

default_id = cfg.id
my_custom_id = "custom_id"
my_custom_arg = 0x01
cfg = get_config(cfg_filename, custom_arg=0x01, id=my_custom_id)
@test cfg.id == my_custom_id
@test cfg.id != default_id
@test haskey(cfg, :custom_arg)
@test cfg.custom_arg == my_custom_arg
end
1 change: 1 addition & 0 deletions test/runtests.jl
@@ -1,6 +1,7 @@
using Cambrian
using Test

include("config.jl")
include("individual.jl")
include("evolution.jl")
include("oneplus.jl")
Expand Down

0 comments on commit 2e58b70

Please sign in to comment.