Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
11a4a83b
Commit
11a4a83b
authored
Feb 27, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HelloFSTest.OpenAndRead
parent
3cc0b9cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
8 deletions
+50
-8
samples/hello_fs_test.go
samples/hello_fs_test.go
+50
-8
No files found.
samples/hello_fs_test.go
View file @
11a4a83b
...
...
@@ -4,6 +4,7 @@
package
samples_test
import
(
"io"
"io/ioutil"
"log"
"os"
...
...
@@ -198,16 +199,57 @@ func (t *HelloFSTest) ReadFile_World() {
ExpectEq
(
"Hello, world!"
,
string
(
slice
))
}
func
(
t
*
HelloFSTest
)
Read_Hello
()
{
AssertTrue
(
false
,
"TODO"
)
}
func
(
t
*
HelloFSTest
)
OpenAndRead
()
{
var
buf
[]
byte
=
make
([]
byte
,
1024
)
var
n
int
var
off
int64
var
err
error
func
(
t
*
HelloFSTest
)
Read_Dir
()
{
AssertTrue
(
false
,
"TODO"
)
}
// Open the file.
f
,
err
:=
os
.
Open
(
path
.
Join
(
t
.
mfs
.
Dir
(),
"hello"
))
defer
func
()
{
if
f
!=
nil
{
ExpectEq
(
nil
,
f
.
Close
())
}
}()
func
(
t
*
HelloFSTest
)
Read_World
()
{
AssertTrue
(
false
,
"TODO"
)
AssertEq
(
nil
,
err
)
// Seeking shouldn't affect the random access reads below.
_
,
err
=
f
.
Seek
(
7
,
0
)
AssertEq
(
nil
,
err
)
// Random access reads
n
,
err
=
f
.
ReadAt
(
buf
[
:
2
],
0
)
AssertEq
(
nil
,
err
)
ExpectEq
(
2
,
n
)
ExpectEq
(
"He"
,
string
(
buf
[
:
n
]))
n
,
err
=
f
.
ReadAt
(
buf
[
:
2
],
int64
(
len
(
"Hel"
)))
AssertEq
(
nil
,
err
)
ExpectEq
(
2
,
n
)
ExpectEq
(
"lo"
,
string
(
buf
[
:
n
]))
n
,
err
=
f
.
ReadAt
(
buf
[
:
3
],
int64
(
len
(
"Hello, wo"
)))
AssertEq
(
nil
,
err
)
ExpectEq
(
3
,
n
)
ExpectEq
(
"rld"
,
string
(
buf
[
:
n
]))
// Read beyond end.
n
,
err
=
f
.
ReadAt
(
buf
[
:
3
],
int64
(
len
(
"Hello, world"
)))
AssertEq
(
io
.
EOF
,
err
)
ExpectEq
(
1
,
n
)
ExpectEq
(
"!"
,
string
(
buf
[
:
n
]))
// Seek then read the rest.
off
,
err
=
f
.
Seek
(
int64
(
len
(
"Hel"
)),
0
)
AssertEq
(
nil
,
err
)
AssertEq
(
len
(
"Hel"
),
off
)
n
,
err
=
io
.
ReadFull
(
f
,
buf
[
:
len
(
"lo, world!"
)])
AssertEq
(
nil
,
err
)
ExpectEq
(
len
(
"lo, world!"
),
n
)
ExpectEq
(
"lo, world!"
,
string
(
buf
[
:
n
]))
}
func
(
t
*
HelloFSTest
)
Open_NonExistent
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment