Commit 9cec466e authored by gejun's avatar gejun

fix UT warning on clang

parent b5900a38
...@@ -23,7 +23,7 @@ TEST_F(HPackTest, header_with_indexing) { ...@@ -23,7 +23,7 @@ TEST_F(HPackTest, header_with_indexing) {
options.index_policy = brpc::HPACK_INDEX_HEADER; options.index_policy = brpc::HPACK_INDEX_HEADER;
butil::IOBufAppender buf; butil::IOBufAppender buf;
p1.Encode(&buf, h, options); p1.Encode(&buf, h, options);
const size_t nwrite = buf.buf().size(); const ssize_t nwrite = buf.buf().size();
LOG(INFO) << butil::ToPrintable(buf.buf()); LOG(INFO) << butil::ToPrintable(buf.buf());
uint8_t expected[] = { uint8_t expected[] = {
0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79, 0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79,
...@@ -53,7 +53,7 @@ TEST_F(HPackTest, header_without_indexing) { ...@@ -53,7 +53,7 @@ TEST_F(HPackTest, header_without_indexing) {
options.index_policy = brpc::HPACK_NOT_INDEX_HEADER; options.index_policy = brpc::HPACK_NOT_INDEX_HEADER;
butil::IOBufAppender buf; butil::IOBufAppender buf;
p1.Encode(&buf, h, options); p1.Encode(&buf, h, options);
const size_t nwrite = buf.buf().size(); const ssize_t nwrite = buf.buf().size();
LOG(INFO) << butil::ToPrintable(buf.buf()); LOG(INFO) << butil::ToPrintable(buf.buf());
uint8_t expected[] = { uint8_t expected[] = {
0x04, 0x0c, 0x2f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x61, 0x04, 0x0c, 0x2f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x61,
...@@ -83,7 +83,7 @@ TEST_F(HPackTest, header_never_indexed) { ...@@ -83,7 +83,7 @@ TEST_F(HPackTest, header_never_indexed) {
options.index_policy = brpc::HPACK_NEVER_INDEX_HEADER; options.index_policy = brpc::HPACK_NEVER_INDEX_HEADER;
butil::IOBufAppender buf; butil::IOBufAppender buf;
p1.Encode(&buf, h, options); p1.Encode(&buf, h, options);
const size_t nwrite = buf.buf().size(); const ssize_t nwrite = buf.buf().size();
LOG(INFO) << butil::ToPrintable(buf.buf()); LOG(INFO) << butil::ToPrintable(buf.buf());
uint8_t expected[] = { uint8_t expected[] = {
0x10, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
......
...@@ -493,7 +493,7 @@ public: ...@@ -493,7 +493,7 @@ public:
if (_done_place == DONE_BEFORE_CREATE_PA) { if (_done_place == DONE_BEFORE_CREATE_PA) {
done_guard.reset(NULL); done_guard.reset(NULL);
} }
ASSERT_GT(PA_DATA_LEN, 8); // long enough to hold a 64-bit decimal. ASSERT_GT(PA_DATA_LEN, 8u); // long enough to hold a 64-bit decimal.
char buf[PA_DATA_LEN]; char buf[PA_DATA_LEN];
for (size_t c = 0; c < _nrep;) { for (size_t c = 0; c < _nrep;) {
CopyPAPrefixedWithSeqNo(buf, c); CopyPAPrefixedWithSeqNo(buf, c);
......
...@@ -596,7 +596,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { ...@@ -596,7 +596,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) {
// There are 3 valid servers with weight 3, 2 and 7 respectively. // There are 3 valid servers with weight 3, 2 and 7 respectively.
// We run SelectServer for 12 times. The result number of each server seleted should be // We run SelectServer for 12 times. The result number of each server seleted should be
// consistent with weight configured. // consistent with weight configured.
std::map<butil::EndPoint, size_t> select_result; std::map<butil::EndPoint, int> select_result;
brpc::SocketUniquePtr ptr; brpc::SocketUniquePtr ptr;
brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
brpc::LoadBalancer::SelectOut out(&ptr); brpc::LoadBalancer::SelectOut out(&ptr);
...@@ -613,7 +613,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { ...@@ -613,7 +613,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) {
} }
std::cout << std::endl; std::cout << std::endl;
// Check whether slected result is consistent with expected. // Check whether slected result is consistent with expected.
EXPECT_EQ(3, select_result.size()); EXPECT_EQ((size_t)3, select_result.size());
for (const auto& result : select_result) { for (const auto& result : select_result) {
std::cout << result.first << " result=" << result.second std::cout << result.first << " result=" << result.second
<< " configured=" << configed_weight[result.first] << std::endl; << " configured=" << configed_weight[result.first] << std::endl;
......
...@@ -38,7 +38,7 @@ TEST(URITest, only_host) { ...@@ -38,7 +38,7 @@ TEST(URITest, only_host) {
ASSERT_EQ("", uri.path()); ASSERT_EQ("", uri.path());
ASSERT_EQ("", uri.user_info()); ASSERT_EQ("", uri.user_info());
ASSERT_EQ("", uri.fragment()); ASSERT_EQ("", uri.fragment());
ASSERT_EQ(2, uri.QueryCount()); ASSERT_EQ(2u, uri.QueryCount());
ASSERT_TRUE(uri.GetQuery("wd")); ASSERT_TRUE(uri.GetQuery("wd"));
ASSERT_EQ(*uri.GetQuery("wd"), "uri2"); ASSERT_EQ(*uri.GetQuery("wd"), "uri2");
ASSERT_TRUE(uri.GetQuery("nonkey")); ASSERT_TRUE(uri.GetQuery("nonkey"));
......
...@@ -290,7 +290,7 @@ TEST_F(IOBufTest, reserve) { ...@@ -290,7 +290,7 @@ TEST_F(IOBufTest, reserve) {
ASSERT_EQ((size_t)16, b.size()); ASSERT_EQ((size_t)16, b.size());
// pop/append sth. from back-side and assign again. // pop/append sth. from back-side and assign again.
ASSERT_EQ(5, b.pop_back(5)); ASSERT_EQ((size_t)5, b.pop_back(5));
ASSERT_EQ("prefihello ", b.to_string()); ASSERT_EQ("prefihello ", b.to_string());
b.append("blahblahfoobar"); b.append("blahblahfoobar");
ASSERT_EQ(0, b.unsafe_assign(a1, "goodorbad")); // `x' will not be copied ASSERT_EQ(0, b.unsafe_assign(a1, "goodorbad")); // `x' will not be copied
...@@ -1312,7 +1312,7 @@ TEST_F(IOBufTest, append_from_fd_with_offset) { ...@@ -1312,7 +1312,7 @@ TEST_F(IOBufTest, append_from_fd_with_offset) {
ASSERT_EQ((ssize_t)sizeof(dummy), buf.cut_into_file_descriptor(fd)); ASSERT_EQ((ssize_t)sizeof(dummy), buf.cut_into_file_descriptor(fd));
for (size_t i = 0; i < sizeof(dummy); ++i) { for (size_t i = 0; i < sizeof(dummy); ++i) {
butil::IOPortal b0; butil::IOPortal b0;
ASSERT_EQ(sizeof(dummy) - i, b0.pappend_from_file_descriptor(fd, i, sizeof(dummy))) << berror(); ASSERT_EQ(sizeof(dummy) - i, (size_t)b0.pappend_from_file_descriptor(fd, i, sizeof(dummy))) << berror();
char tmp[sizeof(dummy)]; char tmp[sizeof(dummy)];
ASSERT_EQ(0, memcmp(dummy + i, b0.fetch(tmp, b0.length()), b0.length())); ASSERT_EQ(0, memcmp(dummy + i, b0.fetch(tmp, b0.length()), b0.length()));
} }
......
...@@ -139,7 +139,7 @@ TEST_F(TempFileTest, save_binary_twice) ...@@ -139,7 +139,7 @@ TEST_F(TempFileTest, save_binary_twice)
fp = fopen(tmp.fname(), "r"); fp = fopen(tmp.fname(), "r");
ASSERT_NE((void*)0, fp); ASSERT_NE((void*)0, fp);
bzero(&act_data, sizeof(act_data)); bzero(&act_data, sizeof(act_data));
ASSERT_EQ(1, fread(&act_data, sizeof(act_data), 1, fp)); ASSERT_EQ((size_t)1, fread(&act_data, sizeof(act_data), 1, fp));
fclose(fp); fclose(fp);
ASSERT_EQ(0, memcmp(&data2, &act_data, sizeof(data2))); ASSERT_EQ(0, memcmp(&data2, &act_data, sizeof(data2)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment