Compare commits
2 Commits
73234d0764
...
123e0f56bc
Author | SHA1 | Date | |
---|---|---|---|
123e0f56bc | |||
e79158e3f1 |
@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
|
|||||||
bool is_idat = memcmp(chunks[i]->type, "IDAT", 4) == 0;
|
bool is_idat = memcmp(chunks[i]->type, "IDAT", 4) == 0;
|
||||||
bool is_iend = memcmp(chunks[i]->type, "IEND", 4) == 0;
|
bool is_iend = memcmp(chunks[i]->type, "IEND", 4) == 0;
|
||||||
if (is_idat || is_iend) {
|
if (is_idat || is_iend) {
|
||||||
printf("Found %.4s chunk\n", chunks[i]->type);
|
printf("Found %.4s\n", chunks[i]->type);
|
||||||
if (is_idat) {
|
if (is_idat) {
|
||||||
xor_data(chunks[i]);
|
xor_data(chunks[i]);
|
||||||
}
|
}
|
||||||
|
22
Assignment9/tests/test_images.sh
Normal file
22
Assignment9/tests/test_images.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Executable path
|
||||||
|
EXECUTABLE=../build/Assignment9
|
||||||
|
|
||||||
|
|
||||||
|
test_reverse() {
|
||||||
|
start=$(date +%s)
|
||||||
|
cp "$1" in.png
|
||||||
|
cp in.png out.png
|
||||||
|
$EXECUTABLE out.png > /dev/null
|
||||||
|
$EXECUTABLE out.png > /dev/null
|
||||||
|
diff in.png out.png
|
||||||
|
rm in.png out.png
|
||||||
|
end=$(date +%s)
|
||||||
|
echo "Test $1 took $((end - start)) seconds"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_reverse test1.png
|
||||||
|
# test_reverse test2.png # This png is invalid, so it will fail
|
||||||
|
test_reverse test3.png
|
||||||
|
test_reverse test4.png
|
18
Assignment9/tests/test_text.sh
Normal file
18
Assignment9/tests/test_text.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
EXECUTABLE=../build/Assignment9
|
||||||
|
|
||||||
|
# Test the text output
|
||||||
|
$EXECUTABLE test1.png | diff output1.txt -
|
||||||
|
$EXECUTABLE test2.png | diff output2.txt -
|
||||||
|
$EXECUTABLE test3.png | diff output3.txt -
|
||||||
|
$EXECUTABLE test4.png | diff output4.txt -
|
||||||
|
|
||||||
|
|
||||||
|
# Reverse the images
|
||||||
|
$EXECUTABLE test1.png > /dev/null
|
||||||
|
$EXECUTABLE test2.png > /dev/null
|
||||||
|
$EXECUTABLE test3.png > /dev/null
|
||||||
|
$EXECUTABLE test4.png > /dev/null
|
||||||
|
|
||||||
|
echo "If there is no diff output, then the test passed."
|
Loading…
Reference in New Issue
Block a user