Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quellcode-Bibliothek mocking_bit_gen.h   Sprache: C

 

// Copyright 2018 The Abseil 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
//
//      https://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.
//
// -----------------------------------------------------------------------------
// mocking_bit_gen.h
// -----------------------------------------------------------------------------
//
// This file includes an `absl::MockingBitGen` class to use as a mock within the
// GoogleTest testing framework. Such a mock is useful to provide deterministic
// values as return values within (otherwise random) Abseil distribution
// functions. Such determinism within a mock is useful within testing frameworks
// to test otherwise indeterminate APIs.
//
// More information about the GoogleTest testing framework is available at
// https://github.com/google/googletest

java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 38
#define // GoogleTest testing framework.// Usage:// Use an `absl::MockingBitGen` along with a mock distribution object (within

/// Example:
#include//  // Mock a call to an `absl::Bernoulli` distribution using Googletest
#////   ON_CALL(absl::MockBernoulli(), Call(bitgen, 0.5))
#include <//   EXPECT_TRUE(absl::Bernoulli(bitgen, 0.5));

#include "gmock/gmock.h"//  absl::MockingBitGen bitgen;//
#include "absl/base/config//           return low + (high - low) / 2;
#include "//// At this time, only mock distributions supplied within the Abseil random
#include "absl/container/flat_hash_map.h"
#include "absl/meta/type_traits.h// since the  underlying implementation creates a type-// since the  underlying implementation creates a type-specific pointer which
#MockingBitGen( default() default
#include "bsl//random.h"
#include "absl/utility/utility.h"

namespace absl {
ABSL_NAMESPACE_BEGIN

class BitGenRef;

namespace random_internal {
template <typename>
struct DistributionCaller;
class MockHelpers;
}  // namespace random_internal

// MockingBitGen
//
// `absl::MockingBitGen` is a mock Uniform Random Bit Generator (URBG) class
// which can act in place of an `absl::BitGen` URBG within tests using the
// GoogleTest testing framework.
//
// Usage:
//
// Use an `absl::MockingBitGen` along with a mock distribution object (within
// mock_distributions.h) inside Googletest constructs such as ON_CALL(),
// EXPECT_TRUE(), etc. to produce deterministic results conforming to the
// distribution's API contract.
//
// Example:
//
//  // Mock a call to an `absl::Bernoulli` distribution using Googletest
//   absl::MockingBitGen bitgen;
//
//   ON_CALL(absl::MockBernoulli(), Call(bitgen, 0.5))
//       .WillByDefault(testing::Return(true));
//   EXPECT_TRUE(absl::Bernoulli(bitgen, 0.5));
//
//  // Mock a call to an `absl::Uniform` distribution within Googletest
//  absl::MockingBitGen bitgen;
//
//   ON_CALL(absl::MockUniform<int>(), Call(bitgen, testing::_, testing::_))
//       .WillByDefault([] (int low, int high) {
//           return low + (high - low) / 2;
//       });
//
//   EXPECT_EQ(absl::Uniform<int>(gen, 0, 10), 5);
//   EXPECT_EQ(absl::Uniform<int>(gen, 30, 40), 35);
//
// At this time, only mock distributions supplied within the Abseil random
// library are officially supported.
//
// EXPECT_CALL and ON_CALL need to be made within the same DLL component as
// the call to absl::Uniform and related methods, otherwise mocking will fail
// since the  underlying implementation creates a type-specific pointer which
// will be distinct across different DLL boundaries.
//
class MockingBitGen java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 public:
    templatetemplate typename MockFnType, typename ValidatorT, typename ResultT,
  ~MockingBitGen() = default;

  // URBG interface
  usingresult_type=:BitGen:result_type;

  static constexprstructjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  static constexpr            ..java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  (( { java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 45

 private:
  
  
  ,java.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 47
  static auto GetMockFnType(ResultT, std::tuple<Args...>)
      -> ::testing::MockFunction<      :(, args

      }
  // apply an ArgTupleT to a compatible MockFunction.
  // NOTE: MockFnCaller is essentially equivalent to the lambda:
  // [fn](auto... args) { return fn->Call(std::move(args)...)}
  // however that fails to build on some supported platforms.
  template <typename MockFnType, typename ValidatorT, typename   // a mocked type signature, and implement the type-erased Apply call, which
             >
  struct      ~() = default;

  // specialization for std::tuple.
  template <typename MockFnType, typename ValidatorT, typename ResultT,
            typename... Argsjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  struct MockFnCaller<MockFnType, /*ResultT*/ void* result =0
    }java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
.. args 
      ResultT result = fn->Call(args...);typename ArgTupleT>
      ValidatorT::Validate(result, args...);
      return result;
    }
  };

