on bc8da8d help sign in
Idris-dev/test/buffer001/buffer001.idr
33 lines 970 B history raw
1import Data.Buffer
3main : IO ()
4main = do Just buf <- newBuffer 40
5 printLn (size buf)
6 setByte buf 5 42
7 setString buf 20 "Hello world!"
8 printLn !(bufferData buf)
9 Just buf2 <- resizeBuffer buf 50
10 putStrLn "Resized"
11 printLn !(bufferData buf2)
13 putStrLn "Writing to file"
14 Right h <- openFile "test.buf" WriteTruncate
15 writeBufferToFile h buf (size buf)
16 closeFile h
18 putStrLn "Reading from file twice"
19 Just buf3 <- newBuffer 80
21 Right h <- openFile "test.buf" Read
22 buf3 <- readBufferFromFile h buf3 (size buf3)
23 closeFile h
24 Right h <- openFile "test.buf" Read
25 readBufferFromFile h buf3 (size buf3)
26 closeFile h
28 printLn !(bufferData buf3)
30 -- Small buffer, tests issue #3828
31 Just small <- newBuffer 3
32 setByte small 0 0
33 setByte small 2 1