Fermé

a stub program for a c++/poco/regex .cpp program

i have a part program that describes how "poco" can use "regex" to manipulate data, it is good because it is cross environment,

but in order to do something a "stub" program must be made in order to call this routines and test the result, the routines are already there.

= = = = = = = = = = = = = = = =

// [url removed, login to view]

#include <Poco/RegularExpression.h>

#include <gtest/gtest.h>

TEST(RegularExpressionTest, match)

{

Poco::RegularExpression re1("[0-9]+");

EXPECT_TRUE([url removed, login to view]("123"));

EXPECT_FALSE([url removed, login to view]("abc"));

EXPECT_TRUE([url removed, login to view]("abc123", 3));

}

TEST(RegularExpressionTest, matchPos)

{

Poco::RegularExpression re1("[0-9]+");

Poco::RegularExpression::Match pos;

EXPECT_EQ(1, [url removed, login to view]("123", 0, pos));

EXPECT_EQ(0, [url removed, login to view]);

EXPECT_EQ(3, [url removed, login to view]);

EXPECT_EQ(1, [url removed, login to view]("ab12de90cd12d", 0, pos));

EXPECT_EQ(2, [url removed, login to view]);

EXPECT_EQ(2, [url removed, login to view]);

EXPECT_EQ(0, [url removed, login to view]("abcd", 0, pos));

EXPECT_EQ(std::string::npos, [url removed, login to view]);

Poco::RegularExpression re2("([0-9]+) ([0-9]+)");

Poco::RegularExpression::MatchVec posVec;

EXPECT_EQ(3, [url removed, login to view]("123 456", 0, posVec));

EXPECT_EQ(0, posVec[0].offset);

EXPECT_EQ(7, posVec[0].length);

EXPECT_EQ(0, posVec[1].offset);

EXPECT_EQ(3, posVec[1].length);

EXPECT_EQ(4, posVec[2].offset);

EXPECT_EQ(3, posVec[2].length);

}

TEST(RegularExpressionTest, extract)

{

std::string s;

Poco::RegularExpression re1("[0-9]+");

Poco::RegularExpression re2("([0-9]+) ([0-9]+)");

EXPECT_EQ(1, [url removed, login to view]("123", s));

EXPECT_EQ("123", s);

EXPECT_EQ(1, [url removed, login to view]("ab12de", 0, s));

EXPECT_EQ("12", s);

EXPECT_EQ(0, [url removed, login to view]("abcd", 0, s));

EXPECT_EQ("", s);

std::vector<std::string> vec;

[url removed, login to view]("123 456", 0, vec);

// FIXME: split?

EXPECT_EQ("123 456", vec[0]);

EXPECT_EQ("123", vec[1]);

EXPECT_EQ("456", vec[2]);

}

TEST(RegularExpressionTest, subst)

{

std::string s = "123";

Poco::RegularExpression re1("[0-9]+");

Poco::RegularExpression re2("([0-9]+) ([0-9]+)");

[url removed, login to view](s, "ABC");

EXPECT_EQ("ABC", s);

s = "123 456";

[url removed, login to view](s, "$2 $1");

EXPECT_EQ("456 123", s);

}

TEST(RegularExpressionTest, options)

{

Poco::RegularExpression re1("ABC");

EXPECT_FALSE([url removed, login to view]("abc", 0));

Poco::RegularExpression re2("ABC", Poco::RegularExpression::RE_CASELESS);

EXPECT_TRUE([url removed, login to view]("abc", 0));

}

Compétences : Programmation C++

en voir plus : vector vector string, vector string, vector in cpp, vector cpp, vector cplusplus, string vector, string in cpp, string cpp, string cplusplus, src program, regex is, regex in c, regex.h, regex c, programming vector, program data vector, data cpp, c programming regex, cpp vector, cpp string, cpp programming, cpp data, cplusplus vector, cplusplus string, abc programming

Concernant l'employeur :
( 4 commentaires ) tel aviv, Israel

Nº du projet : #8471053

4 freelance font une offre moyenne de $31 pour ce travail

hbxfnzwpf

I am very proficient in java. I have 12 years java developing experience. I have worked for 5 years, my work is online game developing, and mainly focus on server side, the language is java under linux, I am proficint Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(47 Commentaires)
6.0
wrarvw

I have a lot of experience with regular expressions and with C++ and I think I can help you with this. Please describe what exactly do you want to be programmed for you.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(3 Commentaires)
2.7
pinetree800

Hi,sir. I was interested when I saw your project. Because I have a lot of experiences on the fields. My skills are C, C++, Reversing, Matlab & Mathematics, Web scraping,Algorithm. I can help you very kindly. I ca Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(5 Commentaires)
2.3
surfree

A proposal has not yet been provided

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 14 jours
(0 Commentaires)
0.0