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
6e5247d1
Commit
6e5247d1
authored
Dec 19, 2016
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer_test: make use of the new API.
parent
0f6db15c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
internal/buffer/out_message_test.go
internal/buffer/out_message_test.go
+13
-13
No files found.
internal/buffer/out_message_test.go
View file @
6e5247d1
...
@@ -101,7 +101,7 @@ func TestOutMessageAppend(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestOutMessageAppend(t *testing.T) {
om
.
Append
(
wantPayload
[
4
:
])
om
.
Append
(
wantPayload
[
4
:
])
// The result should be a zeroed header followed by the desired payload.
// The result should be a zeroed header followed by the desired payload.
const
wantLen
=
int
(
OutMessageInitialSize
)
+
len
(
wantPayloadStr
)
const
wantLen
=
OutMessageHeaderSize
+
len
(
wantPayloadStr
)
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
...
@@ -113,7 +113,7 @@ func TestOutMessageAppend(t *testing.T) {
...
@@ -113,7 +113,7 @@ func TestOutMessageAppend(t *testing.T) {
}
}
want
:=
append
(
want
:=
append
(
make
([]
byte
,
OutMessage
Initial
Size
),
make
([]
byte
,
OutMessage
Header
Size
),
wantPayload
...
)
wantPayload
...
)
if
!
bytes
.
Equal
(
b
,
want
)
{
if
!
bytes
.
Equal
(
b
,
want
)
{
...
@@ -131,7 +131,7 @@ func TestOutMessageAppendString(t *testing.T) {
...
@@ -131,7 +131,7 @@ func TestOutMessageAppendString(t *testing.T) {
om
.
AppendString
(
wantPayload
[
4
:
])
om
.
AppendString
(
wantPayload
[
4
:
])
// The result should be a zeroed header followed by the desired payload.
// The result should be a zeroed header followed by the desired payload.
const
wantLen
=
int
(
OutMessageInitialSize
)
+
len
(
wantPayload
)
const
wantLen
=
OutMessageHeaderSize
+
len
(
wantPayload
)
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
...
@@ -143,7 +143,7 @@ func TestOutMessageAppendString(t *testing.T) {
...
@@ -143,7 +143,7 @@ func TestOutMessageAppendString(t *testing.T) {
}
}
want
:=
append
(
want
:=
append
(
make
([]
byte
,
OutMessage
Initial
Size
),
make
([]
byte
,
OutMessage
Header
Size
),
wantPayload
...
)
wantPayload
...
)
if
!
bytes
.
Equal
(
b
,
want
)
{
if
!
bytes
.
Equal
(
b
,
want
)
{
...
@@ -159,10 +159,10 @@ func TestOutMessageShrinkTo(t *testing.T) {
...
@@ -159,10 +159,10 @@ func TestOutMessageShrinkTo(t *testing.T) {
om
.
AppendString
(
"burrito"
)
om
.
AppendString
(
"burrito"
)
// Shrink it.
// Shrink it.
om
.
ShrinkTo
(
OutMessage
InitialSize
+
uintptr
(
len
(
"taco"
)
))
om
.
ShrinkTo
(
OutMessage
HeaderSize
+
len
(
"taco"
))
// The result should be a zeroed header followed by "taco".
// The result should be a zeroed header followed by "taco".
const
wantLen
=
int
(
OutMessageInitialSize
)
+
len
(
"taco"
)
const
wantLen
=
OutMessageHeaderSize
+
len
(
"taco"
)
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
,
want
)
...
@@ -174,7 +174,7 @@ func TestOutMessageShrinkTo(t *testing.T) {
...
@@ -174,7 +174,7 @@ func TestOutMessageShrinkTo(t *testing.T) {
}
}
want
:=
append
(
want
:=
append
(
make
([]
byte
,
OutMessage
Initial
Size
),
make
([]
byte
,
OutMessage
Header
Size
),
"taco"
...
)
"taco"
...
)
if
!
bytes
.
Equal
(
b
,
want
)
{
if
!
bytes
.
Equal
(
b
,
want
)
{
...
@@ -233,7 +233,7 @@ func TestOutMessageReset(t *testing.T) {
...
@@ -233,7 +233,7 @@ func TestOutMessageReset(t *testing.T) {
om
.
Reset
()
om
.
Reset
()
// Check that the length was updated.
// Check that the length was updated.
if
got
,
want
:=
int
(
om
.
Len
()),
int
(
OutMessageInitialSize
)
;
got
!=
want
{
if
got
,
want
:=
om
.
Len
(),
OutMessageHeaderSize
;
got
!=
want
{
t
.
Fatalf
(
"om.Len() = %d, want %d"
,
got
,
want
)
t
.
Fatalf
(
"om.Len() = %d, want %d"
,
got
,
want
)
}
}
...
@@ -269,7 +269,7 @@ func TestOutMessageGrow(t *testing.T) {
...
@@ -269,7 +269,7 @@ func TestOutMessageGrow(t *testing.T) {
t
.
Fatalf
(
"fillWithGarbage: %v"
,
err
)
t
.
Fatalf
(
"fillWithGarbage: %v"
,
err
)
}
}
om
.
ShrinkTo
(
OutMessage
Initial
Size
)
om
.
ShrinkTo
(
OutMessage
Header
Size
)
}
}
// Call Grow.
// Call Grow.
...
@@ -278,7 +278,7 @@ func TestOutMessageGrow(t *testing.T) {
...
@@ -278,7 +278,7 @@ func TestOutMessageGrow(t *testing.T) {
}
}
// Check the resulting length in two ways.
// Check the resulting length in two ways.
const
wantLen
=
int
(
payloadSize
+
OutMessageInitialSize
)
const
wantLen
=
payloadSize
+
OutMessageHeaderSize
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
if
got
,
want
:=
om
.
Len
(),
wantLen
;
got
!=
want
{
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
)
t
.
Errorf
(
"om.Len() = %d, want %d"
,
got
)
}
}
...
@@ -289,7 +289,7 @@ func TestOutMessageGrow(t *testing.T) {
...
@@ -289,7 +289,7 @@ func TestOutMessageGrow(t *testing.T) {
}
}
// Check that the payload was zeroed.
// Check that the payload was zeroed.
for
i
,
x
:=
range
b
[
OutMessage
Initial
Size
:
]
{
for
i
,
x
:=
range
b
[
OutMessage
Header
Size
:
]
{
if
x
!=
0
{
if
x
!=
0
{
t
.
Fatalf
(
"non-zero byte 0x%02x at payload offset %d"
,
x
,
i
)
t
.
Fatalf
(
"non-zero byte 0x%02x at payload offset %d"
,
x
,
i
)
}
}
...
@@ -331,7 +331,7 @@ func BenchmarkOutMessageGrowShrink(b *testing.B) {
...
@@ -331,7 +331,7 @@ func BenchmarkOutMessageGrowShrink(b *testing.B) {
var
om
OutMessage
var
om
OutMessage
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
om
.
Grow
(
MaxReadSize
)
om
.
Grow
(
MaxReadSize
)
om
.
ShrinkTo
(
OutMessage
Initial
Size
)
om
.
ShrinkTo
(
OutMessage
Header
Size
)
}
}
b
.
SetBytes
(
int64
(
MaxReadSize
))
b
.
SetBytes
(
int64
(
MaxReadSize
))
...
@@ -349,7 +349,7 @@ func BenchmarkOutMessageGrowShrink(b *testing.B) {
...
@@ -349,7 +349,7 @@ func BenchmarkOutMessageGrowShrink(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
oms
[
i
%
numMessages
]
.
Grow
(
MaxReadSize
)
oms
[
i
%
numMessages
]
.
Grow
(
MaxReadSize
)
oms
[
i
%
numMessages
]
.
ShrinkTo
(
OutMessage
Initial
Size
)
oms
[
i
%
numMessages
]
.
ShrinkTo
(
OutMessage
Header
Size
)
}
}
b
.
SetBytes
(
int64
(
MaxReadSize
))
b
.
SetBytes
(
int64
(
MaxReadSize
))
...
...
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