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

Side by Side Diff: mojo/public/cpp/bindings/tests/sample_service_unittest.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: serialization Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <ostream> 6 #include <ostream>
7 #include <string> 7 #include <string>
8 8
9 #include "mojo/public/cpp/bindings/allocation_scope.h"
10 #include "mojo/public/cpp/environment/environment.h" 9 #include "mojo/public/cpp/environment/environment.h"
11 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" 10 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 namespace mojo { 13 namespace mojo {
15 14
16 template <> 15 template <>
17 class TypeConverter<sample::Bar, int32_t> { 16 class TypeConverter<sample::BarPtr, int32_t> {
18 public: 17 public:
19 static int32_t ConvertTo(const sample::Bar& bar) { 18 static int32_t ConvertTo(const sample::BarPtr& bar) {
20 return static_cast<int32_t>(bar.alpha()) << 16 | 19 return static_cast<int32_t>(bar->alpha) << 16 |
21 static_cast<int32_t>(bar.beta()) << 8 | 20 static_cast<int32_t>(bar->beta) << 8 |
22 static_cast<int32_t>(bar.gamma()); 21 static_cast<int32_t>(bar->gamma);
23 } 22 }
24
25 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
26 }; 23 };
27 24
28 } // namespace mojo 25 } // namespace mojo
29 26
30 namespace sample { 27 namespace sample {
31 namespace { 28 namespace {
32 29
33 // Set this variable to true to print the message in hex. 30 // Set this variable to true to print the message in hex.
34 bool g_dump_message_as_hex = false; 31 bool g_dump_message_as_hex = false;
35 32
36 // Set this variable to true to print the message in human readable form. 33 // Set this variable to true to print the message in human readable form.
37 bool g_dump_message_as_text = false; 34 bool g_dump_message_as_text = false;
38 35
39 // Make a sample |Foo|. 36 // Make a sample |Foo|.
40 Foo MakeFoo() { 37 FooPtr MakeFoo() {
41 mojo::String name("foopy"); 38 mojo::String name("foopy");
42 39
43 Bar::Builder bar; 40 BarPtr bar(Bar::New());
44 bar.set_alpha(20); 41 bar->alpha = 20;
45 bar.set_beta(40); 42 bar->beta = 40;
46 bar.set_gamma(60); 43 bar->gamma = 60;
47 bar.set_type(Bar::TYPE_VERTICAL); 44 bar->type = Bar::TYPE_VERTICAL;
48 45
49 mojo::Array<Bar>::Builder extra_bars(3); 46 mojo::Array<BarPtr> extra_bars(3);
50 for (size_t i = 0; i < extra_bars.size(); ++i) { 47 for (size_t i = 0; i < extra_bars.size(); ++i) {
51 Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL; 48 Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL;
52 Bar::Builder bar; 49 BarPtr bar(Bar::New());
53 uint8_t base = static_cast<uint8_t>(i * 100); 50 uint8_t base = static_cast<uint8_t>(i * 100);
54 bar.set_alpha(base); 51 bar->alpha = base;
55 bar.set_beta(base + 20); 52 bar->beta = base + 20;
56 bar.set_gamma(base + 40); 53 bar->gamma = base + 40;
57 bar.set_type(type); 54 bar->type = type;
58 extra_bars[i] = bar.Finish(); 55 extra_bars[i] = bar.Pass();
59 } 56 }
60 57
61 mojo::Array<uint8_t>::Builder data(10); 58 mojo::Array<uint8_t> data(10);
62 for (size_t i = 0; i < data.size(); ++i) 59 for (size_t i = 0; i < data.size(); ++i)
63 data[i] = static_cast<uint8_t>(data.size() - i); 60 data[i] = static_cast<uint8_t>(data.size() - i);
64 61
65 mojo::Array<mojo::DataPipeConsumerHandle>::Builder input_streams(2); 62 mojo::Array<mojo::ScopedDataPipeConsumerHandle> input_streams(2);
66 mojo::Array<mojo::DataPipeProducerHandle>::Builder output_streams(2); 63 mojo::Array<mojo::ScopedDataPipeProducerHandle> output_streams(2);
67 for (size_t i = 0; i < input_streams.size(); ++i) { 64 for (size_t i = 0; i < input_streams.size(); ++i) {
68 MojoCreateDataPipeOptions options; 65 MojoCreateDataPipeOptions options;
69 options.struct_size = sizeof(MojoCreateDataPipeOptions); 66 options.struct_size = sizeof(MojoCreateDataPipeOptions);
70 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; 67 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
71 options.element_num_bytes = 1; 68 options.element_num_bytes = 1;
72 options.capacity_num_bytes = 1024; 69 options.capacity_num_bytes = 1024;
73 mojo::ScopedDataPipeProducerHandle producer; 70 mojo::ScopedDataPipeProducerHandle producer;
74 mojo::ScopedDataPipeConsumerHandle consumer; 71 mojo::ScopedDataPipeConsumerHandle consumer;
75 mojo::CreateDataPipe(&options, &producer, &consumer); 72 mojo::CreateDataPipe(&options, &producer, &consumer);
76 input_streams[i] = consumer.Pass(); 73 input_streams[i] = consumer.Pass();
77 output_streams[i] = producer.Pass(); 74 output_streams[i] = producer.Pass();
78 } 75 }
79 76
80 mojo::Array<mojo::Array<bool> >::Builder array_of_array_of_bools(2); 77 mojo::Array<mojo::Array<bool> > array_of_array_of_bools(2);
81 for (size_t i = 0; i < 2; ++i) { 78 for (size_t i = 0; i < 2; ++i) {
82 mojo::Array<bool>::Builder array_of_bools(2); 79 mojo::Array<bool> array_of_bools(2);
83 for (size_t j = 0; j < 2; ++j) { 80 for (size_t j = 0; j < 2; ++j)
84 array_of_bools[j] = j; 81 array_of_bools[j] = j;
85 } 82 array_of_array_of_bools[i] = array_of_bools.Pass();
86 array_of_array_of_bools[i] = array_of_bools.Finish();
87 } 83 }
88 84
89 mojo::ScopedMessagePipeHandle pipe0, pipe1; 85 mojo::ScopedMessagePipeHandle pipe0, pipe1;
90 mojo::CreateMessagePipe(&pipe0, &pipe1); 86 mojo::CreateMessagePipe(&pipe0, &pipe1);
91 87
92 Foo::Builder foo; 88 FooPtr foo(Foo::New());
93 foo.set_name(name); 89 foo->name = name;
94 foo.set_x(1); 90 foo->x = 1;
95 foo.set_y(2); 91 foo->y = 2;
96 foo.set_a(false); 92 foo->a = false;
97 foo.set_b(true); 93 foo->b = true;
98 foo.set_c(false); 94 foo->c = false;
99 foo.set_bar(bar.Finish()); 95 foo->bar = bar.Pass();
100 foo.set_extra_bars(extra_bars.Finish()); 96 foo->extra_bars = extra_bars.Pass();
101 foo.set_data(data.Finish()); 97 foo->data = data.Pass();
102 foo.set_source(pipe1.Pass()); 98 foo->source = pipe1.Pass();
103 foo.set_input_streams(input_streams.Finish()); 99 foo->input_streams = input_streams.Pass();
104 foo.set_output_streams(output_streams.Finish()); 100 foo->output_streams = output_streams.Pass();
105 foo.set_array_of_array_of_bools(array_of_array_of_bools.Finish()); 101 foo->array_of_array_of_bools = array_of_array_of_bools.Pass();
106 102
107 return foo.Finish(); 103 return foo.Pass();
108 } 104 }
109 105
110 // Check that the given |Foo| is identical to the one made by |MakeFoo()|. 106 // Check that the given |Foo| is identical to the one made by |MakeFoo()|.
111 void CheckFoo(const Foo& foo) { 107 void CheckFoo(const Foo& foo) {
112 const std::string kName("foopy"); 108 const std::string kName("foopy");
113 ASSERT_FALSE(foo.name().is_null()); 109 ASSERT_FALSE(foo.name.is_null());
114 EXPECT_EQ(kName.size(), foo.name().size()); 110 EXPECT_EQ(kName.size(), foo.name.size());
115 for (size_t i = 0; i < std::min(kName.size(), foo.name().size()); i++) { 111 for (size_t i = 0; i < std::min(kName.size(), foo.name.size()); i++) {
116 // Test both |operator[]| and |at|. 112 // Test both |operator[]| and |at|.
117 EXPECT_EQ(kName[i], foo.name().at(i)) << i; 113 EXPECT_EQ(kName[i], foo.name.at(i)) << i;
118 EXPECT_EQ(kName[i], foo.name()[i]) << i; 114 EXPECT_EQ(kName[i], foo.name[i]) << i;
119 } 115 }
120 EXPECT_EQ(kName, foo.name().To<std::string>()); 116 EXPECT_EQ(kName, foo.name.get());
121 117
122 EXPECT_EQ(1, foo.x()); 118 EXPECT_EQ(1, foo.x);
123 EXPECT_EQ(2, foo.y()); 119 EXPECT_EQ(2, foo.y);
124 EXPECT_FALSE(foo.a()); 120 EXPECT_FALSE(foo.a);
125 EXPECT_TRUE(foo.b()); 121 EXPECT_TRUE(foo.b);
126 EXPECT_FALSE(foo.c()); 122 EXPECT_FALSE(foo.c);
127 123
128 EXPECT_EQ(20, foo.bar().alpha()); 124 EXPECT_EQ(20, foo.bar->alpha);
129 EXPECT_EQ(40, foo.bar().beta()); 125 EXPECT_EQ(40, foo.bar->beta);
130 EXPECT_EQ(60, foo.bar().gamma()); 126 EXPECT_EQ(60, foo.bar->gamma);
131 EXPECT_EQ(Bar::TYPE_VERTICAL, foo.bar().type()); 127 EXPECT_EQ(Bar::TYPE_VERTICAL, foo.bar->type);
132 128
133 EXPECT_EQ(3u, foo.extra_bars().size()); 129 EXPECT_EQ(3u, foo.extra_bars.size());
134 for (size_t i = 0; i < foo.extra_bars().size(); i++) { 130 for (size_t i = 0; i < foo.extra_bars.size(); i++) {
135 uint8_t base = static_cast<uint8_t>(i * 100); 131 uint8_t base = static_cast<uint8_t>(i * 100);
136 Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL; 132 Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL;
137 EXPECT_EQ(base, foo.extra_bars()[i].alpha()) << i; 133 EXPECT_EQ(base, foo.extra_bars[i]->alpha) << i;
138 EXPECT_EQ(base + 20, foo.extra_bars()[i].beta()) << i; 134 EXPECT_EQ(base + 20, foo.extra_bars[i]->beta) << i;
139 EXPECT_EQ(base + 40, foo.extra_bars()[i].gamma()) << i; 135 EXPECT_EQ(base + 40, foo.extra_bars[i]->gamma) << i;
140 EXPECT_EQ(type, foo.extra_bars()[i].type()) << i; 136 EXPECT_EQ(type, foo.extra_bars[i]->type) << i;
141 } 137 }
142 138
143 EXPECT_EQ(10u, foo.data().size()); 139 EXPECT_EQ(10u, foo.data.size());
144 for (size_t i = 0; i < foo.data().size(); ++i) { 140 for (size_t i = 0; i < foo.data.size(); ++i) {
145 EXPECT_EQ(static_cast<uint8_t>(foo.data().size() - i), foo.data()[i]) << i; 141 EXPECT_EQ(static_cast<uint8_t>(foo.data.size() - i), foo.data[i]) << i;
146 } 142 }
147 143
148 EXPECT_FALSE(foo.input_streams().is_null()); 144 EXPECT_FALSE(foo.input_streams.is_null());
149 EXPECT_EQ(2u, foo.input_streams().size()); 145 EXPECT_EQ(2u, foo.input_streams.size());
150 146
151 EXPECT_FALSE(foo.output_streams().is_null()); 147 EXPECT_FALSE(foo.output_streams.is_null());
152 EXPECT_EQ(2u, foo.output_streams().size()); 148 EXPECT_EQ(2u, foo.output_streams.size());
153 149
154 EXPECT_EQ(2u, foo.array_of_array_of_bools().size()); 150 EXPECT_EQ(2u, foo.array_of_array_of_bools.size());
155 for (size_t i = 0; i < foo.array_of_array_of_bools().size(); ++i) { 151 for (size_t i = 0; i < foo.array_of_array_of_bools.size(); ++i) {
156 EXPECT_EQ(2u, foo.array_of_array_of_bools()[i].size()); 152 EXPECT_EQ(2u, foo.array_of_array_of_bools[i].size());
157 for (size_t j = 0; j < foo.array_of_array_of_bools()[i].size(); ++j) { 153 for (size_t j = 0; j < foo.array_of_array_of_bools[i].size(); ++j) {
158 EXPECT_EQ(bool(j), foo.array_of_array_of_bools()[i][j]); 154 EXPECT_EQ(bool(j), foo.array_of_array_of_bools[i][j]);
159 } 155 }
160 } 156 }
161 } 157 }
162 158
163 void PrintSpacer(int depth) { 159 void PrintSpacer(int depth) {
164 for (int i = 0; i < depth; ++i) 160 for (int i = 0; i < depth; ++i)
165 std::cout << " "; 161 std::cout << " ";
166 } 162 }
167 163
168 void Print(int depth, const char* name, bool value) { 164 void Print(int depth, const char* name, bool value) {
169 PrintSpacer(depth); 165 PrintSpacer(depth);
170 std::cout << name << ": " << (value ? "true" : "false") << std::endl; 166 std::cout << name << ": " << (value ? "true" : "false") << std::endl;
171 } 167 }
172 168
173 void Print(int depth, const char* name, int32_t value) { 169 void Print(int depth, const char* name, int32_t value) {
174 PrintSpacer(depth); 170 PrintSpacer(depth);
175 std::cout << name << ": " << value << std::endl; 171 std::cout << name << ": " << value << std::endl;
176 } 172 }
177 173
178 void Print(int depth, const char* name, uint8_t value) { 174 void Print(int depth, const char* name, uint8_t value) {
179 PrintSpacer(depth); 175 PrintSpacer(depth);
180 std::cout << name << ": " << uint32_t(value) << std::endl; 176 std::cout << name << ": " << uint32_t(value) << std::endl;
181 } 177 }
182 178
183 void Print(int depth, const char* name, mojo::Handle value) { 179 template <typename H>
180 void Print(int depth, const char* name,
181 const mojo::ScopedHandleBase<H>& value) {
184 PrintSpacer(depth); 182 PrintSpacer(depth);
185 std::cout << name << ": 0x" << std::hex << value.value() << std::endl; 183 std::cout << name << ": 0x" << std::hex << value.get().value() << std::endl;
186 } 184 }
187 185
188 void Print(int depth, const char* name, const mojo::String& str) { 186 void Print(int depth, const char* name, const mojo::String& str) {
189 std::string s = str.To<std::string>();
190 PrintSpacer(depth); 187 PrintSpacer(depth);
191 std::cout << name << ": \"" << str.To<std::string>() << "\"" << std::endl; 188 std::cout << name << ": \"" << str.get() << "\"" << std::endl;
192 } 189 }
193 190
194 void Print(int depth, const char* name, const Bar& bar) { 191 void Print(int depth, const char* name, const BarPtr& bar) {
195 PrintSpacer(depth); 192 PrintSpacer(depth);
196 std::cout << name << ":" << std::endl; 193 std::cout << name << ":" << std::endl;
197 if (!bar.is_null()) { 194 if (!bar.is_null()) {
198 ++depth; 195 ++depth;
199 Print(depth, "alpha", bar.alpha()); 196 Print(depth, "alpha", bar->alpha);
200 Print(depth, "beta", bar.beta()); 197 Print(depth, "beta", bar->beta);
201 Print(depth, "gamma", bar.gamma()); 198 Print(depth, "gamma", bar->gamma);
202 Print(depth, "packed", bar.To<int32_t>()); 199 Print(depth, "packed", bar.To<int32_t>());
203 --depth; 200 --depth;
204 } 201 }
205 } 202 }
206 203
207 template <typename T> 204 template <typename T>
208 void Print(int depth, const char* name,
209 const mojo::Passable<T>& passable) {
210 Print(depth, name, passable.get());
211 }
212
213 template <typename T>
214 void Print(int depth, const char* name, const mojo::Array<T>& array) { 205 void Print(int depth, const char* name, const mojo::Array<T>& array) {
215 PrintSpacer(depth); 206 PrintSpacer(depth);
216 std::cout << name << ":" << std::endl; 207 std::cout << name << ":" << std::endl;
217 if (!array.is_null()) { 208 if (!array.is_null()) {
218 ++depth; 209 ++depth;
219 for (size_t i = 0; i < array.size(); ++i) { 210 for (size_t i = 0; i < array.size(); ++i) {
220 std::stringstream buf; 211 std::stringstream buf;
221 buf << i; 212 buf << i;
222 Print(depth, buf.str().data(), array.at(i)); 213 Print(depth, buf.str().data(), array.at(i));
223 } 214 }
224 --depth; 215 --depth;
225 } 216 }
226 } 217 }
227 218
228 void Print(int depth, const char* name, const Foo& foo) { 219 void Print(int depth, const char* name, const FooPtr& foo) {
229 PrintSpacer(depth); 220 PrintSpacer(depth);
230 std::cout << name << ":" << std::endl; 221 std::cout << name << ":" << std::endl;
231 if (!foo.is_null()) { 222 if (!foo.is_null()) {
232 ++depth; 223 ++depth;
233 Print(depth, "name", foo.name()); 224 Print(depth, "name", foo->name);
234 Print(depth, "x", foo.x()); 225 Print(depth, "x", foo->x);
235 Print(depth, "y", foo.y()); 226 Print(depth, "y", foo->y);
236 Print(depth, "a", foo.a()); 227 Print(depth, "a", foo->a);
237 Print(depth, "b", foo.b()); 228 Print(depth, "b", foo->b);
238 Print(depth, "c", foo.c()); 229 Print(depth, "c", foo->c);
239 Print(depth, "bar", foo.bar()); 230 Print(depth, "bar", foo->bar);
240 Print(depth, "extra_bars", foo.extra_bars()); 231 Print(depth, "extra_bars", foo->extra_bars);
241 Print(depth, "data", foo.data()); 232 Print(depth, "data", foo->data);
242 Print(depth, "source", foo.source().get()); 233 Print(depth, "source", foo->source);
243 Print(depth, "input_streams", foo.input_streams()); 234 Print(depth, "input_streams", foo->input_streams);
244 Print(depth, "output_streams", foo.output_streams()); 235 Print(depth, "output_streams", foo->output_streams);
245 Print(depth, "array_of_array_of_bools", foo.array_of_array_of_bools()); 236 Print(depth, "array_of_array_of_bools", foo->array_of_array_of_bools);
246 --depth; 237 --depth;
247 } 238 }
248 } 239 }
249 240
250 void DumpHex(const uint8_t* bytes, uint32_t num_bytes) { 241 void DumpHex(const uint8_t* bytes, uint32_t num_bytes) {
251 for (uint32_t i = 0; i < num_bytes; ++i) { 242 for (uint32_t i = 0; i < num_bytes; ++i) {
252 std::cout << std::setw(2) << std::setfill('0') << std::hex << 243 std::cout << std::setw(2) << std::setfill('0') << std::hex <<
253 uint32_t(bytes[i]); 244 uint32_t(bytes[i]);
254 245
255 if (i % 16 == 15) { 246 if (i % 16 == 15) {
(...skipping 10 matching lines...) Expand all
266 257
267 class ServiceImpl : public Service { 258 class ServiceImpl : public Service {
268 public: 259 public:
269 ServiceImpl() : client_(NULL) { 260 ServiceImpl() : client_(NULL) {
270 } 261 }
271 262
272 virtual void SetClient(ServiceClient* client) MOJO_OVERRIDE { 263 virtual void SetClient(ServiceClient* client) MOJO_OVERRIDE {
273 client_ = client; 264 client_ = client;
274 } 265 }
275 266
276 virtual void Frobinate(const Foo& foo, BazOptions baz, PortPtr port) 267 virtual void Frobinate(FooPtr foo, BazOptions baz, PortPtr port)
277 MOJO_OVERRIDE { 268 MOJO_OVERRIDE {
278 // Users code goes here to handle the incoming Frobinate message. 269 // Users code goes here to handle the incoming Frobinate message.
279 270
280 // We mainly check that we're given the expected arguments. 271 // We mainly check that we're given the expected arguments.
281 CheckFoo(foo); 272 EXPECT_FALSE(foo.is_null());
273 if (!foo.is_null())
274 CheckFoo(*foo);
282 EXPECT_EQ(BAZ_EXTRA, baz); 275 EXPECT_EQ(BAZ_EXTRA, baz);
283 276
284 if (g_dump_message_as_text) { 277 if (g_dump_message_as_text) {
285 // Also dump the Foo structure and all of its members. 278 // Also dump the Foo structure and all of its members.
286 std::cout << "Frobinate:" << std::endl; 279 std::cout << "Frobinate:" << std::endl;
287 int depth = 1; 280 int depth = 1;
288 Print(depth, "foo", foo); 281 Print(depth, "foo", foo);
289 Print(depth, "baz", baz); 282 Print(depth, "baz", baz);
290 Print(depth, "port", port.get()); 283 Print(depth, "port", port.get());
291 } 284 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 331
339 // User has a proxy to a Service somehow. 332 // User has a proxy to a Service somehow.
340 Service* service = new ServiceProxyImpl(&receiver); 333 Service* service = new ServiceProxyImpl(&receiver);
341 334
342 // User constructs a message to send. 335 // User constructs a message to send.
343 336
344 // Notice that it doesn't matter in what order the structs / arrays are 337 // Notice that it doesn't matter in what order the structs / arrays are
345 // allocated. Here, the various members of Foo are allocated before Foo is 338 // allocated. Here, the various members of Foo are allocated before Foo is
346 // allocated. 339 // allocated.
347 340
348 mojo::AllocationScope scope; 341 FooPtr foo = MakeFoo();
349 342 CheckFoo(*foo);
350 Foo foo = MakeFoo();
351 CheckFoo(foo);
352 343
353 PortPtr port; 344 PortPtr port;
354 service->Frobinate(foo, Service::BAZ_EXTRA, port.Pass()); 345 service->Frobinate(foo.Pass(), Service::BAZ_EXTRA, port.Pass());
355 346
356 delete service; 347 delete service;
357 } 348 }
358 349
350 #if 0
359 TEST(BindingsSampleTest, DefaultValues) { 351 TEST(BindingsSampleTest, DefaultValues) {
360 mojo::Environment env; 352 mojo::Environment env;
361 SimpleMessageReceiver receiver; 353 SimpleMessageReceiver receiver;
362 mojo::AllocationScope scope; 354 mojo::AllocationScope scope;
363 355
364 DefaultsTest full = DefaultsTest::Builder().Finish(); 356 DefaultsTest full = DefaultsTest::Builder().Finish();
365 EXPECT_EQ(-12, full.a0()); 357 EXPECT_EQ(-12, full.a0());
366 EXPECT_EQ(12U, full.a1()); 358 EXPECT_EQ(12U, full.a1());
367 EXPECT_EQ(1234, full.a2()); 359 EXPECT_EQ(1234, full.a2());
368 EXPECT_EQ(34567U, full.a3()); 360 EXPECT_EQ(34567U, full.a3());
(...skipping 10 matching lines...) Expand all
379 EXPECT_FALSE(full.a12()); 371 EXPECT_FALSE(full.a12());
380 EXPECT_FLOAT_EQ(123.25f, full.a13()); 372 EXPECT_FLOAT_EQ(123.25f, full.a13());
381 EXPECT_DOUBLE_EQ(1234567890.123, full.a14()); 373 EXPECT_DOUBLE_EQ(1234567890.123, full.a14());
382 EXPECT_DOUBLE_EQ(1E10, full.a15()); 374 EXPECT_DOUBLE_EQ(1E10, full.a15());
383 EXPECT_DOUBLE_EQ(-1.2E+20, full.a16()); 375 EXPECT_DOUBLE_EQ(-1.2E+20, full.a16());
384 EXPECT_DOUBLE_EQ(1.23E-20, full.a17()); 376 EXPECT_DOUBLE_EQ(1.23E-20, full.a17());
385 EXPECT_TRUE(full.a18().is_null()); 377 EXPECT_TRUE(full.a18().is_null());
386 EXPECT_TRUE(full.a19().is_null()); 378 EXPECT_TRUE(full.a19().is_null());
387 EXPECT_TRUE(full.a20().is_null()); 379 EXPECT_TRUE(full.a20().is_null());
388 } 380 }
381 #endif
389 382
390 } // namespace 383 } // namespace
391 } // namespace sample 384 } // namespace sample
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698