Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php/ext/google/protobuf/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ upb_CType pbphp_dtype_to_type(upb_FieldType type) {
CASE(Enum, Enum);
CASE(Int32, Int32);
CASE(Int64, Int64);
CASE(UInt32, Int32);
CASE(UInt32, UInt32);
CASE(UInt64, UInt64);
CASE(SInt32, Int32);
CASE(SInt64, Int64);
Expand Down
37 changes: 37 additions & 0 deletions php/tests/GeneratedClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,43 @@ public function testUint32Field()
$this->assertSame(MIN_INT32, $m->getOptionalUint32());
}

public function testUint32ArrayConstructor()
{
$m1 = new TestMessage(['optional_uint32' => 2147483648]);
$this->assertSame(MIN_INT32, $m1->getOptionalUint32());

$m2 = new TestMessage(['optional_uint32' => MAX_UINT32]);
$this->assertSame(-1, $m2->getOptionalUint32());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test pass if you change the lefthand side from -1 to MAX_UINT32?

}

public function testRepeatedUint32Boundaries()
{
$m = new TestMessage();
$rf = $m->getRepeatedUint32();

$rf[] = 0;
$rf[] = MAX_INT32;
$rf[] = 2147483648;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob ezier to grok if MAX_INT32 + 1

$rf[] = MAX_UINT32;

$this->assertSame(0, $rf[0]);
$this->assertSame(MAX_INT32, $rf[1]);
$this->assertSame(MIN_INT32, $rf[2]);
$this->assertSame(-1, $rf[3]);
}

public function testMapUint32Uint32Boundaries()
{
$m = new TestMessage();
$map = $m->getMapUint32Uint32();

$map[1] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not map[0] ?

$map[MAX_UINT32] = MAX_UINT32;

$this->assertSame(0, $map[1]);
$this->assertSame(-1, $map[MAX_UINT32]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAX_UINT32 ?

}

#########################################################
# Test int64 field.
#########################################################
Expand Down
Loading