| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // TODO(vardhan): Needs a lot more testing. | 5 // TODO(vardhan): Needs a lot more testing. |
| 6 | 6 |
| 7 #include <mojo/bindings/array.h> | 7 #include <mojo/bindings/array.h> |
| 8 | 8 |
| 9 #include <mojo/bindings/struct.h> | 9 #include <mojo/bindings/struct.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include "gtest/gtest.h" |
| 12 #include "mojo/public/c/tests/bindings/testing_util.h" | 13 #include "mojo/public/c/tests/bindings/testing_util.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 14 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-c.h" | 15 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-c.h" |
| 15 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom-c.h" | 16 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom-c.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Tests MojomArray_New(). | 20 // Tests MojomArray_New(). |
| 21 TEST(ArrayTest, New) { | 21 TEST(ArrayTest, New) { |
| 22 char bytes_buffer[1000]; | 22 char bytes_buffer[1000]; |
| 23 struct MojomBuffer buf = {bytes_buffer, sizeof(bytes_buffer), 0}; | 23 struct MojomBuffer buf = {bytes_buffer, sizeof(bytes_buffer), 0}; |
| 24 | 24 |
| 25 struct MojomArrayHeader* arr = NULL; | 25 struct MojomArrayHeader* arr = NULL; |
| 26 arr = MojomArray_New(&buf, 3, sizeof(uint32_t)); | 26 arr = MojomArray_New(&buf, 3, sizeof(uint32_t)); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_EQ(static_cast<MojoHandle>(20u), | 285 EXPECT_EQ(static_cast<MojoHandle>(20u), |
| 286 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 0)); | 286 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 0)); |
| 287 EXPECT_EQ(MOJO_HANDLE_INVALID, | 287 EXPECT_EQ(MOJO_HANDLE_INVALID, |
| 288 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 1)); | 288 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 1)); |
| 289 EXPECT_EQ(static_cast<MojoHandle>(30u), | 289 EXPECT_EQ(static_cast<MojoHandle>(30u), |
| 290 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 2)); | 290 *MOJOM_ARRAY_INDEX(copied_struct->array_h.ptr, MojoHandle, 2)); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace | 294 } // namespace |
| OLD | NEW |