Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3171b32

Browse files
Tests for GalleySeries with unlimited stamp size
1 parentc26a528 commit3171b32

File tree

2 files changed

+76
-7
lines changed

2 files changed

+76
-7
lines changed

‎Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ WRAPPERS_OBJ = pg_op_wrappers.o
1818

1919

2020
.PHONY: all blob-stamper-all blob-stamper-clean clean test
21-
all: blob-stamper-all test_dict$(WRAPPERS_OBJ)
21+
22+
#all: blob-stamper-all test_dict $(WRAPPERS_OBJ)
23+
all: blob-stamper-all$(WRAPPERS_OBJ)
2224
@echo All done!
2325

2426
blob-stamper-all:

‎t/300-galley.cpp‎

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,46 @@
1313

1414
usingnamespaceTAP;
1515

16-
/* Test that dict works as expected*/
16+
classStampTwoCharsList:publicStampGeneric
17+
{
18+
protected:
19+
StampTwoChars el_stamp;
20+
GalleySeries galley;
21+
public:
22+
std::stringExtractStr(Blob &blob)override;
23+
StampTwoCharsList(): el_stamp {}, galley {el_stamp} {};
24+
virtualboolisFixedSize()override {returnfalse;};
25+
virtualintmaxSize()override {return -1;};
26+
virtualintminSize()override {return el_stamp.minSize();};
27+
};
28+
29+
std::string
30+
StampTwoCharsList::ExtractStr(Blob &blob)
31+
{
32+
std::string res ="";
33+
std::list<std::string> list = galley.Extract(blob);
34+
35+
for (std::string point : list)
36+
{
37+
if (!res.empty()) res = res +",";
38+
res = res + point;
39+
}
40+
41+
if (res.empty())return"";
42+
43+
res ="(" + res +")";
44+
return res;
45+
}
46+
1747

1848
char short_sample[]="1234567";
49+
char longer_sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!";
1950

2051
int
2152
main()
2253
{
23-
TEST_START(4);
54+
TEST_START(9);
55+
/* Test Galley Sereies with fixed size stampp*/
2456
{/* 1..4*/
2557
std::string expected1 ="12";
2658
std::string expected2 ="34";
@@ -34,18 +66,53 @@ main()
3466
std::string str;
3567

3668
str = res.front();
37-
ok(str == expected1,"GalleySeries: First element of shifted list is ok");
69+
is(str, expected1,"GalleySeries, fixed size stamp: First element of shifted list is ok");
70+
res.pop_front();
71+
72+
str = res.front();
73+
is(str, expected2,"GalleySeries, fixed size stamp: Second element of shifted list is ok");
74+
res.pop_front();
75+
76+
str = res.front();
77+
is(str, expected3,"GalleySeries, fixed size stamp: Third element of shifted list is ok");
78+
res.pop_front();
79+
80+
ok(res.empty(),"GalleySeries, fixed size stamp: The rest of the list is empty");
81+
}
82+
/* Test Galley Sereies with unlimited size stampp*/
83+
{/* 5 .. 9*/
84+
/* This is not the best test, as we do not predict behavior by setting forged sample values,
85+
but at least here we check that it work the same way it worked before. May be this test should be improved later*/
86+
87+
std::string expected1 ="(9a, bc, de, &f, gh, ij)";
88+
std::string expected2 ="(lm, no, pq, rs, tu, vw, xy)";
89+
std::string expected3 ="(zA, B%, CD, EF, GH, IJ, KL)";
90+
std::string expected4 ="(MN, OP, QR, ST, UV, WX, YZ)";
91+
92+
Blobblob(longer_sample,strlen(longer_sample));
93+
StampTwoCharsList stamp_charlist;
94+
GalleySeriesgalley(stamp_charlist);
95+
96+
std::list<std::string> res = galley.Extract(blob);
97+
std::string str;
98+
99+
str = res.front();
100+
is(str, expected1,"GalleySeries, unlimited size stamp: First element of shifted list is ok");
101+
res.pop_front();
102+
103+
str = res.front();
104+
is(str, expected2,"GalleySeries, unlimited size stamp: Second element of shifted list is ok");
38105
res.pop_front();
39106

40107
str = res.front();
41-
ok(str == expected2,"GalleySeries: Second element of shifted list is ok");
108+
is(str, expected3,"GalleySeries, unlimited size stamp: Third element of shifted list is ok");
42109
res.pop_front();
43110

44111
str = res.front();
45-
ok(str == expected3,"GalleySeries: Third element of shifted list is ok");
112+
is(str, expected4,"GalleySeries, unlimited size stamp: Fourth element of shifted list is ok");
46113
res.pop_front();
47114

48-
ok(res.empty(),"GalleySeries: The rest of the list is empty");
115+
ok(res.empty(),"GalleySeries, unlimited size stamp: The rest of the list is empty");
49116
}
50117

51118
TEST_END;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp