32 #ifndef CPPSVF_TEST_SVF_H
33 #define CPPSVF_TEST_SVF_H
64 size_t bytes_written = 0;
65 for (
const auto &write_test:
m_writes) {
67 assert(write_test.first < 256);
68 if (write_test.first >= 256) {
69 std::ostringstream os;
70 os <<
"Test file position " << write_test.first;
74 assert(write_test.first + write_test.second < 256);
75 if (write_test.first + write_test.second >= 256) {
76 std::ostringstream os;
77 os <<
"Test file position + size " << write_test.first;
81 svf.
write(write_test.first, data + write_test.first, write_test.second);
82 bytes_written += write_test.second;
116 t_fpos fpos,
size_t len,
const char *data,
const std::string &message);
148 t_fpos fpos,
size_t len,
const std::string &message);
162 t_fpos fpos,
size_t len,
bool expected);
225 t_fpos fpos,
const std::string &message);
Implementation of a Sparse Virtual File.
void write(t_fpos fpos, const char *data, size_t len)
Write the data a the given file position.
Exception used where a test case is miss-configured.
Abstract base class for tests cases.
virtual TestResult run() const =0
virtual ~TestCaseABC()=default
size_t load_writes(SparseVirtualFile &svf, const char *data) const
Load all the specified write seek/write blocks from the data (assumed to be 512 bytes long).
const std::string & test_name() const noexcept
The tests name.
TestCaseABC(const std::string &m_test_name, const t_seek_reads &m_writes)
Specialisation of a test case for erase() on a SVF.
virtual ~TestCaseErase()=default
TestResult run() const override
TestCaseErase(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos)
Specialisation of a test case where erase() on a SVF throws an exception.
TestCaseEraseThrows(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, const std::string &message)
TestResult run() const override
virtual ~TestCaseEraseThrows()=default
Specialisation of a test case for a SVF has() .
virtual ~TestCaseHas()=default
TestCaseHas(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len, bool expected)
TestResult run() const override
Specialisation of a test case for a SVF need() with a greedy length.
TestResult run() const override
virtual ~TestCaseNeedGreedy()=default
TestCaseNeedGreedy(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len, size_t greedy_length, const t_seek_reads &m_need)
Specialisation of a test case for a SVF need() .
TestResult run() const override
virtual ~TestCaseNeed()=default
TestCaseNeed(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len, const t_seek_reads &m_need)
Specialisation of a test case for writing to a SVF.
TestCaseRead(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len)
TestResult run() const override
virtual ~TestCaseRead()=default
Specialisation of a test case where a write to a SVF throws an exception.
virtual ~TestCaseReadThrows()=default
TestResult run() const override
TestCaseReadThrows(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len, const std::string &message)
Specialisation of a test case for writing to a SVF.
virtual ~TestCaseWrite()=default
TestCaseWrite(const std::string &m_test_name, const t_seek_reads &m_writes, const t_seek_reads &m_expected_blocks)
TestResult run() const override
Create a SVF, run the write tests and report the result.
t_seek_reads m_expected_blocks
Specialisation of a test case where a write to a SVF throws an exception.
virtual ~TestCaseWriteThrows()=default
TestResult run() const override
TestCaseWriteThrows(const std::string &m_test_name, const t_seek_reads &m_writes, t_fpos fpos, size_t len, const char *data, const std::string &message)
Count of tests taht pass and fail.
std::vector< TestResult > t_test_results
TestCount test_svf_all(t_test_results &results)
The namespace for all svfsc code.
std::vector< t_seek_read > t_seek_reads