Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
2e04216e
Commit
2e04216e
authored
7 years ago
by
Vladislav Shpilevoy
Browse files
Options
Downloads
Patches
Plain Diff
xrow: implement xrow lib unit tests
Closes #2507
parent
fafdb65c
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/unit/xrow.cc
+45
-1
45 additions, 1 deletion
test/unit/xrow.cc
test/unit/xrow.result
+12
-1
12 additions, 1 deletion
test/unit/xrow.result
with
57 additions
and
2 deletions
test/unit/xrow.cc
+
45
−
1
View file @
2e04216e
...
...
@@ -37,6 +37,8 @@ extern "C" {
#include
"tt_uuid.h"
#include
"version.h"
#include
"random.h"
#include
"memory.h"
#include
"fiber.h"
int
test_iproto_constants
()
...
...
@@ -198,17 +200,59 @@ test_greeting()
return
check_plan
();
}
void
test_xrow_header_encode_decode
()
{
plan
(
9
);
struct
xrow_header
header
;
char
buffer
[
2048
];
char
*
pos
=
mp_encode_uint
(
buffer
,
300
);
is
(
xrow_header_decode
(
&
header
,
(
const
char
**
)
&
pos
,
buffer
+
100
),
-
1
,
"bad msgpack end"
);
header
.
type
=
100
;
header
.
replica_id
=
200
;
header
.
lsn
=
400
;
header
.
tm
=
123.456
;
header
.
bodycnt
=
0
;
struct
iovec
vec
;
is
(
1
,
xrow_header_encode
(
&
header
,
&
vec
,
200
),
"encode"
);
int
fixheader_len
=
200
;
pos
=
(
char
*
)
vec
.
iov_base
+
fixheader_len
;
is
(
mp_decode_map
((
const
char
**
)
&
pos
),
4
,
"header map size"
);
struct
xrow_header
decoded_header
;
const
char
*
begin
=
(
const
char
*
)
vec
.
iov_base
;
begin
+=
fixheader_len
;
const
char
*
end
=
(
const
char
*
)
vec
.
iov_base
;
end
+=
vec
.
iov_len
;
is
(
xrow_header_decode
(
&
decoded_header
,
&
begin
,
end
),
0
,
"header decode"
);
is
(
header
.
type
,
decoded_header
.
type
,
"decoded type"
);
is
(
header
.
replica_id
,
decoded_header
.
replica_id
,
"decoded replica_id"
);
is
(
header
.
lsn
,
decoded_header
.
lsn
,
"decoded lsn"
);
is
(
header
.
tm
,
decoded_header
.
tm
,
"decoded tm"
);
is
(
decoded_header
.
bodycnt
,
0
,
"decoded bodycnt"
);
check_plan
();
}
int
main
(
void
)
{
plan
(
1
);
memory_init
();
fiber_init
(
fiber_c_invoke
);
plan
(
2
);
random_init
();
test_iproto_constants
();
test_greeting
();
test_xrow_header_encode_decode
();
random_free
();
fiber_free
();
memory_free
();
return
check_plan
();
}
This diff is collapsed.
Click to expand it.
test/unit/xrow.result
+
12
−
1
View file @
2e04216e
1..
1
1..
2
1..40
ok 1 - round trip
ok 2 - roundtrip.version_id
...
...
@@ -41,3 +41,14 @@
ok 39 - invalid 10
ok 40 - invalid 11
ok 1 - subtests
1..9
ok 1 - bad msgpack end
ok 2 - encode
ok 3 - header map size
ok 4 - header decode
ok 5 - decoded type
ok 6 - decoded replica_id
ok 7 - decoded lsn
ok 8 - decoded tm
ok 9 - decoded bodycnt
ok 2 - subtests
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment