Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
mbe-tools
TTool
Commits
cef457af
Commit
cef457af
authored
9 years ago
by
Letitia Li
Browse files
Options
Downloads
Patches
Plain Diff
Updated AvatarPragmaTests
parent
0e96314f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/Avatar/AvatarPragmaTests.java
+18
-10
18 additions, 10 deletions
tests/Avatar/AvatarPragmaTests.java
with
18 additions
and
10 deletions
tests/Avatar/AvatarPragmaTests.java
+
18
−
10
View file @
cef457af
...
@@ -124,7 +124,7 @@ public class AvatarPragmaTests extends TToolTest {
...
@@ -124,7 +124,7 @@ public class AvatarPragmaTests extends TToolTest {
//Handle whitespace
//Handle whitespace
res
=
AvatarPragma
.
createFromString
(
"Public A.key1"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"Public A.key1"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Whitespace parsing: "
+
(
res
.
size
()!=
0
));
this
.
updateDigest
(
"Whitespace parsing: "
+
(
res
.
size
()!=
0
));
res
=
AvatarPragma
.
createFromString
(
"
PrivatePublicKeys
A.key1 B.key2"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"
Confidentiality
A.key1 B.key2"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Whitespace parsing: "
+
(
res
.
size
()!=
0
));
this
.
updateDigest
(
"Whitespace parsing: "
+
(
res
.
size
()!=
0
));
//Test missing block
//Test missing block
...
@@ -218,19 +218,23 @@ public class AvatarPragmaTests extends TToolTest {
...
@@ -218,19 +218,23 @@ public class AvatarPragmaTests extends TToolTest {
this
.
updateDigest
(
"Attr Name "
+
res
.
get
(
1
).
getArgs
().
get
(
1
));
this
.
updateDigest
(
"Attr Name "
+
res
.
get
(
1
).
getArgs
().
get
(
1
));
this
.
updateDigest
(
"-------------------------------------"
);
this
.
updateDigest
(
"-------------------------------------"
);
//Test S
ystem
Knowledge
//Test S
ession
Knowledge
this
.
updateDigest
(
"Initial Session Knowledge Tests"
);
this
.
updateDigest
(
"Initial Session Knowledge Tests"
);
res
=
AvatarPragma
.
createFromString
(
"InitialSessionKnowledge A.key2 B.key1 C.attr"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"InitialSessionKnowledge A.key2 B.key1 C.attr"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
//Check no error
//Check no error
this
.
updateDigest
(
"No error: "
+
(
res
.
size
()==
0
));
this
.
updateDigest
(
"No error: "
+
(
res
.
size
()==
1
));
//Check Type
//Check Type
this
.
updateDigest
(
"Right Type: "
+
(
res
.
get
(
0
)
instanceof
AvatarPragmaInitialKnowledge
));
this
.
updateDigest
(
"Right Type: "
+
(
res
.
get
(
0
)
instanceof
AvatarPragmaInitialKnowledge
));
//
1
Attribute
//
#
Attribute
s
this
.
updateDigest
(
"# of Attributes: "
+
(
res
.
get
(
0
).
getArgs
().
size
()
==
3
));
this
.
updateDigest
(
"# of Attributes: "
+
(
res
.
get
(
0
).
getArgs
().
size
()
==
3
));
//Is session
//Is session
res2
=
(
AvatarPragmaInitialKnowledge
)
res
.
get
(
0
);
res2
=
(
AvatarPragmaInitialKnowledge
)
res
.
get
(
0
);
this
.
updateDigest
(
"Is Session: "
+
!
res2
.
isSystem
());
this
.
updateDigest
(
"Is Session: "
+
!
res2
.
isSystem
());
//Test for error on different base types
res
=
AvatarPragma
.
createFromString
(
"InitialSessionKnowledge A.key2 B.key2"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Fail on different base types "
+
(
res
.
size
()==
0
));
this
.
updateDigest
(
"-------------------------------------"
);
this
.
updateDigest
(
"-------------------------------------"
);
//Test PrivatePublicKey
//Test PrivatePublicKey
...
@@ -287,18 +291,21 @@ public class AvatarPragmaTests extends TToolTest {
...
@@ -287,18 +291,21 @@ public class AvatarPragmaTests extends TToolTest {
//Fail if attributes are not same type
//Fail if attributes are not same type
res
=
AvatarPragma
.
createFromString
(
"Authenticity A.a1.key1 C.c1.m"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"Authenticity A.a1.key1 C.c1.m"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Incompatible types "
+
(
res
.
size
()==
0
));
this
.
updateDigest
(
"Incompatible types "
+
(
res
.
size
()==
0
));
res
=
AvatarPragma
.
createFromString
(
"Authenticity B.
a
1.m C.c1.d"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"Authenticity B.
b
1.m C.c1.d"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Incompatible types "
+
(
res
.
size
()==
0
));
this
.
updateDigest
(
"Incompatible types "
+
(
res
.
size
()==
0
));
res
=
AvatarPragma
.
createFromString
(
"Authenticity B.b1.key2 A.a1.key1"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"Incompatible types "
+
(
res
.
size
()==
0
));
//Check no error
//Check no error
res
=
AvatarPragma
.
createFromString
(
"Authenticity A.a1.key1 C.c1.attr"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
res
=
AvatarPragma
.
createFromString
(
"Authenticity A.a1.key1 C.c1.attr"
,
null
,
blocks
,
typeAttributesMap
,
nameTypeMap
);
this
.
updateDigest
(
"No error: "
+
(
res
.
size
()!=
0
));
this
.
updateDigest
(
"No error: "
+
(
res
.
size
()!=
0
));
//Check Type
//Check Type
this
.
updateDigest
(
"Right Type: "
+
(
res
.
get
(
0
)
instanceof
AvatarPragmaAuthenticity
));
this
.
updateDigest
(
"Right Type: "
+
(
res
.
get
(
0
)
instanceof
AvatarPragmaAuthenticity
));
//Attribute
//Attribute
AvatarPragmaAuthenticity
res3
=
(
AvatarPragmaAuthenticity
)
res
.
get
(
0
);
AvatarPragmaAuthenticity
res3
=
(
AvatarPragmaAuthenticity
)
res
.
get
(
0
);
this
.
updateDigest
(
"# of Attributes: "
+
(
res3
.
getArgs
().
size
()
==
2
));
this
.
updateDigest
(
"# of Attributes: "
+
(
res3
.
getArgs
().
size
()
==
2
));
this
.
updateDigest
(
"Attr "
+
res3
.
getAttrA
());
//
this.updateDigest("Attr "+ res3.getAttrA());
this
.
updateDigest
(
"Attr "
+
res3
.
getAttrB
());
//
this.updateDigest("Attr "+ res3.getAttrB());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrA
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrA
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrB
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrB
().
getName
());
this
.
updateDigest
(
"Attr State "
+
res3
.
getAttrA
().
getState
());
this
.
updateDigest
(
"Attr State "
+
res3
.
getAttrA
().
getState
());
...
@@ -308,8 +315,8 @@ public class AvatarPragmaTests extends TToolTest {
...
@@ -308,8 +315,8 @@ public class AvatarPragmaTests extends TToolTest {
this
.
updateDigest
(
"Multiple creation pass: "
+
(
res
.
size
()==
2
));
this
.
updateDigest
(
"Multiple creation pass: "
+
(
res
.
size
()==
2
));
res3
=
(
AvatarPragmaAuthenticity
)
res
.
get
(
1
);
res3
=
(
AvatarPragmaAuthenticity
)
res
.
get
(
1
);
this
.
updateDigest
(
"# of Attributes: "
+
(
res3
.
getArgs
().
size
()
==
2
));
this
.
updateDigest
(
"# of Attributes: "
+
(
res3
.
getArgs
().
size
()
==
2
));
this
.
updateDigest
(
"Attr "
+
res3
.
getAttrA
());
//
this.updateDigest("Attr "+ res3.getAttrA());
this
.
updateDigest
(
"Attr "
+
res3
.
getAttrB
());
//
this.updateDigest("Attr "+ res3.getAttrB());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrA
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrA
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrB
().
getName
());
this
.
updateDigest
(
"Attr Name "
+
res3
.
getAttrB
().
getName
());
this
.
updateDigest
(
"Attr State "
+
res3
.
getAttrA
().
getState
());
this
.
updateDigest
(
"Attr State "
+
res3
.
getAttrA
().
getState
());
...
@@ -338,7 +345,8 @@ public class AvatarPragmaTests extends TToolTest {
...
@@ -338,7 +345,8 @@ public class AvatarPragmaTests extends TToolTest {
//Avatar Specification Tests
//Avatar Specification Tests
this
.
updateDigest
(
"Tests finished"
);
this
.
updateDigest
(
"Tests finished"
);
if
(!
this
.
testDigest
(
new
byte
[]
{-
111
,
70
,
-
80
,
102
,
-
77
,
-
8
,
127
,
103
,
-
92
,
74
,
25
,
107
,
-
108
,
39
,
-
5
,
23
,
-
49
,
56
,
-
95
,
55
}))
//this.printDigest();
if
(!
this
.
testDigest
(
new
byte
[]
{-
90
,
49
,
84
,
60
,
-
76
,
-
16
,
-
13
,
79
,
-
65
,
-
123
,
61
,
-
9
,
38
,
110
,
-
27
,
80
,
19
,
-
15
,
82
,
-
36
}))
this
.
error
(
"Unexpected result when testing AvatarPragmas..."
);
this
.
error
(
"Unexpected result when testing AvatarPragmas..."
);
}
}
public
static
void
main
(
String
[]
args
){
public
static
void
main
(
String
[]
args
){
...
...
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