#include "base/compiler_specific.h"
#include "mojo/public/cpp/base/big_buffer_mojom_traits.h"
#include "mojo/public/cpp/base/ref_counted_memory_mojom_traits.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "mojo/public/mojom/base/ref_counted_memory.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo_base {
TEST(RefCountedMemoryTest, Data) {
const uint8_t data[] = {'a', 'b', 'c', 'd', 'e'};
scoped_refptr<base::RefCountedMemory> in =
new base::RefCountedStaticMemory(data);
scoped_refptr<base::RefCountedMemory> out;
ASSERT_TRUE(
mojo::test::SerializeAndDeserialize<mojom::RefCountedMemory>(in, out));
ASSERT_EQ(out->size(), in->size());
EXPECT_TRUE(in->Equals(out));
}
TEST(RefCountedMemoryTest, Null) {
const uint8_t data[] = {'a', 'b', 'c', 'd', 'e'};
scoped_refptr<base::RefCountedMemory> out =
new base::RefCountedStaticMemory(data);
scoped_refptr<base::RefCountedMemory> in;
ASSERT_TRUE(
mojo::test::SerializeAndDeserialize<mojom::RefCountedMemory>(in, out));
ASSERT_FALSE(out.get());
}
}