Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1365193, util_gtest: suppress coverity warning, r=kaie
  • Loading branch information
ueno committed May 16, 2017
1 parent e2fbfcd commit bd79273
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions gtests/util_gtest/util_pkcs11uri_unittest.cc
Expand Up @@ -31,13 +31,13 @@ class PK11URITest : public ::testing::Test {
size_t i;
for (i = 0; i < num_pattrs; i++) {
const char *value = PK11URI_GetPathAttribute(tmp.get(), pattrs[i].name);
ASSERT_TRUE(value);
ASSERT_EQ(std::string(value), std::string(pattrs[i].value));
EXPECT_TRUE(value);
if (value) EXPECT_EQ(std::string(value), std::string(pattrs[i].value));
}
for (i = 0; i < num_qattrs; i++) {
const char *value = PK11URI_GetQueryAttribute(tmp.get(), qattrs[i].name);
ASSERT_TRUE(value);
ASSERT_EQ(std::string(value), std::string(qattrs[i].value));
EXPECT_TRUE(value);
if (value) EXPECT_EQ(std::string(value), std::string(qattrs[i].value));
}
}

Expand All @@ -48,8 +48,8 @@ class PK11URITest : public ::testing::Test {
PK11URI_CreateURI(pattrs, num_pattrs, qattrs, num_qattrs));
ASSERT_TRUE(tmp);
char *out = PK11URI_FormatURI(nullptr, tmp.get());
ASSERT_TRUE(out);
ASSERT_EQ(std::string(out), formatted);
EXPECT_TRUE(out);
if (out) EXPECT_EQ(std::string(out), formatted);
PORT_Free(out);
}

Expand All @@ -67,23 +67,25 @@ class PK11URITest : public ::testing::Test {
size_t i;
for (i = 0; i < num_pattrs; i++) {
const char *value = PK11URI_GetPathAttribute(tmp.get(), pattrs[i].name);
ASSERT_TRUE(value);
ASSERT_EQ(std::string(value), std::string(pattrs[i].value));
EXPECT_TRUE(value);
if (value) EXPECT_EQ(std::string(value), std::string(pattrs[i].value));
}
for (i = 0; i < num_qattrs; i++) {
const char *value = PK11URI_GetQueryAttribute(tmp.get(), qattrs[i].name);
ASSERT_TRUE(value);
ASSERT_EQ(std::string(value), std::string(qattrs[i].value));
EXPECT_TRUE(value);
if (value) EXPECT_EQ(std::string(value), std::string(qattrs[i].value));
}
}

void TestParseFormat(const std::string &str, const std::string &formatted) {
ScopedPK11URI tmp(PK11URI_ParseURI(str.c_str()));
ASSERT_TRUE(tmp);
char *out = PK11URI_FormatURI(nullptr, tmp.get());
ASSERT_TRUE(out);
ASSERT_EQ(std::string(out), formatted);
PORT_Free(out);
EXPECT_TRUE(out);
if (out) {
EXPECT_EQ(std::string(out), formatted);
PORT_Free(out);
}
}

protected:
Expand Down

0 comments on commit bd79273

Please sign in to comment.