protected:
BufferTest() : ibuffer(testdata, sizeof(testdata)), obuffer(0),
expected_size(0) {
- data16 = (2 << 8) | 3;
- data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7;
+ data16 = (2U << 8) | 3U;
+ data32 = (4U << 24) | (5U << 16) | (6U << 8) | 7U;
memset(vdata, 0, sizeof(testdata));
}
TEST_F(BufferTest, outputBufferClear) {
obuffer.writeData(testdata, sizeof(testdata));
obuffer.clear();
- ASSERT_EQ(0, obuffer.getLength());
+ ASSERT_EQ(0U, obuffer.getLength());
ASSERT_FALSE(obuffer.getData());
}
TEST_F(BufferTest, outputEmptyBufferCopy) {
ASSERT_NO_THROW({
OutputBuffer copy(obuffer);
- ASSERT_EQ(0, copy.getLength());
+ ASSERT_EQ(0U, copy.getLength());
ASSERT_FALSE(copy.getData());
});
}
TEST_F(BufferTest, outputEmptyBufferAssign) {
OutputBuffer copy(0);
ASSERT_NO_THROW(copy = obuffer;);
- ASSERT_EQ(0, copy.getLength());
- ASSERT_EQ(0, copy.getData());
+ ASSERT_EQ(0U, copy.getLength());
+ ASSERT_EQ(0U, copy.getData());
}
// Check assign to self doesn't break stuff
}
TEST_F(BufferTest, outputBufferExtend) {
- ASSERT_EQ(0, obuffer.getCapacity());
- ASSERT_EQ(0, obuffer.getLength());
+ ASSERT_EQ(0U, obuffer.getCapacity());
+ ASSERT_EQ(0U, obuffer.getLength());
obuffer.writeUint8(10);
- ASSERT_LT(0, obuffer.getCapacity());
- ASSERT_EQ(1, obuffer.getLength());
+ ASSERT_LT(0U, obuffer.getCapacity());
+ ASSERT_EQ(1U, obuffer.getLength());
}
TEST_F(BufferTest, outputBufferSkip) {
obuffer.skip(4);
- ASSERT_EQ(4, obuffer.getLength());
+ ASSERT_EQ(4U, obuffer.getLength());
obuffer.skip(2);
- ASSERT_EQ(6, obuffer.getLength());
+ ASSERT_EQ(6U, obuffer.getLength());
}
TEST_F(BufferTest, outputBufferTrim) {
obuffer.writeData(testdata, sizeof(testdata));
- ASSERT_EQ(5, obuffer.getLength());
+ ASSERT_EQ(5U, obuffer.getLength());
obuffer.trim(1);
- ASSERT_EQ(4, obuffer.getLength());
+ ASSERT_EQ(4U, obuffer.getLength());
obuffer.trim(2);
- ASSERT_EQ(2, obuffer.getLength());
+ ASSERT_EQ(2U, obuffer.getLength());
ASSERT_THROW(obuffer.trim(3), OutOfRange);
}
TEST_F(BufferTest, inputBufferRead) {
- ASSERT_EQ(5, ibuffer.getLength());
- ASSERT_EQ(1, ibuffer.peekUint8());
- ASSERT_EQ(0, ibuffer.getPosition());
- ASSERT_EQ(1, ibuffer.readUint8());
- ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(5U, ibuffer.getLength());
+ ASSERT_EQ(1U, ibuffer.peekUint8());
+ ASSERT_EQ(0U, ibuffer.getPosition());
+ ASSERT_EQ(1U, ibuffer.readUint8());
+ ASSERT_EQ(1U, ibuffer.getPosition());
data16 = ibuffer.peekUint16();
- ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(1U, ibuffer.getPosition());
ASSERT_EQ(data16, ibuffer.readUint16());
- ASSERT_EQ((2 << 8) | 3, data16);
- ASSERT_EQ(3, ibuffer.getPosition());
+ ASSERT_EQ((2U << 8) | 3U, data16);
+ ASSERT_EQ(3U, ibuffer.getPosition());
ibuffer.setPosition(1);
- ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(1U, ibuffer.getPosition());
data32 = ibuffer.peekUint32();
- ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(1U, ibuffer.getPosition());
ASSERT_EQ(data32, ibuffer.readUint32());
- ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32);
+ ASSERT_EQ((2U << 24) | (3U << 16) | (4U << 8) | 5U, data32);
ibuffer.setPosition(0);
memset(vdata, 0, sizeof(vdata));
ibuffer.peekData(vdata, sizeof(vdata));
ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
- ASSERT_EQ(0, ibuffer.getPosition());
+ ASSERT_EQ(0U, ibuffer.getPosition());
memset(vdata, 0, sizeof(vdata));
ibuffer.readData(vdata, sizeof(vdata));
ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
ibuffer.peekVector(datav, sizeof(vdata));
ASSERT_EQ(sizeof(vdata), datav.size());
ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
- ASSERT_EQ(0, ibuffer.getPosition());
+ ASSERT_EQ(0U, ibuffer.getPosition());
datav.clear();
ibuffer.readVector(datav, sizeof(vdata));
ASSERT_EQ(sizeof(vdata), datav.size());
// vector without throwing.
datav.resize(8);
ASSERT_NO_THROW(ibuffer.readVector(datav, 0));
- ASSERT_EQ(datav.size(), 0);
+ ASSERT_EQ(datav.size(), 0U);
}
TEST_F(BufferTest, outputBufferReadAt) {
// check that vector can read the whole buffer
ibuffer.readVector(vec, 3);
- ASSERT_EQ(3, vec.size());
+ ASSERT_EQ(3U, vec.size());
ASSERT_EQ(0, memcmp(&vec[0], testdata, 3));
ASSERT_NO_THROW(ibuffer.readVector(vec, 2));
- ASSERT_EQ(2, vec.size());
+ ASSERT_EQ(2U, vec.size());
ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2));
}
expected_size += sizeof(uint8_t);
ASSERT_EQ(expected_size, obuffer.getLength());
const uint8_t* cp = obuffer.getData();
- ASSERT_EQ(1, *cp);
+ ASSERT_EQ(1U, *cp);
obuffer.writeUint16(data16);
expected_size += sizeof(data16);
cp = obuffer.getData();
ASSERT_EQ(expected_size, obuffer.getLength());
- ASSERT_EQ(2, *(cp + 1));
- ASSERT_EQ(3, *(cp + 2));
+ ASSERT_EQ(2U, *(cp + 1));
+ ASSERT_EQ(3U, *(cp + 2));
obuffer.writeUint32(data32);
expected_size += sizeof(data32);
cp = obuffer.getData();
ASSERT_EQ(expected_size, obuffer.getLength());
- ASSERT_EQ(4, *(cp + 3));
- ASSERT_EQ(5, *(cp + 4));
- ASSERT_EQ(6, *(cp + 5));
- ASSERT_EQ(7, *(cp + 6));
+ ASSERT_EQ(4U, *(cp + 3));
+ ASSERT_EQ(5U, *(cp + 4));
+ ASSERT_EQ(6U, *(cp + 5));
+ ASSERT_EQ(7U, *(cp + 6));
obuffer.writeData(testdata, sizeof(testdata));
expected_size += sizeof(testdata);
obuffer.writeUint8At(4, 1);
ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
const uint8_t* cp = obuffer.getData();
- ASSERT_EQ(4, *(cp + 1));
+ ASSERT_EQ(4U, *(cp + 1));
// overwrite 2nd and 3rd bytes
obuffer.writeUint16At(data16, 1);
ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
cp = obuffer.getData();
- ASSERT_EQ(2, *(cp + 1));
- ASSERT_EQ(3, *(cp + 2));
+ ASSERT_EQ(2U, *(cp + 1));
+ ASSERT_EQ(3U, *(cp + 2));
// overwrite 3rd and 4th bytes
obuffer.writeUint16At(data16, 2);
ASSERT_EQ(expected_size, obuffer.getLength());
cp = obuffer.getData();
- ASSERT_EQ(2, *(cp + 2));
- ASSERT_EQ(3, *(cp + 3));
+ ASSERT_EQ(2U, *(cp + 2));
+ ASSERT_EQ(3U, *(cp + 3));
ASSERT_THROW(obuffer.writeUint8At(data16, 5), isc::OutOfRange);
ASSERT_THROW(obuffer.writeUint8At(data16, 4), isc::OutOfRange);
// This test checks that the single data row is parsed.
TEST(CSVRow, parse) {
CSVRow row0("foo,bar,foo-bar");
- ASSERT_EQ(3, row0.getValuesCount());
+ ASSERT_EQ(3U, row0.getValuesCount());
EXPECT_EQ("foo", row0.readAt(0));
EXPECT_EQ("bar", row0.readAt(1));
EXPECT_EQ("foo-bar", row0.readAt(2));
row0.parse("bar,,foo-bar");
- ASSERT_EQ(3, row0.getValuesCount());
+ ASSERT_EQ(3U, row0.getValuesCount());
EXPECT_EQ("bar", row0.readAt(0));
EXPECT_TRUE(row0.readAt(1).empty());
EXPECT_EQ("foo-bar", row0.readAt(2));
row0.parse("bar,foo,-bar");
- ASSERT_EQ(2, row0.getValuesCount());
+ ASSERT_EQ(2U, row0.getValuesCount());
EXPECT_EQ("bar", row0.readAt(0));
// Read the second column as-is and escaped
EXPECT_EQ("foo,-bar", row0.readAt(1));
EXPECT_EQ("foo,-bar", row0.readAtEscaped(1));
CSVRow row1("foo-bar|foo|bar|", '|');
- ASSERT_EQ(4, row1.getValuesCount());
+ ASSERT_EQ(4U, row1.getValuesCount());
EXPECT_EQ("foo-bar", row1.readAt(0));
EXPECT_EQ("foo", row1.readAt(1));
EXPECT_EQ("bar", row1.readAt(2));
EXPECT_TRUE(row1.readAt(3).empty());
row1.parse("");
- ASSERT_EQ(1, row1.getValuesCount());
+ ASSERT_EQ(1U, row1.getValuesCount());
EXPECT_TRUE(row1.readAt(0).empty());
}
TEST(CSVRow, emptyColumns) {
// Should get four columns, all blank except column the second one.
CSVRow row(",one,,");
- ASSERT_EQ(4, row.getValuesCount());
+ ASSERT_EQ(4U, row.getValuesCount());
EXPECT_EQ("", row.readAt(0));
EXPECT_EQ("one", row.readAt(1));
EXPECT_EQ("", row.readAt(2));
TEST(CSVRow, oneColumn) {
// Should get one column
CSVRow row("zero");
- ASSERT_EQ(1, row.getValuesCount());
+ ASSERT_EQ(1U, row.getValuesCount());
EXPECT_EQ("zero", row.readAt(0));
}
TEST(CSVRow, append) {
CSVRow row(3);
- EXPECT_EQ(3, row.getValuesCount());
+ EXPECT_EQ(3U, row.getValuesCount());
row.writeAt(0, "alpha");
ASSERT_NO_THROW(row.append("delta"));
- EXPECT_EQ(4, row.getValuesCount());
+ EXPECT_EQ(4U, row.getValuesCount());
row.writeAt(1, "beta");
row.writeAt(2, "gamma");
ASSERT_NO_THROW(row.append("epsilon"));
- EXPECT_EQ(5, row.getValuesCount());
+ EXPECT_EQ(5U, row.getValuesCount());
std::string text;
ASSERT_NO_THROW(text = row.render());
// a given number of elements
TEST(CSVRow, trim) {
CSVRow row("zero,one,two,three,four");
- ASSERT_EQ(5, row.getValuesCount());
+ ASSERT_EQ(5U, row.getValuesCount());
EXPECT_EQ("zero", row.readAt(0));
EXPECT_EQ("one", row.readAt(1));
EXPECT_EQ("two", row.readAt(2));
// Verify that we can erase just one
ASSERT_NO_THROW(row.trim(1));
- ASSERT_EQ(4, row.getValuesCount());
+ ASSERT_EQ(4U, row.getValuesCount());
EXPECT_EQ("zero", row.readAt(0));
EXPECT_EQ("one", row.readAt(1));
EXPECT_EQ("two", row.readAt(2));
// Verify we can trim more than one
ASSERT_NO_THROW(row.trim(2));
- ASSERT_EQ(2, row.getValuesCount());
+ ASSERT_EQ(2U, row.getValuesCount());
EXPECT_EQ("zero", row.readAt(0));
EXPECT_EQ("one", row.readAt(1));
}
// Open this file and check that the header is parsed.
boost::scoped_ptr<CSVFile> csv(new CSVFile(testfile_));
ASSERT_NO_THROW(csv->open());
- ASSERT_EQ(3, csv->getColumnCount());
+ ASSERT_EQ(3U, csv->getColumnCount());
EXPECT_EQ("animal", csv->getColumnName(0));
EXPECT_EQ("age", csv->getColumnName(1));
EXPECT_EQ("color", csv->getColumnName(2));
// Read first row.
CSVRow row;
ASSERT_TRUE(csv->next(row));
- ASSERT_EQ(3, row.getValuesCount());
+ ASSERT_EQ(3U, row.getValuesCount());
EXPECT_EQ("cat", row.readAt(0));
EXPECT_EQ("10", row.readAt(1));
EXPECT_EQ("white", row.readAt(2));
// Read second row.
ASSERT_TRUE(csv->next(row));
- ASSERT_EQ(3, row.getValuesCount());
+ ASSERT_EQ(3U, row.getValuesCount());
EXPECT_EQ("lion", row.readAt(0));
EXPECT_EQ("15", row.readAt(1));
EXPECT_EQ("yellow", row.readAt(2));
// Read the first row.
CSVRow row0(0);
ASSERT_NO_THROW(csv->next(row0));
- ASSERT_EQ(3, row0.getValuesCount());
+ ASSERT_EQ(3U, row0.getValuesCount());
EXPECT_EQ("cat", row0.readAt(0));
EXPECT_EQ("10", row0.readAt(1));
EXPECT_EQ("white", row0.readAt(2));
// Open this file and check that the header is parsed.
CSVFile csv(testfile_);
ASSERT_NO_THROW(csv.open());
- ASSERT_EQ(3, csv.getColumnCount());
+ ASSERT_EQ(3U, csv.getColumnCount());
EXPECT_EQ("animal", csv.getColumnName(0));
EXPECT_EQ("age", csv.getColumnName(1));
EXPECT_EQ("color", csv.getColumnName(2));
// Open this file and check that the header is parsed.
CSVFile csv(testfile_);
ASSERT_NO_THROW(csv.open());
- ASSERT_EQ(3, csv.getColumnCount());
+ ASSERT_EQ(3U, csv.getColumnCount());
EXPECT_EQ("animal", csv.getColumnName(0));
EXPECT_EQ("age", csv.getColumnName(1));
EXPECT_EQ("color", csv.getColumnName(2));
// Open this file and check that the header is parsed.
CSVFile csv(testfile_);
ASSERT_NO_THROW(csv.open());
- ASSERT_EQ(3, csv.getColumnCount());
+ ASSERT_EQ(3U, csv.getColumnCount());
EXPECT_EQ("animal", csv.getColumnName(0));
EXPECT_EQ("age", csv.getColumnName(1));
EXPECT_EQ("color", csv.getColumnName(2));
auto pad_char = encoder_->getPadChar();
// Ensure the bit table is the proper size.
- ASSERT_EQ(encoder_->getBitsTable().size(), 256);
+ ASSERT_EQ(encoder_->getBitsTable().size(), 256U);
// Iterate over the whole ASCII character set:
// 1. Convert the ASCII value to its encoded binary bit value.
EXPECT_EQ(valid_digits, num_digits);
// Verify that all of the ASCII values are accounted for.
- EXPECT_EQ((valid_digits + upper_cased + whitespaces + bad_chars + pad_chars), 256)
+ EXPECT_EQ((valid_digits + upper_cased + whitespaces + bad_chars + pad_chars), 256U)
<< " : " << valid_digits
<< " + " << upper_cased
<< " + " << whitespaces
ASSERT_GE(0, result) << "error: " << strerror(errno);
}
fds.push_back(pipe_fd[0]);
- EXPECT_EQ(sizeof(i), write(pipe_fd[1], &i, sizeof(i)));
+ EXPECT_EQ(static_cast<int>(sizeof(i)),
+ write(pipe_fd[1], &i, sizeof(i)));
fds.push_back(pipe_fd[1]);
EXPECT_NO_THROW(handler_->add(pipe_fd[0]));
}
- EXPECT_EQ(limit, handler_->waitEvent(0, 1000));
+ EXPECT_EQ(static_cast<int>(limit), handler_->waitEvent(0, 1000));
for (size_t i = 0; i < fds.size(); i += 2) {
bool ready = handler_->readReady(fds[i]);
EXPECT_TRUE(ready);
EXPECT_FALSE(handler_->hasError(fds[i]));
size_t data = 0;
if (ready) {
- EXPECT_EQ(sizeof(i), read(fds[i], &data, sizeof(data)));
+ EXPECT_EQ(static_cast<int>(sizeof(i)),
+ read(fds[i], &data, sizeof(data)));
}
EXPECT_EQ(data, i / 2);
close(fds[i]);
ASSERT_GE(feeder, 0);
ssize_t received(read_data(read_pipe, buffer, TEST_DATA_SIZE));
EXPECT_TRUE(process_ok(feeder));
- EXPECT_EQ(TEST_DATA_SIZE, received);
+ EXPECT_EQ(TEST_DATA_SIZE, static_cast<size_t>(received));
EXPECT_EQ(0, memcmp(data, buffer, received));
}
}
/// @brief Verifies that the thread pool size setter works.
TEST_F(MultiThreadingMgrTest, threadPoolSize) {
// default thread count is 0
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 0);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 0U);
// set thread count to 16
EXPECT_NO_THROW(MultiThreadingMgr::instance().setThreadPoolSize(16));
// thread count should be 16
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 16);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 16U);
// set thread count to 0
EXPECT_NO_THROW(MultiThreadingMgr::instance().setThreadPoolSize(0));
// thread count should be 0
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 0);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPoolSize(), 0U);
}
/// @brief Verifies that the packet queue size setter works.
TEST_F(MultiThreadingMgrTest, packetQueueSize) {
// default queue size is 0
- EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 0);
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 0);
+ EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 0U);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 0U);
// set queue size to 16
EXPECT_NO_THROW(MultiThreadingMgr::instance().setPacketQueueSize(16));
// queue size should be 16
- EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 16);
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 16);
+ EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 16U);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 16U);
// set queue size to 0
EXPECT_NO_THROW(MultiThreadingMgr::instance().setPacketQueueSize(0));
// queue size should be 0
- EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 0);
- EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 0);
+ EXPECT_EQ(MultiThreadingMgr::instance().getPacketQueueSize(), 0U);
+ EXPECT_EQ(MultiThreadingMgr::instance().getThreadPool().getMaxQueueSize(), 0U);
}
/// @brief Verifies that detecting thread count works.
TEST_F(MultiThreadingMgrTest, detectThreadCount) {
// detecting thread count should work
- EXPECT_NE(MultiThreadingMgr::detectThreadCount(), 0);
+ EXPECT_NE(MultiThreadingMgr::detectThreadCount(), 0U);
}
/// @brief Verifies that apply settings works.
// get the thread pool instance
auto& thread_pool = MultiThreadingMgr::instance().getThreadPool();
// thread pool should be stopped
- EXPECT_EQ(thread_pool.size(), 0);
+ EXPECT_EQ(thread_pool.size(), 0U);
// Add two sets of CriticalSection call backs.
MultiThreadingMgr::instance().addCriticalSectionCallbacks("oneAndTwo",
// get the thread pool instance
auto& thread_pool = MultiThreadingMgr::instance().getThreadPool();
// thread pool should be stopped
- EXPECT_EQ(thread_pool.size(), 0);
+ EXPECT_EQ(thread_pool.size(), 0U);
// Apply multi-threading configuration with 16 threads and queue size 256.
MultiThreadingMgr::instance().apply(true, 16, 256);
StopwatchMock stopwatch(ref_time_);
// The stopwatch shouldn't automatically start. The initial
// durations should be set to 0.
- EXPECT_EQ(0, stopwatch.getLastDurationInMs());
- EXPECT_EQ(0, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getTotalDurationInMs());
stopwatch.start();
// Even though the stopwatch is started, the time is still set to
// the initial value. The durations should not be affected.
- EXPECT_EQ(0, stopwatch.getLastDurationInMs());
- EXPECT_EQ(0, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getTotalDurationInMs());
// Move the time by 10 ms.
stopwatch.ffwd(10);
// It should be possible to retrieve the durations even when the
// stopwatch is running.
- EXPECT_EQ(10, stopwatch.getLastDurationInMs());
- EXPECT_EQ(10, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(10U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(10U, stopwatch.getTotalDurationInMs());
// Now stop it and make sure that the same values are returned.
stopwatch.stop();
- EXPECT_EQ(10, stopwatch.getLastDurationInMs());
- EXPECT_EQ(10, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(10U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(10U, stopwatch.getTotalDurationInMs());
// Start it again, but don't move the time forward yet.
stopwatch.start();
// The new duration should be 0, but the total should be equal to
// the previously measured duration.
- EXPECT_EQ(0, stopwatch.getLastDurationInMs());
- EXPECT_EQ(10, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(10U, stopwatch.getTotalDurationInMs());
// Move time by 5 ms.
stopwatch.ffwd(5);
// New measured duration should be 5 ms. The total should be 15 ms.
- EXPECT_EQ(5, stopwatch.getLastDurationInMs());
- EXPECT_EQ(15, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(5U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(15U, stopwatch.getTotalDurationInMs());
// Stop it again and make sure the values returned are the same.
stopwatch.stop();
- EXPECT_EQ(5, stopwatch.getLastDurationInMs());
- EXPECT_EQ(15, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(5U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(15U, stopwatch.getTotalDurationInMs());
// Move the time forward while the stopwatch is stopped.
stopwatch.ffwd(8);
// The measured values should not be affected.
- EXPECT_EQ(5, stopwatch.getLastDurationInMs());
- EXPECT_EQ(15, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(5U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(15U, stopwatch.getTotalDurationInMs());
// Stop should be no-op in this case.
stopwatch.stop();
- EXPECT_EQ(5, stopwatch.getLastDurationInMs());
- EXPECT_EQ(15, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(5U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(15U, stopwatch.getTotalDurationInMs());
// Start the stopwatch again.
stopwatch.start();
// Since the stopwatch is running, the measured duration should
// get updated again.
- EXPECT_EQ(3, stopwatch.getLastDurationInMs());
- EXPECT_EQ(18, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(3U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(18U, stopwatch.getTotalDurationInMs());
// Move the time by 2 ms.
stopwatch.ffwd(2);
stopwatch.start();
// But the durations should be updated.
- EXPECT_EQ(5, stopwatch.getLastDurationInMs());
- EXPECT_EQ(20, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(5U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(20U, stopwatch.getTotalDurationInMs());
// Make sure we can reset.
stopwatch.reset();
- EXPECT_EQ(0, stopwatch.getLastDurationInMs());
- EXPECT_EQ(0, stopwatch.getTotalDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getLastDurationInMs());
+ EXPECT_EQ(0U, stopwatch.getTotalDurationInMs());
}
// This test checks that the stopwatch works when the real clock is in use.
// Degenerate cases
result = tokens(""); // Empty string
- EXPECT_EQ(0, result.size());
+ EXPECT_EQ(0U, result.size());
result = tokens(" \n "); // String is all delimiters
- EXPECT_EQ(0, result.size());
+ EXPECT_EQ(0U, result.size());
result = tokens("abc"); // String has no delimiters
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("abc"), result[0]);
// String containing leading and/or trailing delimiters, no embedded ones.
result = tokens("\txyz"); // One leading delimiter
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("xyz"), result[0]);
result = tokens("\t \nxyz"); // Multiple leading delimiters
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("xyz"), result[0]);
result = tokens("xyz\n"); // One trailing delimiter
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("xyz"), result[0]);
result = tokens("xyz \t"); // Multiple trailing
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("xyz"), result[0]);
result = tokens("\t xyz \n"); // Leading and trailing
- ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1U, result.size());
EXPECT_EQ(string("xyz"), result[0]);
// Embedded delimiters
result = tokens("abc\ndef"); // 2 tokens, one separator
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
result = tokens("abc\t\t\ndef"); // 2 tokens, 3 separators
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
result = tokens("abc\n \tdef\t\tghi");
- ASSERT_EQ(3, result.size()); // Multiple tokens, many delims
+ ASSERT_EQ(3U, result.size()); // Multiple tokens, many delims
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
EXPECT_EQ(string("ghi"), result[2]);
// Embedded and non-embedded delimiters
result = tokens("\t\t \nabc\n \tdef\t\tghi \n\n");
- ASSERT_EQ(3, result.size()); // Multiple tokens, many delims
+ ASSERT_EQ(3U, result.size()); // Multiple tokens, many delims
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
EXPECT_EQ(string("ghi"), result[2]);
// Non-default delimiter
result = tokens("alpha/beta/ /gamma//delta/epsilon/", "/");
- ASSERT_EQ(6, result.size());
+ ASSERT_EQ(6U, result.size());
EXPECT_EQ(string("alpha"), result[0]);
EXPECT_EQ(string("beta"), result[1]);
EXPECT_EQ(string(" "), result[2]);
// Non-default delimiters (plural)
result = tokens("+*--alpha*beta+ -gamma**delta+epsilon-+**", "*+-");
- ASSERT_EQ(6, result.size());
+ ASSERT_EQ(6U, result.size());
EXPECT_EQ(string("alpha"), result[0]);
EXPECT_EQ(string("beta"), result[1]);
EXPECT_EQ(string(" "), result[2]);
// Escaped delimiter
result = tokens("foo\\,bar", ",", true);
- EXPECT_EQ(1, result.size());
+ EXPECT_EQ(1U, result.size());
EXPECT_EQ(string("foo,bar"), result[0]);
// Escaped escape
result = tokens("foo\\\\,bar", ",", true);
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("foo\\"), result[0]);
EXPECT_EQ(string("bar"), result[1]);
// Double escapes
result = tokens("foo\\\\\\\\,\\bar", ",", true);
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("foo\\\\"), result[0]);
EXPECT_EQ(string("\\bar"), result[1]);
// Escaped standard character
result = tokens("fo\\o,bar", ",", true);
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("fo\\o"), result[0]);
EXPECT_EQ(string("bar"), result[1]);
// Escape at the end
result = tokens("foo,bar\\", ",", true);
- ASSERT_EQ(2, result.size());
+ ASSERT_EQ(2U, result.size());
EXPECT_EQ(string("foo"), result[0]);
EXPECT_EQ(string("bar\\"), result[1]);
// Escape opening a token
result = tokens("foo,\\,,bar", ",", true);
- ASSERT_EQ(3, result.size());
+ ASSERT_EQ(3U, result.size());
EXPECT_EQ(string("foo"), result[0]);
EXPECT_EQ(string(","), result[1]);
EXPECT_EQ(string("bar"), result[2]);
CallBack call_back;
ThreadPool<CallBack> thread_pool;
// the item count should be 0
- ASSERT_EQ(thread_pool.count(), 0);
+ ASSERT_EQ(thread_pool.count(), 0U);
// the thread count should be 0
- ASSERT_EQ(thread_pool.size(), 0);
+ ASSERT_EQ(thread_pool.size(), 0U);
items_count = 20;
ASSERT_EQ(thread_pool.count(), items_count);
// change the max count
- ASSERT_EQ(thread_pool.getMaxQueueSize(), 0);
+ ASSERT_EQ(thread_pool.getMaxQueueSize(), 0U);
size_t max_queue_size = 10;
thread_pool.setMaxQueueSize(max_queue_size);
EXPECT_EQ(thread_pool.getMaxQueueSize(), max_queue_size);
CallBack call_back;
ThreadPool<CallBack> thread_pool;
// the item count should be 0
- ASSERT_EQ(thread_pool.count(), 0);
+ ASSERT_EQ(thread_pool.count(), 0U);
// the thread count should be 0
- ASSERT_EQ(thread_pool.size(), 0);
+ ASSERT_EQ(thread_pool.size(), 0U);
items_count = 20;
ASSERT_EQ(thread_pool.count(), items_count);
// change the max count
- ASSERT_EQ(thread_pool.getMaxQueueSize(), 0);
+ ASSERT_EQ(thread_pool.getMaxQueueSize(), 0U);
size_t max_queue_size = 10;
thread_pool.setMaxQueueSize(max_queue_size);
EXPECT_EQ(thread_pool.getMaxQueueSize(), max_queue_size);
// requesting a value from within the range (min < x < max) should
// return the requested value
- EXPECT_EQ(17, x.get(17));
+ EXPECT_EQ(17U, x.get(17));
EXPECT_EQ(max, x.get(max));
// this will be boring. It is expected to return 42 no matter what
Triplet<uint32_t> y(42);
- EXPECT_EQ(42, y.getMin()); // min, default and max are equal to 42
- EXPECT_EQ(42, y.get()); // it returns ...
- EXPECT_EQ(42, y.getMax()); // the exact value...
+ EXPECT_EQ(42U, y.getMin()); // min, default and max are equal to 42
+ EXPECT_EQ(42U, y.get()); // it returns ...
+ EXPECT_EQ(42U, y.getMax()); // the exact value...
EXPECT_FALSE(x.unspecified());
// requested values below or above are ignore
- EXPECT_EQ(42, y.get(5)); // all...
- EXPECT_EQ(42, y.get(42)); // the...
- EXPECT_EQ(42, y.get(80)); // time!
+ EXPECT_EQ(42U, y.get(5)); // all...
+ EXPECT_EQ(42U, y.get(42)); // the...
+ EXPECT_EQ(42U, y.get(80)); // time!
}
TEST(TripletTest, unspecified) {
Triplet<uint32_t> x;
// When using the constructor without parameters, the triplet
// value is unspecified.
- EXPECT_EQ(0, x.getMin());
- EXPECT_EQ(0, x.get());
- EXPECT_EQ(0, x.getMax());
+ EXPECT_EQ(0U, x.getMin());
+ EXPECT_EQ(0U, x.get());
+ EXPECT_EQ(0U, x.getMax());
EXPECT_TRUE(x.unspecified());
// For the triplet which has unspecified value we can call accessors
x = 72;
// Check if the new value has been assigned.
- EXPECT_EQ(72, x.getMin());
- EXPECT_EQ(72, x.get());
- EXPECT_EQ(72, x.getMax());
+ EXPECT_EQ(72U, x.getMin());
+ EXPECT_EQ(72U, x.get());
+ EXPECT_EQ(72U, x.getMax());
// Triplet is now specified.
EXPECT_FALSE(x.unspecified());
}
foo = bar;
- EXPECT_EQ(4, foo.getMin());
- EXPECT_EQ(5, foo.get());
- EXPECT_EQ(6, foo.getMax());
+ EXPECT_EQ(4U, foo.getMin());
+ EXPECT_EQ(5U, foo.get());
+ EXPECT_EQ(6U, foo.getMax());
EXPECT_FALSE(foo.unspecified());
// assignment operator: uint32_t => triplet
// Input Header should match defined columns on new files
// Valid columns should match defined columns on new files
// Minimum valid columns wasn't set. (Remember it's optional)
- EXPECT_EQ(3, csv->getColumnCount());
- EXPECT_EQ(3, csv->getInputHeaderCount());
- EXPECT_EQ(3, csv->getValidColumnCount());
- EXPECT_EQ(0, csv->getMinimumValidColumns());
+ EXPECT_EQ(3U, csv->getColumnCount());
+ EXPECT_EQ(3U, csv->getInputHeaderCount());
+ EXPECT_EQ(3U, csv->getValidColumnCount());
+ EXPECT_EQ(0U, csv->getMinimumValidColumns());
// Schema versions for new files should always match
EXPECT_EQ("3.0", csv->getInputSchemaVersion());
// 3 columns total found in the header
// 3 valid columns found in the header
// Minimum valid columns wasn't set. (Remember it's optional)
- EXPECT_EQ(3, csv->getColumnCount());
- EXPECT_EQ(3, csv->getInputHeaderCount());
- EXPECT_EQ(3, csv->getValidColumnCount());
- EXPECT_EQ(0, csv->getMinimumValidColumns());
+ EXPECT_EQ(3U, csv->getColumnCount());
+ EXPECT_EQ(3U, csv->getInputHeaderCount());
+ EXPECT_EQ(3U, csv->getValidColumnCount());
+ EXPECT_EQ(0U, csv->getMinimumValidColumns());
// Input schema and current schema should both be 2.0
EXPECT_EQ("2.0", csv->getInputSchemaVersion());
// 1 column found in the header
// 1 valid column in the header
// Minimum valid columns wasn't set. (Remember it's optional)
- EXPECT_EQ(2, csv->getColumnCount());
- EXPECT_EQ(1, csv->getInputHeaderCount());
- EXPECT_EQ(1, csv->getValidColumnCount());
- EXPECT_EQ(0, csv->getMinimumValidColumns());
+ EXPECT_EQ(2U, csv->getColumnCount());
+ EXPECT_EQ(1U, csv->getInputHeaderCount());
+ EXPECT_EQ(1U, csv->getValidColumnCount());
+ EXPECT_EQ(0U, csv->getMinimumValidColumns());
// Input schema should be 1.0, while our current schema should be 2.0
EXPECT_EQ("1.0", csv->getInputSchemaVersion());
// Create a third schema by adding a column
ASSERT_NO_THROW(csv->addColumn("age", "3.0", "21"));
- ASSERT_EQ(3, csv->getColumnCount());
+ ASSERT_EQ(3U, csv->getColumnCount());
// Header should pass validation and allow the open to succeed
ASSERT_NO_THROW(csv->open());
// 1 column found in the header
// 1 valid column in the header
// Minimum valid columns wasn't set. (Remember it's optional)
- EXPECT_EQ(3, csv->getColumnCount());
- EXPECT_EQ(1, csv->getInputHeaderCount());
- EXPECT_EQ(1, csv->getValidColumnCount());
- EXPECT_EQ(0, csv->getMinimumValidColumns());
+ EXPECT_EQ(3U, csv->getColumnCount());
+ EXPECT_EQ(1U, csv->getInputHeaderCount());
+ EXPECT_EQ(1U, csv->getValidColumnCount());
+ EXPECT_EQ(0U, csv->getMinimumValidColumns());
// Make sure schema versions are accurate
EXPECT_EQ("1.0", csv->getInputSchemaVersion());
// Set the minimum number of columns to "color"
csv->setMinimumValidColumns("color");
- EXPECT_EQ(2, csv->getMinimumValidColumns());
+ EXPECT_EQ(2U, csv->getMinimumValidColumns());
// Header validation should fail, too few columns
ASSERT_THROW(csv->open(), CSVFileError);
// Set the minimum number of columns to 1. File should parse now.
csv->setMinimumValidColumns("animal");
- EXPECT_EQ(1, csv->getMinimumValidColumns());
+ EXPECT_EQ(1U, csv->getMinimumValidColumns());
ASSERT_NO_THROW(csv->open());
// First row is correct.
// 3 columns found in the header
// 2 valid columns in the header
// Minimum valid columns wasn't set. (Remember it's optional)
- EXPECT_EQ(2, csv->getColumnCount());
- EXPECT_EQ(3, csv->getInputHeaderCount());
- EXPECT_EQ(2, csv->getValidColumnCount());
- EXPECT_EQ(0, csv->getMinimumValidColumns());
+ EXPECT_EQ(2U, csv->getColumnCount());
+ EXPECT_EQ(3U, csv->getInputHeaderCount());
+ EXPECT_EQ(2U, csv->getValidColumnCount());
+ EXPECT_EQ(0U, csv->getMinimumValidColumns());
// Input schema and current schema should both be 2.0
EXPECT_EQ("2.0", csv->getInputSchemaVersion());
/// Verify that we have exactly one marker waiting to be read.
int count = 0;
EXPECT_FALSE(ioctl(select_fd, FIONREAD, &count));
- EXPECT_EQ(sizeof(WatchSocket::MARKER), count);
+ EXPECT_EQ(static_cast<int>(sizeof(WatchSocket::MARKER)), count);
/// Verify that we can call markReady again without error.
ASSERT_NO_THROW(watch->markReady());
/// Verify that we STILL have exactly one marker waiting to be read.
EXPECT_FALSE(ioctl(select_fd, FIONREAD, &count));
- EXPECT_EQ(sizeof(WatchSocket::MARKER), count);
+ EXPECT_EQ(static_cast<int>(sizeof(WatchSocket::MARKER)), count);
/// Verify that isReady() is true and that a call to select agrees.
EXPECT_TRUE(watch->isReady());
// Interfere by reading the fd. This should empty the read pipe.
uint32_t buf = 0;
- ASSERT_EQ((read (select_fd, &buf, sizeof(buf))), sizeof(buf));
+ ASSERT_EQ((read (select_fd, &buf, sizeof(buf))),
+ static_cast<int>(sizeof(buf)));
ASSERT_EQ(WatchSocket::MARKER, buf);
// Really nothing that can be done to protect against this, but let's