<commit_before>#include <google/protobuf/util/message_differencer.h>
#include <lightstep/tracer.h>
#include <opentracing/noop.h>
#include "../src/lightstep_tracer_impl.h"
#include "../src/utility.h"
#include "in_memory_recorder.h"

#define CATCH_CONFIG_MAIN
#include <lightstep/catch/catch.hpp>
using namespace lightstep;
using namespace opentracing;

//------------------------------------------------------------------------------
// HasTag
//------------------------------------------------------------------------------
static bool HasTag(const collector::Span& span, string_view key,
                   const Value& value) {
  auto key_value = ToKeyValue(key, value);
  return std::find_if(
             std::begin(span.tags()), std::end(span.tags()),
             [&](const collector::KeyValue& other) {
               return google::protobuf::util::MessageDifferencer::Equals(
                   key_value, other);
             }) != std::end(span.tags());
}

//------------------------------------------------------------------------------
// HasRelationship
//------------------------------------------------------------------------------
static bool HasRelationship(SpanReferenceType relationship,
                            const collector::Span& span_a,
                            const collector::Span& span_b) {
  collector::Reference reference;
  switch (relationship) {
    case SpanReferenceType::ChildOfRef:
      reference.set_relationship(collector::Reference::CHILD_OF);
      break;
    case SpanReferenceType::FollowsFromRef:
      reference.set_relationship(collector::Reference::FOLLOWS_FROM);
      break;
  }
  *reference.mutable_span_context() = span_b.span_context();
  return std::any_of(
      std::begin(span_a.references()), std::end(span_a.references()),
      [&](const collector::Reference& other) {
        return google::protobuf::util::MessageDifferencer::Equals(reference,
                                                                  other);
      });
}

//------------------------------------------------------------------------------
// tests
//------------------------------------------------------------------------------
TEST_CASE("tracer") {
  auto recorder = new InMemoryRecorder();<commit_msg>Use std::any_of instead of std::find.<commit_after>#include <google/protobuf/util/message_differencer.h>
#include <lightstep/tracer.h>
#include <opentracing/noop.h>
#include "../src/lightstep_tracer_impl.h"
#include "../src/utility.h"
#include "in_memory_recorder.h"

#define CATCH_CONFIG_MAIN
#include <lightstep/catch/catch.hpp>
using namespace lightstep;
using namespace opentracing;

//------------------------------------------------------------------------------
// HasTag
//------------------------------------------------------------------------------
static bool HasTag(const collector::Span& span, string_view key,
                   const Value& value) {
  auto key_value = ToKeyValue(key, value);
  return std::any_of(
      std::begin(span.tags()), std::end(span.tags()),
      [&](const collector::KeyValue& other) {
        return google::protobuf::util::MessageDifferencer::Equals(key_value,
                                                                  other);
      });
}

//------------------------------------------------------------------------------
// HasRelationship
//------------------------------------------------------------------------------
static bool HasRelationship(SpanReferenceType relationship,
                            const collector::Span& span_a,
                            const collector::Span& span_b) {
  collector::Reference reference;
  switch (relationship) {
    case SpanReferenceType::ChildOfRef:
      reference.set_relationship(collector::Reference::CHILD_OF);
      break;
    case SpanReferenceType::FollowsFromRef:
      reference.set_relationship(collector::Reference::FOLLOWS_FROM);
      break;
  }
  *reference.mutable_span_context() = span_b.span_context();
  return std::any_of(
      std::begin(span_a.references()), std::end(span_a.references()),
      [&](const collector::Reference& other) {
        return google::protobuf::util::MessageDifferencer::Equals(reference,
                                                                  other);
      });
}

//------------------------------------------------------------------------------
// tests
//------------------------------------------------------------------------------
TEST_CASE("tracer") {
  auto recorder = new InMemoryRecorder();
{'fraction_non_alphanumeric': 0.3120567375886525, 'fraction_numerical': 0.0, 'mean_word_length': 1.419839142091153, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4907421', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1042, 'n_words': 181}