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
4d5ae5b4
Commit
4d5ae5b4
authored
Aug 29, 2019
by
Sydney Acksman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use proto2 and proto3 in unknown field tests
parent
bdc6cd1d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
UnknownFieldSetTest.cs
csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs
+25
-14
No files found.
csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs
View file @
4d5ae5b4
...
@@ -40,6 +40,18 @@ namespace Google.Protobuf
...
@@ -40,6 +40,18 @@ namespace Google.Protobuf
{
{
public
class
UnknownFieldSetTest
public
class
UnknownFieldSetTest
{
{
public
class
Data
{
public
static
System
.
Collections
.
IEnumerable
Messages
{
get
{
yield
return
SampleMessages
.
CreateFullTestAllTypesProto2
();
yield
return
SampleMessages
.
CreateFullTestAllTypes
();
}
}
}
[
Test
]
[
Test
]
public
void
EmptyUnknownFieldSet
()
public
void
EmptyUnknownFieldSet
()
{
{
...
@@ -61,24 +73,23 @@ namespace Google.Protobuf
...
@@ -61,24 +73,23 @@ namespace Google.Protobuf
}
}
[
Test
]
[
Test
]
public
void
TestMergeCodedInput
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestMergeCodedInput
(
IMessage
message
)
{
{
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
emptyMessage
=
new
TestEmptyMessage
();
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
Assert
.
AreEqual
(
message
.
CalculateSize
(),
emptyMessage
.
CalculateSize
());
Assert
.
AreEqual
(
message
.
CalculateSize
(),
emptyMessage
.
CalculateSize
());
Assert
.
AreEqual
(
message
.
ToByteArray
(),
emptyMessage
.
ToByteArray
());
Assert
.
AreEqual
(
message
.
ToByteArray
(),
emptyMessage
.
ToByteArray
());
var
newMessage
=
new
Proto2
.
TestAllTypes
();
var
newMessage
=
message
.
Descriptor
.
Parser
.
ParseFrom
(
emptyMessage
.
ToByteArray
());
newMessage
.
MergeFrom
(
emptyMessage
.
ToByteArray
());
Assert
.
AreEqual
(
message
,
newMessage
);
Assert
.
AreEqual
(
message
,
newMessage
);
Assert
.
AreEqual
(
message
.
CalculateSize
(),
newMessage
.
CalculateSize
());
Assert
.
AreEqual
(
message
.
CalculateSize
(),
newMessage
.
CalculateSize
());
}
}
[
Test
]
[
Test
]
public
void
TestMergeMessage
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestMergeMessage
(
IMessage
message
)
{
{
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
...
@@ -89,9 +100,9 @@ namespace Google.Protobuf
...
@@ -89,9 +100,9 @@ namespace Google.Protobuf
}
}
[
Test
]
[
Test
]
public
void
TestEquals
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestEquals
(
IMessage
message
)
{
{
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
Assert
.
AreEqual
(
emptyMessage
,
otherEmptyMessage
);
Assert
.
AreEqual
(
emptyMessage
,
otherEmptyMessage
);
...
@@ -102,9 +113,9 @@ namespace Google.Protobuf
...
@@ -102,9 +113,9 @@ namespace Google.Protobuf
}
}
[
Test
]
[
Test
]
public
void
TestHashCode
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestHashCode
(
IMessage
message
)
{
{
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
emptyMessage
=
new
TestEmptyMessage
();
int
hashCode
=
emptyMessage
.
GetHashCode
();
int
hashCode
=
emptyMessage
.
GetHashCode
();
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
...
@@ -112,7 +123,8 @@ namespace Google.Protobuf
...
@@ -112,7 +123,8 @@ namespace Google.Protobuf
}
}
[
Test
]
[
Test
]
public
void
TestClone
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestClone
(
IMessage
message
)
{
{
var
emptyMessage
=
new
TestEmptyMessage
();
var
emptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
var
otherEmptyMessage
=
new
TestEmptyMessage
();
...
@@ -120,7 +132,6 @@ namespace Google.Protobuf
...
@@ -120,7 +132,6 @@ namespace Google.Protobuf
Assert
.
AreEqual
(
emptyMessage
.
CalculateSize
(),
otherEmptyMessage
.
CalculateSize
());
Assert
.
AreEqual
(
emptyMessage
.
CalculateSize
(),
otherEmptyMessage
.
CalculateSize
());
Assert
.
AreEqual
(
emptyMessage
.
ToByteArray
(),
otherEmptyMessage
.
ToByteArray
());
Assert
.
AreEqual
(
emptyMessage
.
ToByteArray
(),
otherEmptyMessage
.
ToByteArray
());
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
emptyMessage
.
MergeFrom
(
message
.
ToByteArray
());
otherEmptyMessage
=
emptyMessage
.
Clone
();
otherEmptyMessage
=
emptyMessage
.
Clone
();
Assert
.
AreEqual
(
message
.
CalculateSize
(),
otherEmptyMessage
.
CalculateSize
());
Assert
.
AreEqual
(
message
.
CalculateSize
(),
otherEmptyMessage
.
CalculateSize
());
...
@@ -128,9 +139,9 @@ namespace Google.Protobuf
...
@@ -128,9 +139,9 @@ namespace Google.Protobuf
}
}
[
Test
]
[
Test
]
public
void
TestDiscardUnknownFields
()
[
TestCaseSource
(
typeof
(
Data
),
"Messages"
)]
public
void
TestDiscardUnknownFields
(
IMessage
message
)
{
{
var
message
=
SampleMessages
.
CreateFullTestAllTypesProto2
();
var
goldenEmptyMessage
=
new
TestEmptyMessage
();
var
goldenEmptyMessage
=
new
TestEmptyMessage
();
byte
[]
data
=
message
.
ToByteArray
();
byte
[]
data
=
message
.
ToByteArray
();
int
fullSize
=
message
.
CalculateSize
();
int
fullSize
=
message
.
CalculateSize
();
...
...
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