Skip to content

Commit 3ea15b2

Browse files
committed
Merge pull request #2 from boyska/manipulation
Test improvement is nice :)
2 parents e6b2d5d + 59a5468 commit 3ea15b2

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@ images_names=kodim01.png kodim02.png
22

33
all: split
44
images:$(addprefix testImage/,$(images_names))
5+
.PHONY: clean test
56

7+
BINS=split tests/createBlankImage
68
OBJ:=split.o lib/fillwithblack.o lib/manppm.o
79
EXTRACFLAGS=
810
CFLAGS=-Wall $(EXTRACFLAGS)
911

12+
$(BINS):
13+
$(CC) $(CFLAGS) -lm -o $@ $^
14+
1015
split: $(OBJ)
11-
$(CC) $(CFLAGS) -lm $(OBJ) -o $@
16+
tests/createBlankImage: tests/createBlankImage.o lib/fillwithblack.o lib/manppm.o
17+
1218

1319
testImage/kodim%.png:
1420
wget --quiet http://r0k.us/graphics/kodak/kodak/$(notdir $@) -O $@
1521

1622
clean:
17-
rm -f $(OBJ) split
23+
rm -f $(OBJ) split tests/createBlankImage
24+
25+
26+
27+
test: tests/cuttest tests/createBlankImage split
28+
cd $(dir $<) && bash $(notdir $<)

lib/fillwithblack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4+
#include <math.h>
45
#include "fillwithblack.h"
56

67
void writePPM(const char *filename, PPMImage *img) {

tests/cuttest

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ function genLine {
1212
tanalpha=$sign$(printf "0.%03d%02d" $(( $RANDOM % 1000 )) $(( $RANDOM % 100)))
1313
}
1414

15-
function initFuncs {
16-
gcc -o createBlankImg ../lib/manppm.c ../lib/fillwithblack.c createBlankImage.c -lm 2> /dev/null
17-
}
18-
1915
function createVoidImage {
20-
./createBlankImg -n "voidImage.ppm"
16+
./createBlankImage -n "voidImage.ppm"
2117
}
2218

2319
function cleanVoidImage {
@@ -40,7 +36,7 @@ function testRandomPoints {
4036
y2=`shuf -i $halfheight-$height -n 1`
4137
x1=`echo "$intercept+$tanalpha*$y1"|bc`
4238
x2=`echo "$intercept+$tanalpha*$y2"|bc`
43-
./createBlankImg -n "blankImage.ppm" -x $x1 -y $y1 -a $x2 -b $y2
39+
./createBlankImage -n "blankImage.ppm" -x $x1 -y $y1 -a $x2 -b $y2
4440
../split -f "blankImage.ppm" -p -s
4541
}
4642

@@ -50,9 +46,6 @@ function testRandomPoints {
5046
#echo $intercept
5147
#echo $tanalpha
5248

53-
# Init stuff #
54-
55-
initFuncs
5649

5750
# Void Image test #
5851

@@ -71,13 +64,10 @@ testRandomPoints
7164
#echo $y2
7265
echo "intercept: "$intercept
7366
echo "tanalpha: "$tanalpha
74-
rm blankImage.ppm
67+
rm -f blankImage.ppm
7568

7669
# Clean All #
7770

78-
rm ../lib/fillwithblack.o ../lib/manppm.o
79-
rm ./createBlankImg
80-
8171
###################
8272

8373

0 commit comments

Comments
 (0)