예제 #1
0
        public void H5Lget_infoTest2()
        {
            Assert.IsTrue(
                H5G.close(H5G.create(m_v0_test_file, "A/B/C/D", m_lcpl)) >= 0);
            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(H5L.get_info(m_v0_test_file, "A/B/C/D", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.HARD);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() == 3896);

            Assert.IsTrue(
                H5G.close(H5G.create(m_v2_test_file, "A/B/C/D", m_lcpl)) >= 0);
            Assert.IsTrue(H5L.get_info(m_v2_test_file, "A/B/C/D", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.HARD);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() == 636);
        }
예제 #2
0
        public void H5Lget_infoTest1()
        {
            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file,
                "A/B/C", m_lcpl) >= 0);

            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(H5L.get_info(m_v0_test_file, "A/B/C", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() > 0);

            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file,
                "A/B/C", m_lcpl) >= 0);

            Assert.IsTrue(H5L.get_info(m_v2_test_file, "A/B/C", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() > 0);
        }
예제 #3
0
        public void H5Lget_info_by_idxTest1()
        {
            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file,
                "A", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file,
                "AB", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file,
                "ABC", m_lcpl) >= 0);

            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(H5L.get_info_by_idx(m_v0_test_file, ".",
                H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() > 0);

            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file,
                "A", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file,
                "AB", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file,
                "ABC", m_lcpl) >= 0);

            Assert.IsTrue(H5L.get_info_by_idx(m_v2_test_file, ".",
                H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Assert.IsTrue(info.u.val_size.ToInt64() > 0);
        }
예제 #4
0
        public void H5Lget_val_by_idxTest1()
        {
            string sym_path = String.Join("/", m_utf8strings);
            byte[] bytes = Encoding.UTF8.GetBytes(sym_path);

            Assert.IsTrue(
                H5L.create_soft(bytes, m_v0_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D"), m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_soft(bytes, m_v0_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D1"), m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_soft(bytes, m_v0_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D2"), m_lcpl) >= 0);
            
            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v0_test_file, "/A/B/C/D2", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.SOFT);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            Int32 size = info.u.val_size.ToInt32();
            Assert.IsTrue(size == 70);

            // the library appends a null terminator
            Assert.IsTrue(size == bytes.Length + 1);

            byte[] buf = new byte[size-1];

            GCHandle hnd = GCHandle.Alloc(buf, GCHandleType.Pinned);

            Assert.IsTrue(H5L.get_val_by_idx(m_v0_test_file, "/A/B/C",
                H5.index_t.NAME, H5.iter_order_t.NATIVE, 2,
                hnd.AddrOfPinnedObject(), new IntPtr(buf.Length)) >= 0);
            
            hnd.Free();

            for (int i = 0; i < buf.Length - 1; ++i)
            {
                Assert.IsTrue(buf[i] == bytes[i]);
            }

            Assert.IsTrue(
                H5L.create_soft(bytes, m_v2_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D"), m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_soft(bytes, m_v2_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D1"), m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_soft(bytes, m_v2_test_file,
                Encoding.ASCII.GetBytes("/A/B/C/D2"), m_lcpl) >= 0);

            info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v0_test_file, "/A/B/C/D2", ref info) >= 0);
            Assert.IsTrue(info.type == H5L.type_t.SOFT);
            Assert.IsTrue(info.corder_valid == 0);
            Assert.IsTrue(info.cset == H5T.cset_t.ASCII);
            size = info.u.val_size.ToInt32();
            Assert.IsTrue(size == 70);

            // the library appends a null terminator
            Assert.IsTrue(size == bytes.Length + 1);

            buf = new byte[size - 1];

            hnd = GCHandle.Alloc(buf, GCHandleType.Pinned);

            Assert.IsTrue(H5L.get_val_by_idx(m_v2_test_file, "/A/B/C",
                H5.index_t.NAME, H5.iter_order_t.NATIVE, 2,
                hnd.AddrOfPinnedObject(), new IntPtr(buf.Length)) >= 0);

            hnd.Free();

            for (int i = 0; i < buf.Length - 1; ++i)
            {
                Assert.IsTrue(buf[i] == bytes[i]);
            }
        }
