Esempio n. 1
0
                public void string1d()
                {
                    using (var Container = new TempH5FileContainer())
                    {
                        var hf = Container.Content();

                        var dims = new long[] { 3L };

                        string1d DSET = hf.Root.CreateDataset("tempdata", 1, dims, typeof(string)) as string1d;

                        Assert.NotNull(DSET);
                        Assert.Equal(dims, DSET.Dims);

                        var expect = new string[3] {
                            "foo", "bar", "zoom"
                        };

                        DSET.Values = expect;

                        var actual = DSET.Values;

                        Assert.Equal(expect, actual);

                        Assert.Throws <InvalidOperationException>(() => DSET.Values = new string[1]);
                        Assert.Throws <InvalidOperationException>(() => DSET.Values = new string[9]);

                        DSET.Dispose();
                    }
                }
Esempio n. 2
0
                public void string1d()
                {
                    using (var container = new TempH5FileContainer())
                    {
                        H5Group ROOT = container.Content().Root;

                        int rank = 1;
                        var dims = new long[] { 3 };

                        using (string1d DSET = ROOT.CreateDataset("dataset", rank, dims, typeof(string)) as string1d)
                        {
                            Assert.NotNull(DSET);
                            Assert.Equal(dims, DSET.Dims);

                            DSET[0] = "foo";
                            DSET[1] = "bar";
                            DSET[2] = "yom";

                            Assert.Throws <IndexOutOfRangeException>(() => DSET[3]);
                            Assert.Throws <IndexOutOfRangeException>(() => DSET[3] = "grok");

                            Assert.Throws <IndexOutOfRangeException>(() => DSET[-1]);
                            Assert.Throws <IndexOutOfRangeException>(() => DSET[-1] = "grok");
                        }
                    }
                }
Esempio n. 3
0
            [InlineData("datasets/string1d_32")]        //  32 byte string length
            public void string1d(string key)
            {
                using (H5File hf = H5File.Open(testfile, mode: "r"))
                {
                    string1d DSET = hf.Root[key] as string1d;

                    Assert.NotNull(DSET);
                    Assert.Equal(Edge, DSET.Length);
                    Assert.Equal(typeof(string), DSET.PrimitiveType);

                    string[] expect = { "foo", "bar", "zoom", "grok", "fitz", "roy", "baz" };

                    for (long i = 0; i < DSET.Dims[0]; i++)
                    {
                        Assert.Equal(expect[i], DSET[i]);
                    }
                }
            }
Esempio n. 4
0
            public void string1d()
            {
                using (H5File hf = H5File.Open(testfile, mode: "r"))
                {
                    string1d DSET = hf.Root["datasets/string1d"] as string1d;

                    Assert.NotNull(DSET);

                    string[] expected = new string[] {
                        "foo", "bar", "zoom", "grok", "fitz", "roy", "baz"
                    };
                    int index = 0;

                    foreach (string actual in DSET.Elements())
                    {
                        Assert.Equal(expected[index], actual);
                        index += 1;
                    }
                }
            }