Sha256: 23f6c6649d5c6c62ee10b52bbc3ed1b7f92c45c233dedb3607ff4fff63bb9e61

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

//          Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef IGLOO_STARTSWITHCONSTRAINT_H
#define IGLOO_STARTSWITHCONSTRAINT_H

#include "./expressions/expression.h"

namespace snowhouse {

  template <typename ExpectedType>
  struct StartsWithConstraint : Expression< StartsWithConstraint<ExpectedType> >
  {
    StartsWithConstraint(const ExpectedType& expected) 
      : m_expected(expected) {}
      
    bool operator()(const std::string& actual) const
    {
      return actual.find(m_expected) == 0;
    } 
    
    ExpectedType m_expected;
  };              

  template< typename ExpectedType >
  inline StartsWithConstraint<ExpectedType> StartsWith(const ExpectedType& expected)
  {
    return StartsWithConstraint<ExpectedType>(expected);
  }
  
  inline StartsWithConstraint<std::string> StartsWith(const char* expected)
  {
    return StartsWithConstraint<std::string>(expected);
  }

  template< typename ExpectedType >
  struct Stringizer< StartsWithConstraint< ExpectedType > >
  {
    static std::string ToString(const StartsWithConstraint<ExpectedType>& constraint)
    {
      std::ostringstream builder;
	  builder << "starts with " << snowhouse::Stringize(constraint.m_expected);

      return builder.str();
    }
  };
}

#endif

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tree-sitter-0.1.0 ext/tree-sitter/tree-sitter/externals/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/startswithconstraint.h
tree-sitter-0.0.1 ext/tree-sitter/tree-sitter/externals/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/startswithconstraint.h