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
a80a37cc
Commit
a80a37cc
authored
Aug 14, 2008
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidying up, and a couple of extra tests.
parent
f26f8dce
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
34 deletions
+28
-34
CodedInputStreamTest.cs
csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs
+25
-27
ReflectionTester.cs
csharp/ProtocolBuffers.Test/ReflectionTester.cs
+0
-1
CodedInputStream.cs
csharp/ProtocolBuffers/CodedInputStream.cs
+1
-1
DynamicMessage.cs
csharp/ProtocolBuffers/DynamicMessage.cs
+0
-1
ExtendableBuilder.cs
csharp/ProtocolBuffers/ExtendableBuilder.cs
+2
-4
No files found.
csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs
View file @
a80a37cc
...
@@ -201,56 +201,54 @@ namespace Google.ProtocolBuffers {
...
@@ -201,56 +201,54 @@ namespace Google.ProtocolBuffers {
}
}
}
}
/* TODO(jonskeet): Reinstate this when protoc is ready
[
Test
]
public void
testSkipWholeMessage() throws Exception
{
public
void
SkipWholeMessage
()
{
TestAllTypes message = TestUtil.
g
etAllSet();
TestAllTypes
message
=
TestUtil
.
G
etAllSet
();
byte[] rawBytes = message.
t
oByteArray();
byte
[]
rawBytes
=
message
.
T
oByteArray
();
// Create two parallel inputs. Parse one as unknown fields while using
// Create two parallel inputs. Parse one as unknown fields while using
// skipField() to skip each field on the other. Expect the same tags.
// skipField() to skip each field on the other. Expect the same tags.
CodedInputStream input1 = CodedInputStream.
new
Instance(rawBytes);
CodedInputStream
input1
=
CodedInputStream
.
Create
Instance
(
rawBytes
);
CodedInputStream input2 = CodedInputStream.
new
Instance(rawBytes);
CodedInputStream
input2
=
CodedInputStream
.
Create
Instance
(
rawBytes
);
UnknownFieldSet.Builder unknownFields = UnknownFieldSet.
new
Builder();
UnknownFieldSet
.
Builder
unknownFields
=
UnknownFieldSet
.
Create
Builder
();
while
(
true
)
{
while
(
true
)
{
int tag = input1.r
eadTag();
uint
tag
=
input1
.
R
eadTag
();
assertEquals(tag, input2.r
eadTag());
Assert
.
AreEqual
(
tag
,
input2
.
R
eadTag
());
if
(
tag
==
0
)
{
if
(
tag
==
0
)
{
break
;
break
;
}
}
unknownFields.mergeFieldFrom(tag, input1);
unknownFields
.
MergeFieldFrom
(
tag
,
input1
);
input2.skipField(tag);
input2
.
SkipField
(
tag
);
}
}
}
}*/
/* TODO(jonskeet): Reinstate this when protoc is ready
public
void
ReadHugeBlob
()
{
public void testReadHugeBlob() throws Exception {
// Allocate and initialize a 1MB blob.
// Allocate and initialize a 1MB blob.
byte
[]
blob
=
new
byte
[
1
<<
20
];
byte
[]
blob
=
new
byte
[
1
<<
20
];
for (int i = 0; i < blob.
l
ength; i++) {
for
(
int
i
=
0
;
i
<
blob
.
L
ength
;
i
++)
{
blob
[
i
]
=
(
byte
)
i
;
blob
[
i
]
=
(
byte
)
i
;
}
}
// Make a message containing it.
// Make a message containing it.
TestAllTypes.Builder builder = TestAllTypes.
new
Builder();
TestAllTypes
.
Builder
builder
=
TestAllTypes
.
Create
Builder
();
TestUtil.
s
etAllFields(builder);
TestUtil
.
S
etAllFields
(
builder
);
builder.
setOptionalBytes(ByteString.c
opyFrom(blob));
builder
.
SetOptionalBytes
(
ByteString
.
C
opyFrom
(
blob
));
TestAllTypes message = builder.
b
uild();
TestAllTypes
message
=
builder
.
B
uild
();
// Serialize and parse it. Make sure to parse from an InputStream, not
// Serialize and parse it. Make sure to parse from an InputStream, not
// directly from a ByteString, so that CodedInputStream uses buffered
// directly from a ByteString, so that CodedInputStream uses buffered
// reading.
// reading.
TestAllTypes message2 =
TestAllTypes
message2
=
TestAllTypes
.
ParseFrom
(
message
.
ToByteString
().
CreateCodedInput
());
TestAllTypes.parseFrom(message.toByteString().newInput());
assertEquals(message.getOptionalBytes(), message2.getOptionalBytes()
);
Assert
.
AreEqual
(
message
.
OptionalBytes
,
message2
.
OptionalBytes
);
// Make sure all the other fields were parsed correctly.
// Make sure all the other fields were parsed correctly.
TestAllTypes message3 = TestAllTypes.
new
Builder(message2)
TestAllTypes
message3
=
TestAllTypes
.
Create
Builder
(
message2
)
.
setOptionalBytes(TestUtil.getAllSet().getOptionalBytes()
)
.
SetOptionalBytes
(
TestUtil
.
GetAllSet
().
OptionalBytes
)
.
b
uild();
.
B
uild
();
TestUtil.
a
ssertAllFieldsSet(message3);
TestUtil
.
A
ssertAllFieldsSet
(
message3
);
}
*/
}
[
Test
]
[
Test
]
public
void
ReadMaliciouslyLargeBlob
()
{
public
void
ReadMaliciouslyLargeBlob
()
{
...
...
csharp/ProtocolBuffers.Test/ReflectionTester.cs
View file @
a80a37cc
...
@@ -51,7 +51,6 @@ namespace Google.ProtocolBuffers {
...
@@ -51,7 +51,6 @@ namespace Google.ProtocolBuffers {
/// then baseDescriptor should be for TestAllExtensions instead, and instead of
/// then baseDescriptor should be for TestAllExtensions instead, and instead of
/// reading and writing normal fields, the tester will read and write extensions.
/// reading and writing normal fields, the tester will read and write extensions.
/// All of the TestAllExtensions extensions must be registered in the registry.
/// All of the TestAllExtensions extensions must be registered in the registry.
/// TODO(jonskeet): Enforce all of these with two factory methods.
/// </summary>
/// </summary>
private
ReflectionTester
(
MessageDescriptor
baseDescriptor
,
private
ReflectionTester
(
MessageDescriptor
baseDescriptor
,
ExtensionRegistry
extensionRegistry
)
{
ExtensionRegistry
extensionRegistry
)
{
...
...
csharp/ProtocolBuffers/CodedInputStream.cs
View file @
a80a37cc
...
@@ -102,7 +102,7 @@ namespace Google.ProtocolBuffers {
...
@@ -102,7 +102,7 @@ namespace Google.ProtocolBuffers {
}
}
#
endregion
#
endregion
#
region
Uncategorised
(
TODO
:
Fix
this
!)
#
region
Validation
/// <summary>
/// <summary>
/// Verifies that the last call to ReadTag() returned the given tag value.
/// Verifies that the last call to ReadTag() returned the given tag value.
/// This is used to verify that a nested group ended with the correct
/// This is used to verify that a nested group ended with the correct
...
...
csharp/ProtocolBuffers/DynamicMessage.cs
View file @
a80a37cc
...
@@ -8,7 +8,6 @@ namespace Google.ProtocolBuffers {
...
@@ -8,7 +8,6 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// <summary>
/// An implementation of IMessage that can represent arbitrary types, given a MessageaDescriptor.
/// An implementation of IMessage that can represent arbitrary types, given a MessageaDescriptor.
/// TODO: Implement appropriate generics.
/// </summary>
/// </summary>
public
class
DynamicMessage
:
AbstractMessage
<
DynamicMessage
,
DynamicMessage
.
Builder
>
{
public
class
DynamicMessage
:
AbstractMessage
<
DynamicMessage
,
DynamicMessage
.
Builder
>
{
...
...
csharp/ProtocolBuffers/ExtendableBuilder.cs
View file @
a80a37cc
...
@@ -95,8 +95,7 @@ namespace Google.ProtocolBuffers {
...
@@ -95,8 +95,7 @@ namespace Google.ProtocolBuffers {
set
{
set
{
if
(
field
.
IsExtension
)
{
if
(
field
.
IsExtension
)
{
ExtendableMessage
<
TMessage
,
TBuilder
>
message
=
MessageBeingBuilt
;
ExtendableMessage
<
TMessage
,
TBuilder
>
message
=
MessageBeingBuilt
;
// TODO(jonskeet): Figure out how to call this!
message
.
VerifyContainingType
(
field
);
// message.VerifyExtensionContainingType(field);
message
.
Extensions
[
field
,
index
]
=
value
;
message
.
Extensions
[
field
,
index
]
=
value
;
}
else
{
}
else
{
base
[
field
,
index
]
=
value
;
base
[
field
,
index
]
=
value
;
...
@@ -109,8 +108,7 @@ namespace Google.ProtocolBuffers {
...
@@ -109,8 +108,7 @@ namespace Google.ProtocolBuffers {
set
{
set
{
if
(
field
.
IsExtension
)
{
if
(
field
.
IsExtension
)
{
ExtendableMessage
<
TMessage
,
TBuilder
>
message
=
MessageBeingBuilt
;
ExtendableMessage
<
TMessage
,
TBuilder
>
message
=
MessageBeingBuilt
;
// TODO(jonskeet): Figure out how to call this!
message
.
VerifyContainingType
(
field
);
// message.VerifyExtensionContainingType(field);
message
.
Extensions
[
field
]
=
value
;
message
.
Extensions
[
field
]
=
value
;
}
else
{
}
else
{
base
[
field
]
=
value
;
base
[
field
]
=
value
;
...
...
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