Mercurial > repos > public > sbplib_julia
diff test/test_utils.jl @ 703:988e9cfcd58d feature/laplace_opset
Add function for == comparison of the fields for a struct, and apply to Laplace tests
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 15 Feb 2021 17:20:03 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test_utils.jl Mon Feb 15 17:20:03 2021 +0100 @@ -0,0 +1,9 @@ +""" + cmp_fields(s1,s2) + +Compares the fields of two structs s1, s2, using the == operator. +""" +function cmp_fields(s1::T,s2::T) where T + f = fieldnames(T) + return getfield.(Ref(s1),f) == getfield.(Ref(s2),f) +end