Skip to content

Commit 5c8beb2

Browse files
committed
[http] extend test_sniffer.cxx
Add test of multiple invocation of SetTitle in exe.json. Checks that cache works properly
1 parent 88f0726 commit 5c8beb2

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

net/httpsniff/test/test_sniffer.cxx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ TEST(TRootSniffer, set_title)
230230
std::string res;
231231

232232
sniffer.Produce("/obj", "exe.json", "method=SetTitle&title=NewTitle", res);
233-
EXPECT_EQ(res, "null") << "return value of exe.json when methout return void";
233+
EXPECT_EQ(res, "null") << "return value of exe.json when method return void";
234234
EXPECT_EQ(std::string("NewTitle"), obj.GetTitle()) << "compare object title with applied value";
235235

236236
res = "";
@@ -244,9 +244,31 @@ TEST(TRootSniffer, set_title)
244244
EXPECT_EQ(std::string("UrlStyleQuotedTitle"), obj.GetTitle()) << "compare object title with applied value";
245245

246246
res = "";
247-
sniffer.Produce("/obj", "exe.json", "method=SetTitle&title=Mail\"Formed\"Title", res);
247+
sniffer.Produce("/obj", "exe.json", "method=SetTitle&title=Mal\"formed\"title", res);
248248
EXPECT_EQ(res, "null");
249-
EXPECT_EQ(std::string("Mail\"Formed\"Title"), obj.GetTitle()) << "compare object title with applied value";
249+
EXPECT_EQ(std::string("Mal\"formed\"title"), obj.GetTitle()) << "compare object title with applied value";
250+
}
251+
252+
// changing object title many times
253+
TEST(TRootSniffer, many_set_title)
254+
{
255+
TNamed obj("obj", "title");
256+
257+
TRootSnifferFull sniffer("sniffer");
258+
// disable readonly to get method executed
259+
sniffer.SetReadOnly(kFALSE);
260+
261+
sniffer.RegisterObject("/", &obj);
262+
263+
std::string res;
264+
265+
for (int n = 0; n < 1000; ++n) {
266+
std::string new_title = "NewTitle" + std::to_string(n);
267+
268+
sniffer.Produce("/obj", "exe.json", "method=SetTitle&title=" + new_title, res);
269+
EXPECT_EQ(res, "null") << "return value of exe.json when method return void";
270+
EXPECT_EQ(new_title, obj.GetTitle()) << "compare object title with applied value";
271+
}
250272
}
251273

252274
// testing command execution with different signatures

0 commit comments

Comments
 (0)