Skip to content

Commit 1ddeeec

Browse files
committed
tidier
1 parent 3babb3c commit 1ddeeec

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/core_dispatch.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ function test(u0, dual, chunk_size)
1616
result_dual2
1717
end
1818

19+
function structequal(struct1, struct2)
20+
if typeof(struct1) == typeof(struct2)
21+
fn = fieldnames(typeof(struct1))
22+
all(getfield(a, fn[i]) == getfield(b, fn[i]) for i in eachindex(fn))
23+
else
24+
return false
25+
end
26+
end
27+
1928
#Setup Base Array tests
2029
chunk_size = 5
2130
u0 = ones(5, 5)
@@ -144,6 +153,5 @@ tmp_dual_du_APN = get_tmp(cache_AP, dual_AP[1])
144153
a = PreallocationTools.DiffCache(zeros(4), 4)
145154
b = PreallocationTools.DiffCache(zeros(4), Val{4}())
146155
c = PreallocationTools.DiffCache(zeros(4), Val{4})
147-
fn = fieldnames(PreallocationTools.DiffCache)
148-
@test all(getfield(a, fn[i]) == getfield(b, fn[i]) for i in eachindex(fn))
149-
@test all(getfield(a, fn[i]) == getfield(c, fn[i]) for i in eachindex(fn))
156+
@test structequal(a, b)
157+
@test structequal(a, b)

0 commit comments

Comments
 (0)