MatrixBerryCore
mlunit_test_diskbasedhashmap_nostorage.m
Go to the documentation of this file.
1 classdef mlunit_test_diskbasedhashmap_nostorage < matlab.unittest.TestCase
2  properties (Access=private)
3  map
4  rel1
5  rel2
6  end
7  %
8  methods
9  function self = mlunit_test_diskbasedhashmap_nostorage(varargin)
10  self = self@matlab.unittest.TestCase(varargin{:});
11  end
12  end
13  methods (TestMethodSetup)
14  function self = setUp(self)
15  import mxberry.core.cont.DiskBasedHashMap;
16  self.map=DiskBasedHashMap('storageBranchKey',...
17  'testBranch','storageFormat','none');
18  %
19  %
20  self.rel1=struct(...
21  'gamma',{{[1 2 3],[1 2 3]}},...
22  'delta',{{[1 2 3], [4 5 6]}},...
23  'epsilon',{{'nu','mu'}},...
24  'zeta',int16([144 1]),...
25  'eta',logical([1 1]),...
26  'theta',{{'nu','nu'}},...
27  'iota',{{'nu','mu'}});
28  %
29  self.rel2=struct(...
30  'gamma',{{[1 2 3],[1 2 44545453]}},...
31  'delta',{{[1 2.676676734 3], [4.23232423423424 5 6]}},...
32  'epsilon',{{'nu','mu'}},...
33  'zeta',int8([431 2121]),...
34  'eta',logical([1 0]),...
35  'theta',{{'nu','nu'}},...
36  'iota',{{'nu','mu'}});
37  self.map.removeAll();
38  end
39  end
40  methods(Test)
41  function self=test_putGet(self)
42  rel1=self.rel1; %#ok<*PROP>
43  rel2=self.rel2;
44  inpObjList={rel1,rel2};
45  keyList={'rel1','rel2'};
46  self.map.put(keyList,inpObjList);
47  isThere=fliplr(self.map.isKey(fliplr(keyList)));
48  isEqual=any(isThere==true);
49  self.verifyEqual(isEqual,false);
50  self.map.removeAll();
51  end
52  function self=test_getKeyList(self)
53  rel1=self.rel1;
54  rel2=self.rel2;
55  inpObjList={rel1,rel2};
56  keyList={'rel1','rel2'};
57  self.map.put(keyList,inpObjList);
58  isEqual=isequal({},self.map.getKeyList);
59  self.verifyEqual(isEqual,true);
60  self.map.remove('rel2');
61  isEqual=isequal({},self.map.getKeyList);
62  self.verifyEqual(isEqual,true);
63  self.map.removeAll();
64  end
65  function self=test_isKeyAndRemove(self)
66  rel1=self.rel1;
67  rel2=self.rel2;
68  rel3=self.rel2;
69  inpObjList={rel1,rel2,rel3};
70  keyList={'rel1','rel2','rel3'};
71  self.map.put(keyList,inpObjList);
72  self.map.remove(keyList{3});
73  self.verifyEqual(self.map.isKey(keyList{3}),false);
74  keyList=keyList(1:2);
75  isThere=fliplr(self.map.isKey(fliplr(keyList)));
76  isEqual=any(isThere==true);
77  self.verifyEqual(isEqual,false);
78  self.map.removeAll();
79  end
80  function self=test_getFileNameByKey(self)
81  rel1=self.rel1;
82  inpObjList={rel1};
83  keyList='rel1';
84  self.map.put(keyList,inpObjList);
85  self.map.getFileNameByKey(keyList);
86  end
87  end
88 end