chromium/third_party/crashpad/crashpad/client/annotation_list_test.cc

// Copyright 2017 The Crashpad Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "client/annotation.h"

#include <algorithm>
#include <iterator>
#include <string>
#include <type_traits>
#include <vector>

#include "base/rand_util.h"
#include "client/crashpad_info.h"
#include "gtest/gtest.h"
#include "util/misc/clock.h"
#include "util/thread/thread.h"

namespace crashpad {
namespace test {
namespace {

#if (__cplusplus >= 202002L)
template <typename Iterator>
  requires std::input_iterator<Iterator>
void VerifyIsInputIterator(Iterator) {}
#else
template <typename Iterator>
struct IsLegacyIteratorImpl {
  static constexpr bool value =
      std::is_copy_constructible_v<Iterator> &&
      std::is_copy_assignable_v<Iterator> && std::is_destructible_v<Iterator> &&
      std::is_swappable_v<Iterator> &&
      // check that std::iterator_traits has the necessary types (check only one
      // needed as std::iterator is required to define only if all are defined)
      !std::is_same_v<typename std::iterator_traits<Iterator>::reference,
                      void> &&
      std::is_same_v<decltype(++std::declval<Iterator>()), Iterator&> &&
      !std::is_same_v<decltype(*std::declval<Iterator>()), void>;
};

template <typename Iterator>
struct IsLegacyInputIteratorImpl {
  static constexpr bool value =
      IsLegacyIteratorImpl<Iterator>::value &&
      std::is_base_of_v<
          std::input_iterator_tag,
          typename std::iterator_traits<Iterator>::iterator_category> &&
      std::is_convertible_v<decltype(std::declval<Iterator>() !=
                                     std::declval<Iterator>()),
                            bool> &&
      std::is_convertible_v<decltype(std::declval<Iterator>() ==
                                     std::declval<Iterator>()),
                            bool> &&
      std::is_same_v<decltype(*std::declval<Iterator>()),
                     typename std::iterator_traits<Iterator>::reference> &&
      std::is_same_v<decltype(++std::declval<Iterator>()), Iterator&> &&
      std::is_same_v<decltype(std::declval<Iterator>()++), Iterator> &&
      std::is_same_v<decltype(*(++std::declval<Iterator>())),
                     typename std::iterator_traits<Iterator>::reference>;
};

template <typename Iterator>
void VerifyIsInputIterator(Iterator) {
  static_assert(IsLegacyInputIteratorImpl<Iterator>::value);
}
#endif

TEST(AnnotationListStatic, Register) {}

class AnnotationList : public testing::Test {};

TEST_F(AnnotationList, SetAndClear) {}

TEST_F(AnnotationList, DuplicateKeys) {}

TEST_F(AnnotationList, IteratorSingleAnnotation) {}

TEST_F(AnnotationList, IteratorMultipleAnnotationsInserted) {}

TEST_F(AnnotationList, IteratorMultipleAnnotationsInsertedAndRemoved) {}

TEST_F(AnnotationList, IteratorIsInputIterator) {}

class RaceThread : public Thread {};

TEST_F(AnnotationList, MultipleThreads) {}

}  // namespace
}  // namespace test
}  // namespace crashpad