Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
id-iot
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
Model registry
Operate
Environments
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
Per Lindgren
id-iot
Commits
afd9756f
Commit
afd9756f
authored
8 years ago
by
James Munns
Browse files
Options
Downloads
Patches
Plain Diff
Add test
parent
60ab4856
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/packet.rs
+19
-3
19 additions, 3 deletions
src/packet.rs
with
19 additions
and
3 deletions
src/packet.rs
+
19
−
3
View file @
afd9756f
...
...
@@ -31,7 +31,7 @@ pub struct PacketHeader {
message_id
:
u16
}
#[derive(Debug)]
#[derive(Debug
,
PartialEq
)]
pub
enum
PacketClass
{
Empty
,
Request
(
RequestRegistry
),
...
...
@@ -39,7 +39,7 @@ pub enum PacketClass {
Reserved
}
#[derive(Debug)]
#[derive(Debug
,
PartialEq
)]
pub
enum
RequestRegistry
{
Get
,
Post
,
...
...
@@ -47,7 +47,7 @@ pub enum RequestRegistry {
Delete
}
#[derive(Debug)]
#[derive(Debug
,
PartialEq
)]
pub
enum
ResponseRegistry
{
// 200 Codes
Created
,
...
...
@@ -617,6 +617,22 @@ mod test {
use
super
::
*
;
use
std
::
collections
::
LinkedList
;
#[test]
fn
test_header_codes
()
{
for
code
in
0
..
255
{
let
class
=
code_to_class
(
&
code
);
let
code_str
=
code_to_str
(
&
code
);
let
class_str
=
class_to_str
(
&
class
);
// Reserved class could technically be many codes
// so only check valid items
if
class
!=
PacketClass
::
Reserved
{
assert_eq!
(
class_to_code
(
&
class
),
code
);
assert_eq!
(
code_str
,
class_str
);
}
}
}
#[test]
fn
test_decode_packet_with_options
()
{
let
buf
=
[
0x44
,
0x01
,
0x84
,
0x9e
,
0x51
,
0x55
,
0x77
,
0xe8
,
0xb2
,
0x48
,
0x69
,
0x04
,
0x54
,
0x65
,
0x73
,
0x74
,
0x43
,
0x61
,
0x3d
,
0x31
];
...
...
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