Skip to content

Instantly share code, notes, and snippets.

std::vector<int> NumbersValidator::getNegatives(const std::vector<int> & numbers) const {
return VectorUtils::filter(numbers, [](int number) { return number < 0; });
}
<?php
$elements = array(1, 2, 3);
// array_map
// (PHP 4 >= 4.0.6, PHP 5)
$mappedElements = array_map(
function($element) {
return 2 * $element;
},
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/regex.hpp>
#include <boost/regex.hpp>
std::vector<std::string> StringUtils::split(
const std::string & str,
const std::vector<std::string> & delimiters) {
std::vector<std::string> tokens;
#include <regex>
#include <sstream>
std::vector<std::string> StringUtils::split(
const std::string & str,
const std::vector<std::string> & delimiters) {
std::regex rgx(join(escapeStrings(delimiters), "|"));
std::sregex_token_iterator
#include <gmock/gmock.h>
#include <vector>
#include "../code/StringUtils.h"
using namespace ::testing;
TEST(StringUtils, CanEscapeOneString) {
EXPECT_THAT(StringUtils::escapeString("*"), Eq("\\*"));
EXPECT_THAT(StringUtils::escapeString("\\"), Eq("\\\\"));
<?php
class SendingFormByEmailAndRedirecting
{
private $form;
private $email;
private $formRedirection;
function __construct(
FormEmail $email,
<?php
class SendingFormByEmailAndRedirectingTest extends PHPUnit_Framework_TestCase
{
private $form;
private $formRedirection;
private $email;
private $sendAndRedirectAction;
private $WHATEVER_FIELDS;
<?php
$action =
Action::sendingByEmail()
->formIn("empresas")
->to("[email protected]")
->build();
$action->execute();
<?php
class EmailAndRedirectService
{
private $redirection;
private $emailService;
function __construct(
FormEmailService $emailService,
Redirection $redirection
<?php
$service =
EmailAndRedirectServiceBuilder::aServiceToSendByEmail()
->aFormOnPage("empresas")
->to("[email protected]")
->build();
$service->sendAndRedirect(new Form($_POST));