-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathhdf5_test.cc
More file actions
61 lines (46 loc) · 1.09 KB
/
hdf5_test.cc
File metadata and controls
61 lines (46 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "test.h"
#include "itensor/all.h"
using namespace std;
using namespace itensor;
TEST_CASE("HDF5Test")
{
SECTION("TagSet")
{
auto to = TagSet("Red,Blue,n=3");
auto fo = h5_open("test.h5",'w');
h5_write(fo,"tagset",to);
close(fo);
auto fi = h5_open("test.h5",'r');
auto ti = h5_read<TagSet>(fi,"tagset");
close(fi);
CHECK(ti == to);
}
SECTION("Index")
{
auto io = Index(3,"Link,n=1");
auto fo = h5_open("test.h5",'w');
h5_write(fo,"index",io);
close(fo);
auto fi = h5_open("test.h5",'r');
auto ii = h5_read<Index>(fi,"index");
close(fi);
CHECK(ii == io);
}
SECTION("IndexSet")
{
auto i1 = Index(1,"Link,n=1");
auto i2 = Index(2,"n=2,Blue");
auto i3 = Index(3,"n=2,Red");
auto iso = IndexSet(i2,i1,i3);
auto fo = h5_open("test.h5",'w');
h5_write(fo,"indexset",iso);
close(fo);
auto fi = h5_open("test.h5",'r');
auto isi = h5_read<IndexSet>(fi,"indexset");
close(fi);
for(auto n : range1(iso.length()))
{
CHECK(isi(n) == iso(n));
}
}
}