ref: 94bd097fcf7cd8eb45f295b988dd725cca6c6bb1
parent: 0c2227e4b15b488a21a1a62f4d337c0bafb00e09
author: jwwang <jwwang@mozilla.com>
date: Wed Feb 5 13:04:32 EST 2014
minor naming/style/bug fixes
--- a/test/BaseDecoderTest.cpp
+++ b/test/BaseDecoderTest.cpp
@@ -16,7 +16,7 @@
if (file->gcount() != 1) { // end of file
return;
}
- if (!buf->Push(b)) {
+ if (!buf->PushBack(b)) {
FAIL() << "unable to allocate memory";
}
@@ -76,7 +76,7 @@
memset(data, 0, sizeof(data));
memset(&bufInfo, 0, sizeof(SBufferInfo));
- DECODING_STATE rv = decoder_->DecodeFrame(src, sliceSize, data, &bufInfo);
+ DECODING_STATE rv = decoder_->DecodeFrame2(src, sliceSize, data, &bufInfo);
ASSERT_TRUE(rv == dsErrorFree);
if (bufInfo.iBufferStatus == 1 && cbk != NULL) {
@@ -107,7 +107,8 @@
std::ifstream file(fileName, std::ios::in | std::ios::binary);
ASSERT_TRUE(file.is_open());
- for (BufferedData buf;;) {
+ BufferedData buf;
+ while (true) {
ReadFrame(&file, &buf);
if (::testing::Test::HasFatalFailure()) {
return;
--- a/test/decode_encode_test.cpp
+++ b/test/decode_encode_test.cpp
@@ -20,7 +20,7 @@
static void WritePlaneBuffer(BufferedData* buf, const uint8_t* plane,
int width, int height, int stride) {
for (int i = 0; i < height; i++) {
- if (!buf->Push(plane, width)) {
+ if (!buf->PushBack(plane, width)) {
FAIL() << "unable to allocate memory";
}
plane += stride;
@@ -83,7 +83,7 @@
break;
}
}
- return buf_.Pop(static_cast<uint8_t*>(ptr), len);
+ return buf_.PopFront(static_cast<uint8_t*>(ptr), len);
}
protected:
--- a/test/utils/BufferedData.h
+++ b/test/utils/BufferedData.h
@@ -13,7 +13,7 @@
free(data_);
}
- bool Push(uint8_t c) {
+ bool PushBack(uint8_t c) {
if (!EnsureCapacity(length_ + 1)) {
return false;
}
@@ -21,7 +21,7 @@
return true;
}
- bool Push(const uint8_t* data, size_t len) {
+ bool PushBack(const uint8_t* data, size_t len) {
if (!EnsureCapacity(length_ + len)) {
return false;
}
@@ -30,10 +30,10 @@
return true;
}
- size_t Pop(uint8_t* ptr, size_t len) {
+ size_t PopFront(uint8_t* ptr, size_t len) {
len = std::min(length_, len);
memcpy(ptr, data_, len);
- memcpy(data_, data_ + len, length_ - len);
+ memmove(data_, data_ + len, length_ - len);
SetLength(length_ - len);
return len;
}
--- a/test/utils/FileInputStream.h
+++ b/test/utils/FileInputStream.h
@@ -11,8 +11,11 @@
return file_.is_open();
}
int read(void* ptr, size_t len) {
+ if (!file_.good()) {
+ return -1;
+ }
file_.read(static_cast<char*>(ptr), len);
- return file_.eof() ? -1 : file_.gcount();
+ return file_.gcount();
}
private:
std::ifstream file_;