LLVM: include/llvm/Testing/ADT/StringMapEntry.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_TESTING_ADT_STRINGMAPENTRY_H_

10#define LLVM_TESTING_ADT_STRINGMAPENTRY_H_

11

14#include "gmock/gmock.h"

15#include

16#include <type_traits>

17

18namespace llvm {

20

21template

23 decltype(std::declval<std::ostream &>() << std::declval());

24

25}

26

27

28

29template

31 OS << "{\"" << E.getKey().data() << "\": ";

33 decltype(E.getValue())>::value) {

34 OS << E.getValue();

35 } else {

36 OS << "non-printable value";

37 }

38 return OS << "}";

39}

40

42

43template

45 : public testing::MatcherInterface {

46public:

47 using ValueT = typename std::remove_reference_t::ValueType;

48

49 template <typename KeyMatcherT, typename ValueMatcherT>

51 ValueMatcherT ValueMatcherArg)

52 : KeyMatcher(

53 testing::SafeMatcherCast<const std::string &>(KeyMatcherArg)),

54 ValueMatcher(

55 testing::SafeMatcherCast<const ValueT &>(ValueMatcherArg)) {}

56

57 void DescribeTo(std::ostream *OS) const override {

58 *OS << "has a string key that ";

59 KeyMatcher.DescribeTo(OS);

60 *OS << ", and has a value that ";

61 ValueMatcher.DescribeTo(OS);

62 }

63

65 *OS << "has a string key that ";

66 KeyMatcher.DescribeNegationTo(OS);

67 *OS << ", or has a value that ";

68 ValueMatcher.DescribeNegationTo(OS);

69 }

70

71 bool

73 testing::MatchResultListener *ResultListener) const override {

74 testing::StringMatchResultListener KeyListener;

75 if (!KeyMatcher.MatchAndExplain(Entry.getKey().data(), &KeyListener)) {

76 *ResultListener << ("which has a string key " +

77 (KeyListener.str().empty() ? "that doesn't match"

78 : KeyListener.str()));

79 return false;

80 }

81 testing::StringMatchResultListener ValueListener;

82 if (!ValueMatcher.MatchAndExplain(Entry.getValue(), &ValueListener)) {

83 *ResultListener << ("which has a value " + (ValueListener.str().empty()

84 ? "that doesn't match"

85 : ValueListener.str()));

86 return false;

87 }

88 *ResultListener << "which is a match";

89 return true;

90 }

91

92private:

93 const testing::Matcher<const std::string &> KeyMatcher;

94 const testing::Matcher<const ValueT &> ValueMatcher;

95};

96

97template <typename KeyMatcherT, typename ValueMatcherT>

99public:

102

103 template

104 operator testing::Matcher() const {

105 return testing::Matcher(

107 }

108

109private:

110 const KeyMatcherT KM;

111 const ValueMatcherT VM;

112};

113

114}

115

116

117

118template <typename KeyMatcherT, typename ValueMatcherT>

119detail::StringMapEntryMatcher<KeyMatcherT, ValueMatcherT>

122 std::move(KM), std::move(VM));

123}

124

125}

126

127#endif

This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file contains library features backported from future STL versions.

StringMapEntry - This is used to represent one value that is inserted into a StringMap.

Definition StringMapEntry.h:45

StringMapEntryMatcherImpl(KeyMatcherT KeyMatcherArg, ValueMatcherT ValueMatcherArg)

Definition StringMapEntry.h:50

bool MatchAndExplain(StringMapEntryT Entry, testing::MatchResultListener *ResultListener) const override

Definition StringMapEntry.h:72

void DescribeTo(std::ostream *OS) const override

Definition StringMapEntry.h:57

void DescribeNegationTo(std::ostream *OS) const override

Definition StringMapEntry.h:64

typename std::remove_reference_t< StringMapEntryT >::ValueType ValueT

Definition StringMapEntry.h:47

Definition StringMapEntry.h:98

StringMapEntryMatcher(KeyMatcherT KMArg, ValueMatcherT VMArg)

Definition StringMapEntry.h:100

A self-contained host- and target-independent arbitrary-precision floating-point software implementat...

decltype(std::declval< std::ostream & >()<< std::declval< T >()) check_ostream

Definition StringMapEntry.h:22

This is an optimization pass for GlobalISel generic memory operations.

detail::StringMapEntryMatcher< KeyMatcherT, ValueMatcherT > IsStringMapEntry(KeyMatcherT KM, ValueMatcherT VM)

Returns a gMock matcher that matches a StringMapEntry whose string key matches KeyMatcher,...

Definition StringMapEntry.h:120

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

typename detail::detector< void, Op, Args... >::value_t is_detected

Detects if a given trait holds for some set of arguments 'Args'.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.