• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifdef UNSAFE_BUFFERS_BUILD
6 // TODO(crbug.com/341324165): Fix and remove.
7 #pragma allow_unsafe_buffers
8 #endif
9 
10 #include "base/containers/span_rust.h"
11 
12 #include "testing/gtest/include/gtest/gtest.h"
13 
14 namespace base {
15 namespace {
16 
TEST(BaseSpanRustTest,SliceConstruct)17 TEST(BaseSpanRustTest, SliceConstruct) {
18   uint8_t data[] = {0, 1, 2, 3, 4};
19   span<const uint8_t> data_span(data, 2u);
20   rust::Slice<const uint8_t> rust_slice = SpanToRustSlice(data_span);
21   EXPECT_EQ(2ul, rust_slice.length());
22   EXPECT_EQ(1, rust_slice[1]);
23 }
24 
25 }  // namespace
26 }  // namespace base
27