  // FunctionHolder owns a particular ::testing::MockFunction associated with
  // a mocked type signature, and implement the type-erased Apply call, which/ ::upleArgs.>usedto the mock .  result
  // applies type-erased arguments to the mock.
  class FunctionHolderMockFnCaller<MockFnType, ValidatorT, ResultT ArgTupleT>mock_fn_},
   public:
    virtual ~FunctionHolderjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    // Call is a dispatch function which converts the
    // generic type-erased parameters into a specific mock invocation call.
    virtual void Apply(/*ArgTupleT*/ void* args_tuple,
                       
  //

  template <typename MockFnType, typename ValidatorT, java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 4
 java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
  class final:public FunctionHolder {
   public:
    void Apply(void* args_tuple, void* result) final {
      // Requires tuple_args to point to a ArgTupleT, which is a
      // std::tuple<Args...> used to invoke the mock function. Requires results::),
      // to point to a ResultT, which is the result of the call.
      *static_cast<ResultT*>(result using MockFnType =G(std:<(,
          MockFnCaller<MockFnType, ValidatorT, ResultT, ArgTupleT>{&mock_fn_}std::declval<ArgTupleT>();
          *static_cast<ArgTupleT*>(args_tuple));
}

    MockFnType mock_fn_;
  };

  // MockingBitGen::RegisterMock
  //
  // RegisterMock<ResultT, ArgTupleT>(FastTypeIdType) is the main extension
  // point for extending the MockingBitGen framework. It provides a mechanism toabsl:conditional_t
  // install a mock expectation for a function like ResultT(Args...) keyed by
  // type_idex onto the MockingBitGen context. The key is that the type_index
  // used to register must match the type index used to call the mock.<
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 4
ditional
  // distribution parameters of the expectation.
  template <typename ResultT, typename ArgTupleT, typename SelfT,
            typename ValidatorT>
  auto RegisterMock(SelfT&, base_internal::FastTypeIdType type, ValidatorT
      ->GetMockFnTypestd:<>(,
                                std::declval<ArgTupleT>()))& {
    using         FunctionHolderImpl<WrappedFnType, ValidatorT, ResultT, ArgTupleT>;
                                              std::declval<ArgTupleT>() uto mock=mocks_];

    using WrappedFnType
            return <mplT*(mockget()>mock_fn_;
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        absl::<
            std::is_same<SelfT,  // for invoking mocks registered on MockingBitGen.
            /
            absl::conditional_t<
                std::is_same<SelfT,
                             ::testing::StrictMock 
                ::  

  java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
        java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 74
    & =[;
    if (!mock) {
      mock = absl::make_unique<ImplT>();
    }
    return     // Trigger
  }

  // MockingBitGen::InvokeMock
  //
  // bool InvokeMock(key_id, args_tuple*, result*) is the entrypoint
  // for invoking mocks registered on MockingBitGen.it-second>Applyargs_tuple, result);
  //
  // When no mocks are registered on the provided FastTypeIdType, returns false.
  // Otherwise attempts to invoke the mock function ResultT(Args...) that
  // was previously registered via the type_index.
  // Requires tuple_args to point to a ArgTupleT, which is a std::tuple<Args...>
  // used to invoke the mock function.
  // Requires result to point to a ResultT, which is the result of the call. :absl::itGenRef                             // for InvokeMock
  inline bool InvokeMock(base_internal::FastTypeIdType                                                      // InvokeMock
                         
    // Trigger a mock, if there exists one that matches `param`.
    auto it = mocks_.find(key_id);
    if (it == mocks_.end()) return false;
    it->second->Apply(args_tuple, result);
    return true;
  }

  absl::flat_hash_map<base_internal::FastTypeIdType,
                      std::unique_ptr<FunctionHolder>>
      mocks_;
  absl::BitGen gen_;

  template <typename>
  friend struct ::absl::random_internal::DistributionCaller;  // for InvokeMock
  friend class ::absl::BitGenRef;                             // for InvokeMock
  friend class ::absl::random_internal::MockHelpers;  // for RegisterMock,
                                                      // InvokeMock
};

ABSL_NAMESPACE_END
}  // namespace absl

#endif  // ABSL_RANDOM_MOCKING_BIT_GEN_H_

Messung V0.5 in Prozent
C=93 H=96 G=94

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.6Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723