Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: third_party/protobuf/php/tests/test_base.php

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/protobuf/php/tests/test.sh ('k') | third_party/protobuf/php/tests/test_util.php » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <?php
2
3 use Foo\TestMessage;
4 use Foo\TestMessage_Sub;
5
6 class TestBase extends PHPUnit_Framework_TestCase
7 {
8
9 public function setFields(TestMessage $m)
10 {
11 TestUtil::setTestMessage($m);
12 }
13
14 public function expectFields(TestMessage $m)
15 {
16 $this->assertSame(-44, $m->getOptionalSint32());
17 $this->assertSame(46, $m->getOptionalFixed32());
18 $this->assertSame(-46, $m->getOptionalSfixed32());
19 $this->assertSame(1.5, $m->getOptionalFloat());
20 $this->assertSame(1.6, $m->getOptionalDouble());
21 $this->assertSame(true, $m->getOptionalBool());
22 $this->assertSame('a', $m->getOptionalString());
23 $this->assertSame('b', $m->getOptionalBytes());
24 $this->assertSame(33, $m->getOptionalMessage()->getA());
25 if (PHP_INT_SIZE == 4) {
26 $this->assertSame('-43', $m->getOptionalInt64());
27 $this->assertSame('43', $m->getOptionalUint64());
28 $this->assertSame('-45', $m->getOptionalSint64());
29 $this->assertSame('47', $m->getOptionalFixed64());
30 $this->assertSame('-47', $m->getOptionalSfixed64());
31 } else {
32 $this->assertSame(-43, $m->getOptionalInt64());
33 $this->assertSame(43, $m->getOptionalUint64());
34 $this->assertSame(-45, $m->getOptionalSint64());
35 $this->assertSame(47, $m->getOptionalFixed64());
36 $this->assertSame(-47, $m->getOptionalSfixed64());
37 }
38
39 $this->assertEquals(-42, $m->getRepeatedInt32()[0]);
40 $this->assertEquals(42, $m->getRepeatedUint32()[0]);
41 $this->assertEquals(-43, $m->getRepeatedInt64()[0]);
42 $this->assertEquals(43, $m->getRepeatedUint64()[0]);
43 $this->assertEquals(-44, $m->getRepeatedSint32()[0]);
44 $this->assertEquals(-45, $m->getRepeatedSint64()[0]);
45 $this->assertEquals(46, $m->getRepeatedFixed32()[0]);
46 $this->assertEquals(47, $m->getRepeatedFixed64()[0]);
47 $this->assertEquals(-46, $m->getRepeatedSfixed32()[0]);
48 $this->assertEquals(-47, $m->getRepeatedSfixed64()[0]);
49 $this->assertEquals(1.5, $m->getRepeatedFloat()[0]);
50 $this->assertEquals(1.6, $m->getRepeatedDouble()[0]);
51 $this->assertEquals(true, $m->getRepeatedBool()[0]);
52 $this->assertEquals('a', $m->getRepeatedString()[0]);
53 $this->assertEquals('b', $m->getRepeatedBytes()[0]);
54 $this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA());
55
56 $this->assertEquals(-52, $m->getRepeatedInt32()[1]);
57 $this->assertEquals(52, $m->getRepeatedUint32()[1]);
58 $this->assertEquals(-53, $m->getRepeatedInt64()[1]);
59 $this->assertEquals(53, $m->getRepeatedUint64()[1]);
60 $this->assertEquals(-54, $m->getRepeatedSint32()[1]);
61 $this->assertEquals(-55, $m->getRepeatedSint64()[1]);
62 $this->assertEquals(56, $m->getRepeatedFixed32()[1]);
63 $this->assertEquals(57, $m->getRepeatedFixed64()[1]);
64 $this->assertEquals(-56, $m->getRepeatedSfixed32()[1]);
65 $this->assertEquals(-57, $m->getRepeatedSfixed64()[1]);
66 $this->assertEquals(2.5, $m->getRepeatedFloat()[1]);
67 $this->assertEquals(2.6, $m->getRepeatedDouble()[1]);
68 $this->assertEquals(false, $m->getRepeatedBool()[1]);
69 $this->assertEquals('c', $m->getRepeatedString()[1]);
70 $this->assertEquals('d', $m->getRepeatedBytes()[1]);
71 $this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA());
72 }
73
74 public function expectEmptyFields(TestMessage $m)
75 {
76 $this->assertSame(0, $m->getOptionalInt32());
77 $this->assertSame(0, $m->getOptionalUint32());
78 $this->assertSame(0, $m->getOptionalSint32());
79 $this->assertSame(0, $m->getOptionalFixed32());
80 $this->assertSame(0, $m->getOptionalSfixed32());
81 $this->assertSame(0.0, $m->getOptionalFloat());
82 $this->assertSame(0.0, $m->getOptionalDouble());
83 $this->assertSame(false, $m->getOptionalBool());
84 $this->assertSame('', $m->getOptionalString());
85 $this->assertSame('', $m->getOptionalBytes());
86 $this->assertNull($m->getOptionalMessage());
87 if (PHP_INT_SIZE == 4) {
88 $this->assertSame("0", $m->getOptionalInt64());
89 $this->assertSame("0", $m->getOptionalUint64());
90 $this->assertSame("0", $m->getOptionalSint64());
91 $this->assertSame("0", $m->getOptionalFixed64());
92 $this->assertSame("0", $m->getOptionalSfixed64());
93 } else {
94 $this->assertSame(0, $m->getOptionalInt64());
95 $this->assertSame(0, $m->getOptionalUint64());
96 $this->assertSame(0, $m->getOptionalSint64());
97 $this->assertSame(0, $m->getOptionalFixed64());
98 $this->assertSame(0, $m->getOptionalSfixed64());
99 }
100 }
101
102 // This test is to avoid the warning of no test by php unit.
103 public function testNone()
104 {
105 }
106 }
OLDNEW
« no previous file with comments | « third_party/protobuf/php/tests/test.sh ('k') | third_party/protobuf/php/tests/test_util.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698