unlimited-storage

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 7079080610a1e168005c32f22a8790ccc9b66b6b
parent d859dbed882c38d529800a01500ac4a9ad24a7d4
Author: Andrew Laack <andrew@laack.co>
Date:   Thu, 17 Jul 2025 01:36:04 -0500

Added tests, fixed a few issues with images. This seems to be working for single images. There is still work to be done for chunking behavior.

Diffstat:
M.gitignore | 1+
Msrc/chunk.cpp | 13+++++++++++--
Msrc/encode.cpp | 1+
Atests/test-identical.sh | 20++++++++++++++++++++
Atests/test-readable-identical.sh | 24++++++++++++++++++++++++
5 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -2,3 +2,4 @@ *.txt *.tga output/* +tests/artifacts diff --git a/src/chunk.cpp b/src/chunk.cpp @@ -114,6 +114,7 @@ Chunk::Chunk(std::string filename) { std::string current = ""; for (int itr = 0; itr < 8; ++itr) { + current += content[i * 8 + itr]; } @@ -156,6 +157,8 @@ Chunk::Chunk(std::string filename, uint start, uint x, uint y) { std::vector<char> bytes(bytesToLoad); + LOG("LOADED IN " + std::to_string(bytes.size()) + " BYTES") + file.read(bytes.data(), bytesToLoad); file.close(); @@ -297,9 +300,15 @@ void Chunk::writeImage(std::string filename, uint chunkNumber, std::string origi } } - LOG(std::to_string(added)) + LOG("FINISHED WRITING " + std::to_string(added) + " CHARACTER BITS") - this->written = added; + // these are the bits that have been added. + this->written = added / 8; + LOG("FINISHED WRITING " + std::to_string(added / 8) + " CHARACTER BYTES") + + if (added<target){ + LOG("PADDING WITH ZEROES") + } while (added < target) { if (xPos == x) { diff --git a/src/encode.cpp b/src/encode.cpp @@ -29,6 +29,7 @@ int main(int argc, char* argv[]) { while (start < std::filesystem::file_size(source)){ LOG("READING CHUNK # " + std::to_string(itr)) + LOG("STARTING AT BYTE " + std::to_string(start)) Chunk chunk = Chunk(source, start, x, y); std::string fname = destinationWithoutExtension + std::to_string(itr) + ".pbm"; // std::string filename, uint chunkNumber, std::string originalFilename, uint x, uint y diff --git a/tests/test-identical.sh b/tests/test-identical.sh @@ -0,0 +1,20 @@ +dd if=/dev/urandom of=tests/artifacts/random_file.bin bs=1M count=1 +hash=$(sha256sum tests/artifacts/random_file.bin) +./build/debugEncode.out tests/artifacts/random_file.bin tests/artifacts/random_file.bin 7680 4320 +mv tests/artifacts/random_file.bin tests/artifacts/original.bin +./build/debugDecode.out tests/artifacts/random_file0.pbm +res_hash=$(sha256sum tests/artifacts/random_file.bin) + +echo $res_hash +echo $hash + +if [[ "$res_hash" == "$hash" ]]; then + echo + echo "Hashes match" +else + echo + echo "Hashes do not match!!!!" + echo "res_hash: $res_hash" + echo "hash: $hash" + exit 1 +fi diff --git a/tests/test-readable-identical.sh b/tests/test-readable-identical.sh @@ -0,0 +1,24 @@ +hash=$(sha256sum tests/resources/example.txt) +./build/debugEncode.out tests/resources/example.txt tests/artifacts/example.pbm 1920 1080 + +mv tests/resources/example.txt tests/resources/example.bak + +./build/debugDecode.out tests/artifacts/example0.pbm +res_hash=$(sha256sum tests/resources/example.txt) + +mv tests/resources/example.txt tests/resources/copy.txt +mv tests/resources/example.bak tests/resources/example.txt + +echo $res_hash +echo $hash + +if [[ "$res_hash" == "$hash" ]]; then + echo + echo "Hashes match" +else + echo + echo "Hashes do not match!!!!" + echo "res_hash: $res_hash" + echo "hash: $hash" + exit 1 +fi