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
cb7fc657
Commit
cb7fc657
authored
Nov 19, 2010
by
csharptest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests and fixes
parent
272cb8ae
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
1 deletion
+75
-1
unittest_extras_full.proto
protos/extest/unittest_extras_full.proto
+23
-0
ProtocolBuffers.sln
src/ProtocolBuffers.sln
+1
-1
AbstractBuilder.cs
src/ProtocolBuffers/AbstractBuilder.cs
+4
-0
GeneratedBuilder.cs
src/ProtocolBuffers/GeneratedBuilder.cs
+4
-0
ExtendableBuilderLiteTest.cs
src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs
+42
-0
MissingFieldAndExtensionTest.cs
src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs
+0
-0
ProtocolBuffersLiteMixed.Test.csproj
...ocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
+1
-0
UnitTestExtrasFullProtoFile.cs
...uffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
+0
-0
No files found.
protos/extest/unittest_extras_full.proto
View file @
cb7fc657
...
...
@@ -47,3 +47,26 @@ message TestInteropEmployeeId {
extend
TestInteropPerson
{
required
TestInteropEmployeeId
employee_id
=
126
;
}
message
TestMissingFieldsA
{
required
string
name
=
1
;
required
int32
id
=
2
;
optional
string
email
=
3
;
message
SubA
{
required
int32
count
=
5
;
repeated
string
values
=
6
;
}
optional
SubA
testA
=
11
;
}
message
TestMissingFieldsB
{
required
string
name
=
1
;
required
int32
id
=
2
;
optional
string
website
=
4
;
message
SubB
{
repeated
string
values
=
7
;
}
optional
SubB
testB
=
12
;
}
src/ProtocolBuffers.sln
View file @
cb7fc657
...
...
@@ -38,7 +38,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unittest", "unittest", "{C8
..\protos\google\protobuf\unittest_embed_optimize_for.proto = ..\protos\google\protobuf\unittest_embed_optimize_for.proto
..\protos\google\protobuf\unittest_empty.proto = ..\protos\google\protobuf\unittest_empty.proto
..\protos\google\protobuf\unittest_enormous_descriptor.proto = ..\protos\google\protobuf\unittest_enormous_descriptor.proto
..\
protos\extest\unittest_extras_full.proto = ..\protos\extest\unittest_extras_full
.proto
..\
..\..\DotNet\ProtoFiles\Test\Protos\SampleComplex.proto = ..\..\..\DotNet\ProtoFiles\Test\Protos\SampleComplex
.proto
..\protos\extest\unittest_extras_lite.proto = ..\protos\extest\unittest_extras_lite.proto
..\protos\google\protobuf\unittest_import.proto = ..\protos\google\protobuf\unittest_import.proto
..\protos\google\protobuf\unittest_import_lite.proto = ..\protos\google\protobuf\unittest_import_lite.proto
...
...
src/ProtocolBuffers/AbstractBuilder.cs
View file @
cb7fc657
...
...
@@ -129,6 +129,10 @@ namespace Google.ProtocolBuffers {
this
[
field
]
=
entry
.
Value
;
}
}
//Fix for unknown fields not merging, see java's AbstractMessage.Builder<T> line 236
MergeUnknownFields
(
other
.
UnknownFields
);
return
ThisBuilder
;
}
...
...
src/ProtocolBuffers/GeneratedBuilder.cs
View file @
cb7fc657
...
...
@@ -158,6 +158,10 @@ namespace Google.ProtocolBuffers {
this
[
field
]
=
entry
.
Value
;
}
}
//Fix for unknown fields not merging, see java's AbstractMessage.Builder<T> line 236
MergeUnknownFields
(
other
.
UnknownFields
);
return
ThisBuilder
;
}
...
...
src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs
View file @
cb7fc657
...
...
@@ -221,5 +221,47 @@ namespace Google.ProtocolBuffers {
Assert
.
AreEqual
(
2
,
builder
.
GetExtensionCount
(
UnitTestLiteProtoFile
.
RepeatedInt32ExtensionLite
));
Assert
.
AreEqual
(
123
,
builder
.
GetExtension
(
UnitTestLiteProtoFile
.
RepeatedInt32ExtensionLite
,
1
));
}
[
Test
]
public
void
TestMissingExtensionsLite
()
{
const
int
optionalInt32
=
12345678
;
TestAllExtensionsLite
.
Builder
builder
=
TestAllExtensionsLite
.
CreateBuilder
();
builder
.
SetExtension
(
UnitTestLiteProtoFile
.
OptionalInt32ExtensionLite
,
optionalInt32
);
builder
.
AddExtension
(
UnitTestLiteProtoFile
.
RepeatedDoubleExtensionLite
,
1.1
);
builder
.
AddExtension
(
UnitTestLiteProtoFile
.
RepeatedDoubleExtensionLite
,
1.2
);
builder
.
AddExtension
(
UnitTestLiteProtoFile
.
RepeatedDoubleExtensionLite
,
1.3
);
TestAllExtensionsLite
msg
=
builder
.
Build
();
Assert
.
IsTrue
(
msg
.
HasExtension
(
UnitTestLiteProtoFile
.
OptionalInt32ExtensionLite
));
Assert
.
AreEqual
(
3
,
msg
.
GetExtensionCount
(
UnitTestLiteProtoFile
.
RepeatedDoubleExtensionLite
));
byte
[]
bits
=
msg
.
ToByteArray
();
TestAllExtensionsLite
copy
=
TestAllExtensionsLite
.
ParseFrom
(
bits
);
Assert
.
IsFalse
(
copy
.
HasExtension
(
UnitTestLiteProtoFile
.
OptionalInt32ExtensionLite
));
Assert
.
AreEqual
(
0
,
copy
.
GetExtensionCount
(
UnitTestLiteProtoFile
.
RepeatedDoubleExtensionLite
));
Assert
.
AreNotEqual
(
msg
,
copy
);
//The lite runtime removes all unknown fields and extensions
byte
[]
copybits
=
copy
.
ToByteArray
();
Assert
.
AreEqual
(
0
,
copybits
.
Length
);
}
[
Test
]
public
void
TestMissingFieldsLite
()
{
TestAllTypesLite
msg
=
TestAllTypesLite
.
CreateBuilder
()
.
SetOptionalInt32
(
123
)
.
SetOptionalString
(
"123"
)
.
Build
();
byte
[]
bits
=
msg
.
ToByteArray
();
TestAllExtensionsLite
copy
=
TestAllExtensionsLite
.
ParseFrom
(
bits
);
Assert
.
AreNotEqual
(
msg
,
copy
);
//The lite runtime removes all unknown fields and extensions
byte
[]
copybits
=
copy
.
ToByteArray
();
Assert
.
AreEqual
(
0
,
copybits
.
Length
);
}
}
}
src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs
0 → 100644
View file @
cb7fc657
This diff is collapsed.
Click to expand it.
src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
View file @
cb7fc657
...
...
@@ -63,6 +63,7 @@
<Compile
Include=
"ExtendableMessageLiteTest.cs"
/>
<Compile
Include=
"InteropLiteTest.cs"
/>
<Compile
Include=
"LiteTest.cs"
/>
<Compile
Include=
"MissingFieldAndExtensionTest.cs"
/>
<Compile
Include=
"TestLiteByApi.cs"
/>
<Compile
Include=
"TestProtos\UnitTestExtrasFullProtoFile.cs"
/>
<Compile
Include=
"TestProtos\UnitTestExtrasLiteProtoFile.cs"
/>
...
...
src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
View file @
cb7fc657
This diff is collapsed.
Click to expand it.
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