llvm/llvm/unittests/Support/DataExtractorTest.cpp

//===- llvm/unittest/Support/DataExtractorTest.cpp - DataExtractor tests --===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/DataExtractor.h"

#include "llvm/ADT/StringExtras.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
usingnamespacellvm;

namespace {

const char numberData[] =;
const char leb128data[] =;
const char bigleb128data[] =;

TEST(DataExtractorTest, OffsetOverflow) {}

TEST(DataExtractorTest, UnsignedNumbers) {}

TEST(DataExtractorTest, SignedNumbers) {}

TEST(DataExtractorTest, Strings) {}

TEST(DataExtractorTest, LEB128) {}

TEST(DataExtractorTest, LEB128_error) {}

TEST(DataExtractorTest, Cursor_tell) {}

TEST(DataExtractorTest, Cursor_seek) {}

TEST(DataExtractorTest, Cursor_takeError) {}

TEST(DataExtractorTest, Cursor_chaining) {}

#if defined(GTEST_HAS_DEATH_TEST) && defined(_DEBUG) &&                        \
    LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(DataExtractorDeathTest, Cursor) {
  DataExtractor DE(StringRef("AB"), false, 8);

  // Even an unused cursor must be checked for errors:
  EXPECT_DEATH(DataExtractor::Cursor(0),
               "Success values must still be checked prior to being destroyed");

  {
    auto C = std::make_unique<DataExtractor::Cursor>(0);
    EXPECT_EQ(0u, DE.getU32(*C));
    // It must also be checked after an unsuccessful operation.
    // destruction.
    EXPECT_DEATH(C.reset(), "unexpected end of data");
    EXPECT_THAT_ERROR(C->takeError(), Failed());
  }
  {
    auto C = std::make_unique<DataExtractor::Cursor>(0);
    EXPECT_EQ('A', DE.getU8(*C));
    // Same goes for a successful one.
    EXPECT_DEATH(
        C.reset(),
        "Success values must still be checked prior to being destroyed");
    EXPECT_THAT_ERROR(C->takeError(), Succeeded());
  }
  {
    auto C = std::make_unique<DataExtractor::Cursor>(0);
    EXPECT_EQ('A', DE.getU8(*C));
    EXPECT_EQ(0u, DE.getU32(*C));
    // Even if a successful operation is followed by an unsuccessful one.
    EXPECT_DEATH(C.reset(), "unexpected end of data");
    EXPECT_THAT_ERROR(C->takeError(), Failed());
  }
  {
    auto C = std::make_unique<DataExtractor::Cursor>(0);
    EXPECT_EQ(0u, DE.getU32(*C));
    EXPECT_EQ(0, DE.getU8(*C));
    // Even if an unsuccessful operation is followed by one that would normally
    // succeed.
    EXPECT_DEATH(C.reset(), "unexpected end of data");
    EXPECT_THAT_ERROR(C->takeError(), Failed());
  }
}
#endif

TEST(DataExtractorTest, getU8_vector) {}

TEST(DataExtractorTest, getU24) {}

TEST(DataExtractorTest, skip) {}

TEST(DataExtractorTest, eof) {}

TEST(DataExtractorTest, size) {}

TEST(DataExtractorTest, FixedLengthString) {}


TEST(DataExtractorTest, GetBytes) {}

}