Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AX.25
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
We are moving to Forgejo!
You are on a read-only GitLab instance.
Show more breadcrumbs
Digipex
AX.25
Commits
afa1c6b1
Verified
Commit
afa1c6b1
authored
2 years ago
by
Jeffrey Phillips Freeman
Browse files
Options
Downloads
Patches
Plain Diff
Forgot to refactor all caps ENTITY and CALLSIGN
parent
bfd6263a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/ax25/frame/entity_spec.rb
+72
-72
72 additions, 72 deletions
spec/ax25/frame/entity_spec.rb
spec/ax25/frame/hop_spec.rb
+43
-43
43 additions, 43 deletions
spec/ax25/frame/hop_spec.rb
with
115 additions
and
115 deletions
spec/ax25/frame/entity_spec.rb
+
72
−
72
View file @
afa1c6b1
require_relative
'../../../lib/ax25'
BASE_
ENTITY
=
"WI2ARD-10"
.
freeze
BASE_
ENTITY_CALLSIGN
=
"WI2ARD"
.
freeze
BASE_
ENTITY
_SSID
=
10
BASE_
ADDRESS
=
"WI2ARD-10"
.
freeze
BASE_
ADDRESS_ENTITY
=
"WI2ARD"
.
freeze
BASE_
ADDRESS
_SSID
=
10
NOSSID_
ENTITY
=
"WI2ARD"
.
freeze
NOSSID_
ENTITY_CALLSIGN
=
"WI2ARD"
.
freeze
NOSSID_
ENTITY
_SSID
=
nil
NOSSID_
ADDRESS
=
"WI2ARD"
.
freeze
NOSSID_
ADDRESS_ENTITY
=
"WI2ARD"
.
freeze
NOSSID_
ADDRESS
_SSID
=
nil
ZEROSSID_
ENTITY
=
"WI2ARD-0"
.
freeze
ZEROSSID_
ENTITY_CALLSIGN
=
"WI2ARD"
.
freeze
ZEROSSID_
ENTITY
_SSID
=
0
ZEROSSID_
ADDRESS
=
"WI2ARD-0"
.
freeze
ZEROSSID_
ADDRESS_ENTITY
=
"WI2ARD"
.
freeze
ZEROSSID_
ADDRESS
_SSID
=
0
BAD_
CALLSIGN_ENTITY
=
"WI2&ARD-10"
.
freeze
BAD_
CALLSIGN_ENTITY_CALLSIGN
=
"WI2&ARD"
.
freeze
BAD_
CALLSIGN_ENTITY
_SSID
=
10
BAD_
ENTITY_ADDRESS
=
"WI2&ARD-10"
.
freeze
BAD_
ENTITY_ADDRESS_ENTITY
=
"WI2&ARD"
.
freeze
BAD_
ENTITY_ADDRESS
_SSID
=
10
BAD_HYPHEN_
ENTITY
=
"WI2ARD-1-1"
.
freeze
BAD_HYPHEN_
ADDRESS
=
"WI2ARD-1-1"
.
freeze
BAD_HYPHEN_NOSSID_
ENTITY
=
"WI2ARD-"
.
freeze
BAD_HYPHEN_NOSSID_
ADDRESS
=
"WI2ARD-"
.
freeze
BAD_LOWSSID_
ENTITY_CALLSIGN
=
"WI2ARD"
.
freeze
BAD_LOWSSID_
ENTITY
_SSID
=
-
1
BAD_LOWSSID_
ADDRESS_ENTITY
=
"WI2ARD"
.
freeze
BAD_LOWSSID_
ADDRESS
_SSID
=
-
1
BAD_HIGHSSID_
ENTITY
=
"WI2ARD-16"
.
freeze
BAD_HIGHSSID_
ENTITY_CALLSIGN
=
"WI2ARD"
.
freeze
BAD_HIGHSSID_
ENTITY
_SSID
=
16
BAD_HIGHSSID_
ADDRESS
=
"WI2ARD-16"
.
freeze
BAD_HIGHSSID_
ADDRESS_ENTITY
=
"WI2ARD"
.
freeze
BAD_HIGHSSID_
ADDRESS
_SSID
=
16
class
AddressEquiv
public
...
...
@@ -42,42 +42,42 @@ end
describe
Ax25
::
Address
do
describe
".new"
do
context
"Given a valid entity with ssid"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
BASE_ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
BASE_ADDRESS
_SSID
)
it
"returns a Address object with correct properties"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"set the entity property correctly"
do
expect
(
address
.
entity
).
to
eql
(
BASE_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
BASE_
ADDRESS_ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
address
.
ssid
).
to
eql
(
BASE_
ENTITY
_SSID
)
expect
(
address
.
ssid
).
to
eql
(
BASE_
ADDRESS
_SSID
)
end
it
"entity is frozen"
do
expect
(
address
.
entity
).
to
be_frozen
end
end
context
"Given a valid entity with nil ssid"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
NOSSID_
ENTITY_CALLSIGN
,
NOSSID_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
NOSSID_
ADDRESS_ENTITY
,
NOSSID_
ADDRESS
_SSID
)
it
"returns a Address object with correct properties"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"set the entity property correctly"
do
expect
(
address
.
entity
).
to
eql
(
NOSSID_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
NOSSID_
ADDRESS_ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
address
.
ssid
).
to
eql
(
NOSSID_
ENTITY
_SSID
)
expect
(
address
.
ssid
).
to
eql
(
NOSSID_
ADDRESS
_SSID
)
end
end
context
"Given a valid entity with zero for ssid"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
ZEROSSID_
ENTITY_CALLSIGN
,
ZEROSSID_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
ZEROSSID_
ADDRESS_ENTITY
,
ZEROSSID_
ADDRESS
_SSID
)
it
"returns a Address object with correct properties"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"set the entity property correctly"
do
expect
(
address
.
entity
).
to
eql
(
ZEROSSID_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
ZEROSSID_
ADDRESS_ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
address
.
ssid
).
to
be_nil
...
...
@@ -86,49 +86,49 @@ describe Ax25::Address do
context
"Given an invalid entity with valid ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_
CALLSIGN_ENTITY_CALLSIGN
,
BAD_CALLSIGN_ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_
ENTITY_ADDRESS_ENTITY
,
BAD_ENTITY_ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a nil entity with valid ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
nil
,
BASE_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
nil
,
BASE_
ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a non-string entity with valid ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
5
,
BASE_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
5
,
BASE_
ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a empty string entity with valid ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
""
,
BASE_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
""
,
BASE_
ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with non-integer ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
"invalid"
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
"invalid"
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with ssid below 0"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_LOWSSID_
ENTITY_CALLSIGN
,
BAD_LOWSSID_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_LOWSSID_
ADDRESS_ENTITY
,
BAD_LOWSSID_
ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with ssid above 15"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_HIGHSSID_
ENTITY_CALLSIGN
,
BAD_HIGHSSID_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BAD_HIGHSSID_
ADDRESS_ENTITY
,
BAD_HIGHSSID_
ADDRESS
_SSID
)
}.
to
raise_error
(
ArgumentError
)
end
end
...
...
@@ -147,88 +147,88 @@ describe Ax25::Address do
end
describe
".from_raw"
do
context
"Given a valid entity with ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
it
"returns a Address object"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"set the entity correctly"
do
expect
(
address
.
entity
).
to
eql
(
BASE_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
BASE_
ADDRESS_ENTITY
)
end
it
"set the ssid correctly"
do
expect
(
address
.
ssid
).
to
eql
(
BASE_
ENTITY
_SSID
)
expect
(
address
.
ssid
).
to
eql
(
BASE_
ADDRESS
_SSID
)
end
end
context
"Given a valid entity with 0 ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ADDRESS
)
it
"returns a FrameAddress object"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"the entity field was parssed correctly"
do
expect
(
address
.
entity
).
to
eql
(
ZEROSSID_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
ZEROSSID_
ADDRESS_ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
address
.
ssid
).
to
be_nil
end
end
context
"Given a valid entity with no ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ADDRESS
)
it
"returns a FrameAddress object"
do
expect
(
address
).
not_to
be_nil
expect
(
address
).
to
be_kind_of
(
Ax25
::
Address
)
end
it
"the entity field was parssed correctly"
do
expect
(
address
.
entity
).
to
eql
(
NOSSID_
ENTITY_CALLSIGN
)
expect
(
address
.
entity
).
to
eql
(
NOSSID_
ADDRESS_ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
address
.
ssid
).
to
eql
(
NOSSID_
ENTITY
_SSID
)
expect
(
address
.
ssid
).
to
eql
(
NOSSID_
ADDRESS
_SSID
)
end
end
context
"Given an invalid entity with valid ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_
CALLSIGN_ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_
ENTITY_ADDRESS
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a address with two hyphens"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HYPHEN_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HYPHEN_
ADDRESS
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a address with a hyphen but no ssid"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HYPHEN_NOSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HYPHEN_NOSSID_
ADDRESS
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a address with a an ssid greater than 15"
do
it
"throws an argument error"
do
expect
{
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HIGHSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BAD_HIGHSSID_
ADDRESS
)
}.
to
raise_error
(
ArgumentError
)
end
end
end
describe
".entity"
do
context
"Given a Address with valid entity and with an ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
it
"then the entity should be frozen"
do
expect
(
address
.
entity
).
to
be_frozen
end
end
context
"Given a Address with valid entity and without an ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ADDRESS
)
it
"then the entity should be frozen"
do
expect
(
address
.
entity
).
to
be_frozen
end
end
context
"Given any valid Address"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
it
"then we should not be able to set a value"
do
expect
{
address
.
entity
=
"BAD1B"
...
...
@@ -252,7 +252,7 @@ describe Ax25::Address do
end
describe
".ssid"
do
context
"Given any valid Address"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
it
"then we should not be able to set a value"
do
expect
{
address
.
ssid
=
"1"
...
...
@@ -267,7 +267,7 @@ describe Ax25::Address do
end
describe
".decrement_ssid"
do
context
"Given a Address that has a greater than 0 ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
context
"which has its ssid decremented"
do
new_address
=
address
.
decrement_ssid
it
"should produce a duplicated Address"
do
...
...
@@ -282,7 +282,7 @@ describe Ax25::Address do
end
end
context
"Given a Address that has a ssid of 0"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ADDRESS
)
context
"which has its ssid decremented"
do
it
"throws a range error"
do
expect
{
...
...
@@ -294,33 +294,33 @@ describe Ax25::Address do
end
describe
".to_s"
do
context
"Given a raw string with valid entity with ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
BASE_
ADDRESS
)
it
"then we should produce the correct string"
do
expect
(
address
.
to_s
).
to
eql
(
BASE_
ENTITY
)
expect
(
address
.
to_s
).
to
eql
(
BASE_
ADDRESS
)
end
end
context
"Given a raw string with valid entity with ssid of zero"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
ZEROSSID_
ADDRESS
)
it
"then we should produce the correct string"
do
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ENTITY
)
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ADDRESS
)
end
end
context
"Given a raw string with valid entity without ssid"
do
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ENTITY
)
address
=
Ax25
::
ImmutableAddress
.
from_raw
(
NOSSID_
ADDRESS
)
it
"then we should produce the correct string"
do
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ENTITY
)
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ADDRESS
)
end
end
context
"Given a FrameAddress from new with valid entity with non-zero ssid"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
BASE_ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
BASE_ADDRESS
_SSID
)
it
"then we should produce the correct string"
do
expect
(
address
.
to_s
).
to
eql
(
BASE_
ENTITY
)
expect
(
address
.
to_s
).
to
eql
(
BASE_
ADDRESS
)
end
end
context
"Given a FrameAddress from new with valid entity with ssid of 0"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
ZEROSSID_
ENTITY_CALLSIGN
,
ZEROSSID_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
ZEROSSID_
ADDRESS_ENTITY
,
ZEROSSID_
ADDRESS
_SSID
)
it
"then we should produce the correct string"
do
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ENTITY
)
expect
(
address
.
to_s
).
to
eql
(
NOSSID_
ADDRESS
)
end
end
end
...
...
@@ -328,15 +328,15 @@ describe Ax25::Address do
describe
".=="
do
context
"Given one Address and an equivelant non-Address class with the same properties"
do
address_equiv
=
AddressEquiv
.
new
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
BASE_ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
BASE_ADDRESS
_SSID
)
it
"then equality should return true"
do
expect
(
address
==
address_equiv
).
to
be_truthy
end
end
context
"Given two equivelant addresss both instaces of Address class with the same properties"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
nil
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
nil
)
it
"then equality should return true"
do
expect
(
address
==
address_equiv
).
to
be_truthy
end
...
...
@@ -344,14 +344,14 @@ describe Ax25::Address do
context
"Given one Address and a equivelant non-Address class with different properties"
do
address_equiv
=
AddressEquiv
.
new
address
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
BASE_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
BASE_
ADDRESS
_SSID
)
it
"then equality should return true"
do
expect
(
address
==
address_equiv
).
to
be_falsey
end
end
context
"Given two equivelant addresss both instaces of Address class with different properties"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
0
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
nil
)
it
"then equality should return true"
do
expect
(
address
==
address_equiv
).
to
be_falsey
...
...
@@ -362,7 +362,7 @@ describe Ax25::Address do
describe
".eql?"
do
context
"Given one Address and an equivelant non-Address class with the same properties"
do
address_equiv
=
AddressEquiv
.
new
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
BASE_ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
BASE_ADDRESS
_SSID
)
it
"throws an ArgumentError"
do
expect
{
address
.
eql?
address_equiv
...
...
@@ -371,8 +371,8 @@ describe Ax25::Address do
end
context
"Given two equivelant addresss both instaces of Address class"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
nil
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
nil
)
it
"then eql should return true"
do
expect
(
address
.
eql?
address_equiv
).
to
be_truthy
end
...
...
@@ -380,7 +380,7 @@ describe Ax25::Address do
context
"Given one Address and a equivelant non-Address class with different properties"
do
address_equiv
=
AddressEquiv
.
new
address
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
BASE_
ENTITY
_SSID
)
address
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
BASE_
ADDRESS
_SSID
)
it
"throws an ArgumentError"
do
expect
{
address
.
eql?
address_equiv
...
...
@@ -389,7 +389,7 @@ describe Ax25::Address do
end
context
"Given two equivelant addresss both instaces of Address class with different properties"
do
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ENTITY_CALLSIGN
,
0
)
address
=
Ax25
::
ImmutableAddress
.
new
(
BASE_
ADDRESS_ENTITY
,
0
)
address_equiv
=
Ax25
::
ImmutableAddress
.
new
(
"BADCALL"
,
nil
)
it
"then eql should return false"
do
expect
(
address
.
eql?
address_equiv
).
to
be_falsey
...
...
This diff is collapsed.
Click to expand it.
spec/ax25/frame/hop_spec.rb
+
43
−
43
View file @
afa1c6b1
require_relative
'../../../lib/ax25/frame/hop'
BASE_HOP
=
"WI2ARD-10*"
.
freeze
BASE_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
BASE_HOP_
ENTITY
=
"WI2ARD"
.
freeze
BASE_HOP_SSID
=
10
BASE_HOP_SEEN
=
true
UNSEEN_HOP
=
"WI2ARD-10"
.
freeze
UNSEEN_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
UNSEEN_HOP_
ENTITY
=
"WI2ARD"
.
freeze
UNSEEN_HOP_SSID
=
10
UNSEEN_HOP_SEEN
=
false
NOSSID_HOP
=
"WI2ARD*"
.
freeze
NOSSID_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
NOSSID_HOP_
ENTITY
=
"WI2ARD"
.
freeze
NOSSID_HOP_SSID
=
nil
NOSSID_HOP_SEEN
=
true
ZEROSSID_HOP
=
"WI2ARD-0*"
.
freeze
ZEROSSID_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
ZEROSSID_HOP_
ENTITY
=
"WI2ARD"
.
freeze
ZEROSSID_HOP_SSID
=
0
ZEROSSID_HOP_SEEN
=
true
NOSSID_UNSEEN_HOP
=
"WI2ARD"
.
freeze
NOSSID_UNSEEN_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
NOSSID_UNSEEN_HOP_
ENTITY
=
"WI2ARD"
.
freeze
NOSSID_UNSEEN_HOP_SSID
=
nil
NOSSID_UNSEEN_HOP_SEEN
=
false
ZEROSSID_UNSEEN_HOP
=
"WI2ARD-0"
.
freeze
ZEROSSID_UNSEEN_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
ZEROSSID_UNSEEN_HOP_
ENTITY
=
"WI2ARD"
.
freeze
ZEROSSID_UNSEEN_HOP_SSID
=
0
ZEROSSID_UNSEEN_HOP_SEEN
=
false
BAD_
CALLSIGN
_HOP
=
"WI2&ARD-10*"
.
freeze
BAD_
CALLSIGN_HOP_CALLSIGN
=
"WI2&ARD"
.
freeze
BAD_
CALLSIGN
_HOP_SSID
=
10
BAD_
CALLSIGN
_HOP_SEEN
=
true
BAD_
ENTITY
_HOP
=
"WI2&ARD-10*"
.
freeze
BAD_
ENTITY_HOP_ENTITY
=
"WI2&ARD"
.
freeze
BAD_
ENTITY
_HOP_SSID
=
10
BAD_
ENTITY
_HOP_SEEN
=
true
BAD_HYPHEN_HOP
=
"WI2ARD-1-1*"
.
freeze
BAD_HYPHEN_NOSSID_HOP
=
"WI2ARD-*"
.
freeze
BAD_LOWSSID_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
BAD_LOWSSID_HOP_
ENTITY
=
"WI2ARD"
.
freeze
BAD_LOWSSID_HOP_SSID
=
-
1
BAD_LOWSSID_HOP_SEEN
=
true
BAD_HIGHSSID_HOP
=
"WI2ARD-16*"
.
freeze
BAD_HIGHSSID_HOP_
CALLSIGN
=
"WI2ARD"
.
freeze
BAD_HIGHSSID_HOP_
ENTITY
=
"WI2ARD"
.
freeze
BAD_HIGHSSID_HOP_SSID
=
16
BAD_HIGHSSID_HOP_SEEN
=
true
...
...
@@ -68,13 +68,13 @@ end
describe
Ax25
::
Hop
do
describe
".new"
do
context
"Given a valid entity with ssid and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
it
"returns a FrameHop object with correct properties"
do
expect
(
hop
).
not_to
be_nil
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"set the entity property correctly"
do
expect
(
hop
.
entity
).
to
eql
(
BASE_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
BASE_HOP_
ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
BASE_HOP_SSID
)
...
...
@@ -84,13 +84,13 @@ describe Ax25::Hop do
end
end
context
"Given a valid entity with nil ssid and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
NOSSID_HOP_
CALLSIGN
,
NOSSID_HOP_SSID
,
NOSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
NOSSID_HOP_
ENTITY
,
NOSSID_HOP_SSID
,
NOSSID_HOP_SEEN
)
it
"returns a FrameHop object with correct properties"
do
expect
(
hop
).
not_to
be_nil
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"set the entity property correctly"
do
expect
(
hop
.
entity
).
to
eql
(
NOSSID_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
NOSSID_HOP_
ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
NOSSID_HOP_SSID
)
...
...
@@ -100,13 +100,13 @@ describe Ax25::Hop do
end
end
context
"Given a valid entity with zero for ssid and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_HOP_
CALLSIGN
,
ZEROSSID_HOP_SSID
,
ZEROSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_HOP_
ENTITY
,
ZEROSSID_HOP_SSID
,
ZEROSSID_HOP_SEEN
)
it
"returns a FrameHop object with correct properties"
do
expect
(
hop
).
not_to
be_nil
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"set the entity property correctly"
do
expect
(
hop
.
entity
).
to
eql
(
ZEROSSID_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
ZEROSSID_HOP_
ENTITY
)
end
it
"set the ssid property correctly"
do
expect
(
hop
.
ssid
).
to
be_nil
...
...
@@ -118,7 +118,7 @@ describe Ax25::Hop do
context
"Given an invalid entity with valid ssid and valid seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_
CALLSIGN_HOP_CALLSIGN
,
BAD_CALLSIGN
_HOP_SSID
,
BAD_
CALLSIGN
_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_
ENTITY_HOP_ENTITY
,
BAD_ENTITY
_HOP_SSID
,
BAD_
ENTITY
_HOP_SEEN
)
}.
to
raise_error
(
ArgumentError
)
end
end
...
...
@@ -132,7 +132,7 @@ describe Ax25::Hop do
context
"Given a valid entity with valid ssid and nil seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
nil
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
nil
)
}.
to
raise_error
(
ArgumentError
)
end
end
...
...
@@ -153,28 +153,28 @@ describe Ax25::Hop do
context
"Given a valid entity with non-integer ssid and valid seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
"invalid"
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
"invalid"
,
BASE_HOP_SEEN
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with valid ssid and non-boolean seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
"invalid"
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
"invalid"
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with ssid below 0 and valid seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_LOWSSID_HOP_
CALLSIGN
,
BAD_LOWSSID_HOP_SSID
,
BAD_LOWSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_LOWSSID_HOP_
ENTITY
,
BAD_LOWSSID_HOP_SSID
,
BAD_LOWSSID_HOP_SEEN
)
}.
to
raise_error
(
ArgumentError
)
end
end
context
"Given a valid entity with ssid above 15 and valid seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_HIGHSSID_HOP_
CALLSIGN
,
BAD_HIGHSSID_HOP_SSID
,
BAD_HIGHSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BAD_HIGHSSID_HOP_
ENTITY
,
BAD_HIGHSSID_HOP_SSID
,
BAD_HIGHSSID_HOP_SEEN
)
}.
to
raise_error
(
ArgumentError
)
end
end
...
...
@@ -199,7 +199,7 @@ describe Ax25::Hop do
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"set the entity correctly"
do
expect
(
hop
.
entity
).
to
eql
(
BASE_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
BASE_HOP_
ENTITY
)
end
it
"set the ssid correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
BASE_HOP_SSID
)
...
...
@@ -215,7 +215,7 @@ describe Ax25::Hop do
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"the entity field was parssed correctly"
do
expect
(
hop
.
entity
).
to
eql
(
UNSEEN_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
UNSEEN_HOP_
ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
UNSEEN_HOP_SSID
)
...
...
@@ -231,7 +231,7 @@ describe Ax25::Hop do
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"the entity field was parssed correctly"
do
expect
(
hop
.
entity
).
to
eql
(
ZEROSSID_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
ZEROSSID_HOP_
ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
hop
.
ssid
).
to
be_nil
...
...
@@ -247,7 +247,7 @@ describe Ax25::Hop do
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"the entity field was parssed correctly"
do
expect
(
hop
.
entity
).
to
eql
(
NOSSID_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
NOSSID_HOP_
ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
NOSSID_HOP_SSID
)
...
...
@@ -263,7 +263,7 @@ describe Ax25::Hop do
expect
(
hop
).
to
be_kind_of
(
Ax25
::
Hop
)
end
it
"the entity field was parssed correctly"
do
expect
(
hop
.
entity
).
to
eql
(
NOSSID_UNSEEN_HOP_
CALLSIGN
)
expect
(
hop
.
entity
).
to
eql
(
NOSSID_UNSEEN_HOP_
ENTITY
)
end
it
"the ssid field was parssed correctly"
do
expect
(
hop
.
ssid
).
to
eql
(
NOSSID_UNSEEN_HOP_SSID
)
...
...
@@ -275,7 +275,7 @@ describe Ax25::Hop do
context
"Given an invalid entity with valid ssid and valid seen flag"
do
it
"throws an argument error"
do
expect
{
hop
=
Ax25
::
ImmutableHop
.
from_raw
(
BAD_
CALLSIGN
_HOP
)
hop
=
Ax25
::
ImmutableHop
.
from_raw
(
BAD_
ENTITY
_HOP
)
}.
to
raise_error
(
ArgumentError
)
end
end
...
...
@@ -459,31 +459,31 @@ describe Ax25::Hop do
end
end
context
"Given a FrameHop from new with valid entity with non-zero ssid and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
it
"then we should produce the correct string"
do
expect
(
hop
.
to_s
).
to
eql
(
BASE_HOP
)
end
end
context
"Given a FrameHop from new with valid entity with non-zero ssid and without seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
UNSEEN_HOP_
CALLSIGN
,
UNSEEN_HOP_SSID
,
UNSEEN_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
UNSEEN_HOP_
ENTITY
,
UNSEEN_HOP_SSID
,
UNSEEN_HOP_SEEN
)
it
"then we should produce the correct string"
do
expect
(
hop
.
to_s
).
to
eql
(
UNSEEN_HOP
)
end
end
context
"Given a FrameHop from new with valid entity with nil ssid and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
NOSSID_HOP_
CALLSIGN
,
NOSSID_HOP_SSID
,
NOSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
NOSSID_HOP_
ENTITY
,
NOSSID_HOP_SSID
,
NOSSID_HOP_SEEN
)
it
"then we should produce the correct string"
do
expect
(
hop
.
to_s
).
to
eql
(
NOSSID_HOP
)
end
end
context
"Given a FrameHop from new with valid entity with ssid of 0 and with seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_HOP_
CALLSIGN
,
ZEROSSID_HOP_SSID
,
ZEROSSID_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_HOP_
ENTITY
,
ZEROSSID_HOP_SSID
,
ZEROSSID_HOP_SEEN
)
it
"then we should produce the correct string"
do
expect
(
hop
.
to_s
).
to
eql
(
NOSSID_HOP
)
end
end
context
"Given a FrameHop from new with valid entity with ssid of zero and without seen flag"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_UNSEEN_HOP_
CALLSIGN
,
ZEROSSID_UNSEEN_HOP_SSID
,
ZEROSSID_UNSEEN_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
ZEROSSID_UNSEEN_HOP_
ENTITY
,
ZEROSSID_UNSEEN_HOP_SSID
,
ZEROSSID_UNSEEN_HOP_SEEN
)
it
"then we should produce the correct string"
do
expect
(
hop
.
to_s
).
to
eql
(
NOSSID_UNSEEN_HOP
)
end
...
...
@@ -493,15 +493,15 @@ describe Ax25::Hop do
describe
".=="
do
context
"Given one Hop and an equivelant non-Hop class with the same properties"
do
hop_equiv
=
HopEquiv
.
new
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
it
"then equality should return true"
do
expect
(
hop
==
hop_equiv
).
to
be_truthy
end
end
context
"Given two equivelant hops both instaces of Hop class with the same properties"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
nil
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
nil
,
BASE_HOP_SEEN
)
it
"then equality should return true"
do
expect
(
hop
==
hop_equiv
).
to
be_truthy
end
...
...
@@ -516,7 +516,7 @@ describe Ax25::Hop do
end
context
"Given two equivelant hops both instaces of Hop class with different properties"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
0
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
"BADCALL"
,
nil
,
BASE_HOP_SEEN
)
it
"then equality should return true"
do
expect
(
hop
==
hop_equiv
).
to
be_falsey
...
...
@@ -527,7 +527,7 @@ describe Ax25::Hop do
describe
".eql?"
do
context
"Given one Hop and an equivelant non-Hop class with the same properties"
do
hop_equiv
=
HopEquiv
.
new
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
BASE_HOP_SSID
,
BASE_HOP_SEEN
)
it
"throws an ArgumentError"
do
expect
{
hop
.
eql?
hop_equiv
...
...
@@ -536,8 +536,8 @@ describe Ax25::Hop do
end
context
"Given two equivelant hops both instaces of Hop class"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
nil
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
nil
,
BASE_HOP_SEEN
)
it
"then eql should return true"
do
expect
(
hop
.
eql?
hop_equiv
).
to
be_truthy
end
...
...
@@ -554,7 +554,7 @@ describe Ax25::Hop do
end
context
"Given two equivelant hops both instaces of Hop class with different properties"
do
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
CALLSIGN
,
0
,
BASE_HOP_SEEN
)
hop
=
Ax25
::
ImmutableHop
.
new
(
BASE_HOP_
ENTITY
,
0
,
BASE_HOP_SEEN
)
hop_equiv
=
Ax25
::
ImmutableHop
.
new
(
"BADCALL"
,
nil
,
BASE_HOP_SEEN
)
it
"then eql should return false"
do
expect
(
hop
.
eql?
hop_equiv
).
to
be_falsey
...
...
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