Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
96815032
Commit
96815032
authored
Feb 19, 2015
by
Jisi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
partial oneof tests.
parent
7b72a24a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
NanoTest.java
...nano/src/test/java/com/google/protobuf/nano/NanoTest.java
+38
-0
No files found.
javanano/src/test/java/com/google/protobuf/nano/NanoTest.java
View file @
96815032
...
...
@@ -3639,6 +3639,44 @@ public class NanoTest extends TestCase {
assertEquals
(
6
,
map
.
size
());
}
private
void
checkOneofCase
(
TestAllTypesNano
nano
,
int
field
)
throws
Exception
{
assertEquals
(
field
,
nano
.
getOneofFieldCase
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_BYTES_FIELD_NUMBER
,
nano
.
hasOneofBytes
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_ENUM_FIELD_NUMBER
,
nano
.
hasOneofEnum
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_FIXED64_FIELD_NUMBER
,
nano
.
hasOneofFixed64
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_NESTED_MESSAGE_FIELD_NUMBER
,
nano
.
hasOneofNestedMessage
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_STRING_FIELD_NUMBER
,
nano
.
hasOneofString
());
assertEquals
(
field
==
TestAllTypesNano
.
ONEOF_UINT32_FIELD_NUMBER
,
nano
.
hasOneofUint32
());
}
public
void
testOneofBasic
()
throws
Exception
{
TestAllTypesNano
m1
=
new
TestAllTypesNano
();
checkOneofCase
(
m1
,
0
);
m1
.
setOneofString
(
"hello"
);
checkOneofCase
(
m1
,
TestAllTypesNano
.
ONEOF_STRING_FIELD_NUMBER
);
TestAllTypesNano
m2
=
new
TestAllTypesNano
();
m2
.
setOneofEnum
(
TestAllTypesNano
.
BAZ
);
assertTrue
(
m2
.
hasOneofEnum
());
assertEquals
(
TestAllTypesNano
.
ONEOF_ENUM_FIELD_NUMBER
,
m2
.
getOneofFieldCase
());
}
public
void
testNullRepeatedFields
()
throws
Exception
{
// Check that serialization after explicitly setting a repeated field
// to null doesn't NPE.
...
...
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