span_rust_unittest.cc 583 B

123456789101112131415161718192021
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/containers/span_rust.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace base {
  7. namespace {
  8. TEST(BaseSpanRustTest, SliceConstruct) {
  9. uint8_t data[] = {0, 1, 2, 3, 4};
  10. span<const uint8_t> data_span(data, 2);
  11. rust::Slice<const uint8_t> rust_slice = SpanToRustSlice(data_span);
  12. EXPECT_EQ(2ul, rust_slice.length());
  13. EXPECT_EQ(1, rust_slice[1]);
  14. }
  15. } // namespace
  16. } // namespace base