Skip to content

Commit

Permalink
Re #1790 minor changes to finish hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Dec 22, 2024
1 parent e6d6ccb commit 6a08643
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 76 deletions.
22 changes: 18 additions & 4 deletions _test/common_functions/hashable_obj_tester.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ function hashable_obj_tester(hobj,values,names)
% and hash is stored-restored correctly
%
% Inputs:
% hobj -- instance of hashable object, better with proper values set
% hobj -- instance of hashable object, with proper values set to
% its properties. hobj build with empty constructor may not be
% acceptable.
% Optional
% values-- cellarray of values to set to hashable object. If present, have
% to have number of elements equal to number of hashable
% properties and values of this properties compartible with
% serializeble, i.e. setting property do not contradict to other
% properties, validated through check_combo_arg method
% properties, validated through check_combo_arg method.
% If missing, will use current values of hashable properties.
%
% Majority of hashable objects do not verify if input property
% value have changed from its current value and invalidate hash
% anyway. Small subset of hashable objects do check if properties
% chanded so they need these valus different from the values
% already set in the input hobj.
%
% names -- list of the properties to set to check hashable object.
% If missing, use hashableFields
%
Expand Down Expand Up @@ -42,15 +52,19 @@ function hashable_obj_tester(hobj,values,names)
hobj = hobj.build_hash();
end

% check if hobj converts into serizliable structure
S = hobj.to_struct();
rec_obj= hobj.from_struct(S);
% and can be successfuly restored back from it, keeping hash intact
rec_obj= hashable.from_struct(S);

assertTrue(hobj.hash_defined);
assertTrue(hobj == rec_obj)

obj_arr = [hobj,hobj];
% check if array of hobj converts into serizliable structure
S = obj_arr.to_struct();
rec_arr= hobj.from_struct(S);
% and can be successfuly restored back from it, keeping hash intact
rec_arr= hashable.from_struct(S);

assertTrue(rec_arr.hash_defined);
assertTrue(obj_arr == rec_arr)
28 changes: 0 additions & 28 deletions herbert_core/utilities/classes/@serializable/eq.m

This file was deleted.

44 changes: 0 additions & 44 deletions herbert_core/utilities/classes/@serializable/private/eq_.m

This file was deleted.

0 comments on commit 6a08643

Please sign in to comment.