| 1 |
/* |
| 2 |
* Copyright (C) 2017 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include "MockConfig.h" |
| 18 |
|
| 19 |
bool NullOutput::open() noexcept { |
| 20 |
return true; |
| 21 |
} |
| 22 |
bool NullOutput::write(const uint8_t* data, size_t size) noexcept { |
| 23 |
return true; |
| 24 |
} |
| 25 |
std::ostream& NullOutput::getOutputStream() noexcept { |
| 26 |
return mNullStream; |
| 27 |
} |
| 28 |
bool NullOutput::close() noexcept { |
| 29 |
return true; |
| 30 |
} |
| 31 |
|
| 32 |
MockInput::MockInput(uint8_t* data, size_t size) : mSize(size) { |
| 33 |
mData = new uint8_t[size]; |
| 34 |
memcpy(mData, data, size); |
| 35 |
} |
| 36 |
|
| 37 |
ssize_t MockInput::open() noexcept { |
| 38 |
return mSize; |
| 39 |
} |
| 40 |
|
| 41 |
std::unique_ptr<const char[]> MockInput::read() noexcept { |
| 42 |
char* rawBuffer = new char[mSize]; |
| 43 |
memcpy(rawBuffer, mData, mSize); |
| 44 |
return std::unique_ptr<const char[]>(rawBuffer); |
| 45 |
} |
| 46 |
|
| 47 |
bool MockInput::close() noexcept { |
| 48 |
return false; |
| 49 |
} |
| 50 |
|
| 51 |
MockInput::~MockInput() { |
| 52 |
delete mData; |
| 53 |
} |
| 54 |
|
| 55 |
matc::Config::Output* MockConfig::getOutput() const noexcept { |
| 56 |
return nullptr; |
| 57 |
} |
| 58 |
|
| 59 |
matc::Config::Input* MockConfig::getInput() const noexcept { |
| 60 |
return nullptr; |
| 61 |
} |
| 62 |
|
| 63 |
std::string MockConfig::toString() const noexcept { |
| 64 |
return nullptr; |
| 65 |
} |