History

Remove temp files using the iterator pattern

jwwang committed 12 years ago

Commit 0c2227e1 parent 596be028 files · +144 −34Browse files

Showing the changes to test/BaseDecoderTest.cpp (1 of 8 files). Show all

Unified · Split

test/BaseDecoderTest.cpp+40−1
@@ -43,7 +43,8 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) { · 42 unmodified lines
43 }43 }
44}44}
45 45
46BaseDecoderTest::BaseDecoderTest() : decoder_(NULL) {}46BaseDecoderTest::BaseDecoderTest()
47 : decoder_(NULL), decodeStatus_(OpenFile) {}
47 48
48void BaseDecoderTest::SetUp() {49void BaseDecoderTest::SetUp() {
49 long rv = CreateDecoder(&decoder_);50 long rv = CreateDecoder(&decoder_);
@@ -126,3 +127,41 @@ void BaseDecoderTest::DecodeFile(const char* fileName, Callback* cbk) { · 76 unmodified lines
126 // Get pending last frame127 // Get pending last frame
127 DecodeFrame(NULL, 0, cbk);128 DecodeFrame(NULL, 0, cbk);
128}129}
130
131bool BaseDecoderTest::Open(const char* fileName) {
132 if (decodeStatus_ == OpenFile) {
133 file_.open(fileName);
134 if (file_.is_open()) {
135 decodeStatus_ = Decoding;
136 return true;
137 }
138 }
139 return false;
140}
141
142bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) {
143 switch (decodeStatus_) {
144 case Decoding:
145 ReadFrame(&file_, &buf_);
146 if (::testing::Test::HasFatalFailure()) {
147 return false;
148 }
149 if (buf_.Length() == 0) {
150 decodeStatus_ = EndOfStream;
151 return true;
152 }
153 DecodeFrame(buf_.data(), buf_.Length(), cbk);
154 if (::testing::Test::HasFatalFailure()) {
155 return false;
156 }
157 return true;
158 case EndOfStream: {
159 int32_t iEndOfStreamFlag = 1;
160 decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
161 DecodeFrame(NULL, 0, cbk);
162 decodeStatus_ = End;
163 break;
164 }
165 }
166 return false;
167}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t