Skip to content

Commit 14dc112

Browse files
author
Nithin Lakshmisha
committed
test: Add test for loading and saving classdef object inside struct (bug #45833).
* test/classdef-load-save/classdef-load-save.tst: Add self-test that checks whether saved objects inside structures are loaded correctly.
1 parent f85c66b commit 14dc112

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/classdef-load-save/classdef-load-save.tst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@
7575
%! delete (savefile);
7676
%! end_unwind_protect
7777

78+
## No constructor, ConstructOnLoad = false, no loadobj/saveobj, nested object inside a struct
79+
%!test
80+
%! obj = regular_class ();
81+
%! s.obj_field = regular_class_with_constructor ();
82+
%! obj.a = s;
83+
%! savefile = tempname ();
84+
%! save ('-text', savefile, 'obj');
85+
%! unwind_protect
86+
%! clear obj;
87+
%! load (savefile);
88+
%! assert (class(obj.a.obj_field), "regular_class_with_constructor");
89+
%! unwind_protect_cleanup
90+
%! delete (savefile);
91+
%! end_unwind_protect
92+
7893
## Vector of value class objects.
7994
%!test
8095
%! obj = regular_class;

0 commit comments

Comments
 (0)