예제 #5
0
        public void H5Lunpack_elink_valTest1()
        {
            // v0 file format

            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file,
                "A/B/C", m_lcpl) >= 0);

            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v0_test_file, "A/B/C", ref info) >= 0);

            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            IntPtr size = new IntPtr(info.u.val_size.ToInt32());
            Assert.IsTrue(size.ToInt32() > 0);

            IntPtr buf = Marshal.AllocHGlobal(size.ToInt32());
            Assert.IsTrue(buf != IntPtr.Zero);
            Assert.IsTrue(
                H5L.get_val(m_v0_test_file, "A/B/C", buf, size) >= 0);

            uint flags = 0;
            IntPtr filename = new IntPtr();
            IntPtr obj_path = new IntPtr();
            Assert.IsTrue(
                H5L.unpack_elink_val(buf, size, ref flags, ref filename,
                ref obj_path) >= 0);

            Assert.IsTrue(
                Marshal.PtrToStringAnsi(filename) == m_v0_class_file_name);
            Assert.IsTrue(Marshal.PtrToStringAnsi(obj_path) == "/");

            Marshal.FreeHGlobal(buf);

            // v2 file format

            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file,
                "A/B/C", m_lcpl) >= 0);

            info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v2_test_file, "A/B/C", ref info) >= 0);

            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            size = new IntPtr(info.u.val_size.ToInt32());
            Assert.IsTrue(size.ToInt32() > 0);

            buf = Marshal.AllocHGlobal(size.ToInt32());
            Assert.IsTrue(buf != IntPtr.Zero);
            Assert.IsTrue(
                H5L.get_val(m_v2_test_file, "A/B/C", buf, size) >= 0);

            flags = 0;
            filename = new IntPtr();
            obj_path = new IntPtr();
            Assert.IsTrue(
                H5L.unpack_elink_val(buf, size, ref flags, ref filename,
                ref obj_path) >= 0);

            Assert.IsTrue(
                Marshal.PtrToStringAnsi(filename) == m_v2_class_file_name);
            Assert.IsTrue(Marshal.PtrToStringAnsi(obj_path) == "/");

            Marshal.FreeHGlobal(buf);
        }
예제 #6
0
        public void H5Lunpack_elink_valTest3()
        {
            // v0 file format

            byte[] bytes = Encoding.UTF8.GetBytes(m_utf8strings[0]);

            Assert.IsTrue(
                H5G.close(H5G.create(m_v0_class_file, bytes, m_lcpl_utf8)) >= 0);

            Assert.IsTrue(
                H5L.create_external(m_v0_class_file_name,
                bytes, m_v0_test_file, bytes, m_lcpl_utf8) >= 0);

            H5L.info_t info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v0_test_file, bytes, ref info) >= 0);

            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            IntPtr size = new IntPtr(info.u.val_size.ToInt32());
            Assert.IsTrue(size.ToInt32() > 0);

            IntPtr buf = Marshal.AllocHGlobal(size.ToInt32());
            Assert.IsTrue(buf != IntPtr.Zero);
            Assert.IsTrue(
                H5L.get_val(m_v0_test_file, bytes, buf, size) >= 0);

            uint flags = 0;
            IntPtr filename = new IntPtr();
            IntPtr obj_path = new IntPtr();
            Assert.IsTrue(
                H5L.unpack_elink_val(buf, size, ref flags, ref filename,
                ref obj_path) >= 0);

            Assert.IsTrue(
                Marshal.PtrToStringAnsi(filename) == m_v0_class_file_name);

            // the elink value is packed like this:
            // <file name>\0<object path>\0
            // the whole thing is of info.u.val_size 

            int count = size.ToInt32() - 
                (int)(obj_path.ToInt64() + 1 - filename.ToInt64()) - 1;
            byte[] obj_path_buf = new byte [count];
            Marshal.Copy(obj_path, obj_path_buf, 0, count);

            Assert.IsTrue(
                Encoding.UTF8.GetString(obj_path_buf) == m_utf8strings[0],
                String.Format("{0}", Encoding.UTF8.GetString(obj_path_buf)));

            Marshal.FreeHGlobal(buf);

            // v2 file format

            Assert.IsTrue(
                H5G.close(H5G.create(m_v2_class_file, bytes, m_lcpl_utf8)) >= 0);

            Assert.IsTrue(
                H5L.create_external(m_v2_class_file_name,
                bytes, m_v2_test_file, bytes, m_lcpl_utf8) >= 0);

           info = new H5L.info_t();
            Assert.IsTrue(
                H5L.get_info(m_v2_test_file, bytes, ref info) >= 0);

            Assert.IsTrue(info.type == H5L.type_t.EXTERNAL);
            size = new IntPtr(info.u.val_size.ToInt32());
            Assert.IsTrue(size.ToInt32() > 0);

            buf = Marshal.AllocHGlobal(size.ToInt32());
            Assert.IsTrue(buf != IntPtr.Zero);
            Assert.IsTrue(
                H5L.get_val(m_v2_test_file, bytes, buf, size) >= 0);

            flags = 0;
            filename = new IntPtr();
            obj_path = new IntPtr();
            Assert.IsTrue(
                H5L.unpack_elink_val(buf, size, ref flags, ref filename,
                ref obj_path) >= 0);

            Assert.IsTrue(
                Marshal.PtrToStringAnsi(filename) == m_v2_class_file_name);

            // the elink value is packed like this:
            // <file name>\0<object path>\0
            // the whole thing is of info.u.val_size 

            count = size.ToInt32() -
                (int)(obj_path.ToInt64() + 1 - filename.ToInt64()) - 1;
            obj_path_buf = new byte[count];
            Marshal.Copy(obj_path, obj_path_buf, 0, count);

            Assert.IsTrue(
                Encoding.UTF8.GetString(obj_path_buf) == m_utf8strings[0],
                String.Format("{0}", Encoding.UTF8.GetString(obj_path_buf)));

            Marshal.FreeHGlobal(buf);
        }