/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (n <= 0) {
return n;
}
- if (n > count) {
+ if (size_t(n) > count) {
throw std::runtime_error("requested count too small");
}
memcpy(buf, data_.data(), n);
for (auto& p : readers_) {
std::string out(in_.size(), '\0');
EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size()));
- if (p.first != -1) {
+ if (p.first != (typeof(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first));
}
}
for (auto& p : readers_) {
std::string out(in_.size(), '\0');
EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size(), off_t(42)));
- if (p.first != -1) {
+ if (p.first != (typeof(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first));
}
}
auto iov = buf.iov();
EXPECT_EQ(p.first, wrapvFull(p.second, 0, iov.data(), iov.size()));
- if (p.first != -1) {
+ if (p.first != (typeof(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first));
}
}
auto iov = buf.iov();
EXPECT_EQ(p.first,
wrapvFull(p.second, 0, iov.data(), iov.size(), off_t(42)));
- if (p.first != -1) {
+ if (p.first != (typeof(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first));
}
}
unlink(emptyFile.c_str());
};
- auto f = fopen(emptyFile.c_str(), "wb");
- EXPECT_NE(nullptr, f);
- EXPECT_EQ(0, fclose(f));
- f = fopen(afile.c_str(), "wb");
- EXPECT_NE(nullptr, f);
- EXPECT_EQ(3, fwrite("bar", 1, 3, f));
- EXPECT_EQ(0, fclose(f));
+ EXPECT_TRUE(writeFile(string(), emptyFile.c_str()));
+ EXPECT_TRUE(writeFile(StringPiece("bar"), afile.c_str()));
{
string contents;
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
- google::ParseCommandLineFlags(&argc, &argv, true);
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
return RUN_ALL_TESTS();
}