public void WriteAndReadDoublesViaMemoryFile() { var file = new MemoryFile("rwb"); Assert.NotNull(file); Assert.True(file.CanWrite); var data0 = new double[4]; for (var i = 0; i < data0.Length; ++i) { data0[i] = (double)i; } file.WriteDoubles(data0); Assert.Equal(data0.Length * sizeof(double), file.Position); file.Seek(0); var data1 = new double[data0.Length]; var rd = file.ReadDoubles(data1, data0.Length); Assert.Equal(rd, data0.Length); Assert.Equal(data0.Length * sizeof(double), file.Position); for (var i = 0; i < rd; ++i) { Assert.Equal(data0[i], data1[i]); } file.Close(); Assert.False(file.IsOpen); }
public void WriteAndReadStorageDoublesViaMemoryFile() { const int size = 10; var file = new MemoryFile("rwb"); Assert.NotNull(file); Assert.True(file.CanWrite); var storage0 = new DoubleTensor.DoubleStorage(size); for (var i = 0; i < size; ++i) { storage0[i] = (double)i; } file.WriteDoubles(storage0); Assert.Equal(size * sizeof(double), file.Position); file.Seek(0); var storage1 = new DoubleTensor.DoubleStorage(size); var rd = file.ReadDoubles(storage1); Assert.Equal(rd, size); Assert.Equal(size * sizeof(double), file.Position); for (var i = 0; i < rd; ++i) { Assert.Equal(storage0[i], storage1[i]); } file.Close(); Assert.False(file.IsOpen); }
public void WriteAndReadDoubleTensorViaMemoryFile() { const int size = 10; var file = new MemoryFile("rwb"); Assert.NotNull(file); Assert.True(file.CanWrite); var tensor0 = new DoubleTensor(size); for (var i = 0; i < size; ++i) { tensor0[i] = (double)i; } file.WriteTensor(tensor0); Assert.Equal(size * sizeof(double), file.Position); file.Seek(0); var tensor1 = new DoubleTensor(size); var rd = file.ReadTensor(tensor1); Assert.Equal(rd, size); Assert.Equal(size * sizeof(double), file.Position); for (var i = 0; i < rd; ++i) { Assert.Equal(tensor1[i], tensor1[i]); } file.Close(); Assert.False(file.IsOpen); }
public void WriteShortToMemoryFile() { var file = new MemoryFile("wb"); Assert.NotNull(file); Assert.True(file.CanWrite); file.Close(); Assert.False(file.IsOpen); }
public void CreateReadWritableMemoryFile() { var file = new MemoryFile("rw"); Assert.NotNull(file); Assert.True(file.CanRead); Assert.True(file.CanWrite); file.Close(); Assert.False(file.IsOpen); }
public void SeekToEndInMemoryFile() { var storage = new MemoryFile.CharStorage(256); Assert.NotNull(storage); storage.Fill(0); var file = new MemoryFile(storage, "w"); Assert.NotNull(file); Assert.False(file.CanRead); Assert.True(file.CanWrite); file.SeekEnd(); Assert.Equal(255, file.Position); file.Close(); Assert.False(file.IsOpen); }
public void WriteAndReadDoubleViaMemoryFile() { var file = new MemoryFile("rwb"); Assert.NotNull(file); Assert.True(file.CanWrite); file.WriteDouble(13); file.WriteDouble(17); file.Seek(0); var rd = file.ReadDouble(); Assert.Equal(13, rd); rd = file.ReadDouble(); Assert.Equal(17, rd); file.Close(); Assert.False(file.IsOpen); }
public void CreateWritableMemoryFile() { var file = new MemoryFile("w"); Assert.NotNull(file); Assert.False(file.CanRead); Assert.True(file.CanWrite); Assert.False(file.IsBinary); Assert.True(file.IsAscii); file.Close(); Assert.False(file.IsOpen); file = new MemoryFile("wb"); Assert.NotNull(file); Assert.False(file.CanRead); Assert.True(file.CanWrite); Assert.True(file.IsBinary); Assert.False(file.IsAscii); file.Close(); Assert.False(file.IsOpen); }