Beispiel #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestEmptyFile()
        {
            Configuration conf = new Configuration();
            FileSystem    fs   = FileSystem.GetLocal(conf);

            WriteTest(fs, new RandomDatum[0], TestFile);
            ArrayFile.Reader reader = new ArrayFile.Reader(fs, TestFile, conf);
            NUnit.Framework.Assert.IsNull(reader.Get(0, new RandomDatum()));
            reader.Close();
        }
Beispiel #2
0
        /// <exception cref="System.IO.IOException"/>
        private static void ReadTest(FileSystem fs, RandomDatum[] data, string file, Configuration
                                     conf)
        {
            RandomDatum v = new RandomDatum();

            if (Log.IsDebugEnabled())
            {
                Log.Debug("reading " + data.Length + " debug");
            }
            ArrayFile.Reader reader = new ArrayFile.Reader(fs, file, conf);
            try
            {
                for (int i = 0; i < data.Length; i++)
                {
                    // try forwards
                    reader.Get(i, v);
                    if (!v.Equals(data[i]))
                    {
                        throw new RuntimeException("wrong value at " + i);
                    }
                }
                for (int i_1 = data.Length - 1; i_1 >= 0; i_1--)
                {
                    // then backwards
                    reader.Get(i_1, v);
                    if (!v.Equals(data[i_1]))
                    {
                        throw new RuntimeException("wrong value at " + i_1);
                    }
                }
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("done reading " + data.Length + " debug");
                }
            }
            finally
            {
                reader.Close();
            }
        }