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

Unified Diff: mojo/public/c/bindings/tests/buffer_unittest.cc

Issue 2234063002: Move the C bindings tests to the new location. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_mojo_bindings
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/c/bindings/tests/array_unittest.cc ('k') | mojo/public/c/bindings/tests/message_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/c/bindings/tests/buffer_unittest.cc
diff --git a/mojo/public/c/bindings/tests/buffer_unittest.cc b/mojo/public/c/bindings/tests/buffer_unittest.cc
deleted file mode 100644
index aa95a785992667ac548a6f993d42f2126f4e4959..0000000000000000000000000000000000000000
--- a/mojo/public/c/bindings/tests/buffer_unittest.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <mojo/bindings/buffer.h>
-
-#include <stdint.h>
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-TEST(MojomBufferTest, RoundTo8) {
- char buffer[100];
- struct MojomBuffer mbuf = {
- buffer, sizeof(buffer),
- 0, // num_bytes_used
- };
-
- // This should actually allocate 8 bytes:
- EXPECT_EQ(buffer, MojomBuffer_Allocate(&mbuf, 6));
- EXPECT_EQ(8ul, mbuf.num_bytes_used);
- // The start of the next buffer is buffer + 8 bytes:
- EXPECT_EQ(buffer + 8, MojomBuffer_Allocate(&mbuf, 6));
- EXPECT_EQ(16ul, mbuf.num_bytes_used);
- // 8-bye allocation results in 8-byte allocation.
- EXPECT_EQ(buffer + 16, MojomBuffer_Allocate(&mbuf, 8));
- EXPECT_EQ(24ul, mbuf.num_bytes_used);
- // Allocate 0 bytes.
- EXPECT_EQ(buffer + 24ul, MojomBuffer_Allocate(&mbuf, 0));
- EXPECT_EQ(24ul, mbuf.num_bytes_used);
-}
-
-TEST(MojomBufferTest, Failure) {
- char buffer[100];
- struct MojomBuffer mbuf = {
- buffer, sizeof(buffer),
- 0, // num_bytes_used
- };
-
- // Allocate too much space.
- EXPECT_EQ(NULL, MojomBuffer_Allocate(&mbuf, sizeof(buffer) + 10));
-
- // Setup the buffer data so that it will overflow.
- mbuf.num_bytes_used = UINT32_MAX - 7; // This divides by 8.
- mbuf.buf_size = UINT32_MAX;
-
- // Rounds to 8, and allocates more than it has:
- EXPECT_EQ(NULL, MojomBuffer_Allocate(&mbuf, 1));
-}
-
-} // namespace
« no previous file with comments | « mojo/public/c/bindings/tests/array_unittest.cc ('k') | mojo/public/c/bindings/tests/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698