2018-02-18 01:50:24 -08:00
|
|
|
#include "test.hpp"
|
2019-10-19 03:28:21 -07:00
|
|
|
|
|
|
|
#include <athena/MemoryWriter.hpp>
|
|
|
|
#include <fmt/format.h>
|
2018-02-18 01:50:24 -08:00
|
|
|
|
2018-03-03 20:24:11 -08:00
|
|
|
#define EXPECTED_BYTES 281
|
2018-02-18 01:50:24 -08:00
|
|
|
|
2018-12-07 21:18:17 -08:00
|
|
|
int main(int argc, const char** argv) {
|
|
|
|
TESTFile<atUint32, 2> file = {};
|
|
|
|
file.arrCount[0] = 2;
|
|
|
|
file.array.push_back(42);
|
|
|
|
file.array.push_back(64);
|
|
|
|
size_t binSize = 0;
|
|
|
|
file.binarySize(binSize);
|
|
|
|
athena::io::MemoryCopyWriter w(nullptr, binSize);
|
|
|
|
atInt64 pos = w.position();
|
|
|
|
file.write(w);
|
2019-10-19 03:28:21 -07:00
|
|
|
|
|
|
|
const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES;
|
|
|
|
if (pass) {
|
2020-04-11 15:46:42 -07:00
|
|
|
fmt::print(FMT_STRING("[PASS] {} bytes written\n"), size_t(w.position() - pos));
|
2019-10-19 03:28:21 -07:00
|
|
|
} else {
|
2020-04-11 15:46:42 -07:00
|
|
|
fmt::print(FMT_STRING("[FAIL] {} bytes written; {} bytes sized; {} bytes expected\n"), size_t(w.position() - pos), binSize,
|
2019-10-19 03:28:21 -07:00
|
|
|
EXPECTED_BYTES);
|
|
|
|
}
|
|
|
|
|
2018-12-07 21:18:17 -08:00
|
|
|
return pass ? 0 : 1;
|
2018-02-18 01:50:24 -08:00
|
|
|
}
|