-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsobel_test.cpp
More file actions
67 lines (54 loc) · 1.32 KB
/
Copy pathsobel_test.cpp
File metadata and controls
67 lines (54 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <complex>
#include <complex.h>
#include "sobel.h"
using namespace std;
int main () {
short int src[HEIGHT*WIDTH];
short int dst[(HEIGHT-2)*(WIDTH-2)];
ifstream file("data.txt");
string line;
short int s1;
int i=0;
while(getline(file,line) && (i < (HEIGHT*WIDTH)))
{
istringstream sin(line);
sin >> s1;
src[i] = (short int)s1;
i = i + 1;
}
sobel(src, dst, HEIGHT, WIDTH);
int tf = 0;
ifstream fileo("dst.txt");
string lineo;
short int s2;
int j=0;
while(getline(fileo,lineo) && (j < (HEIGHT-2)*(WIDTH-2)))
{
istringstream sino(lineo);
sino >> s2;
if (dst[j] != s2)
{
tf = 1;
}
j = j + 1;
}
if (tf == 1)
{
fprintf(stdout, "*******************************************\n");
fprintf(stdout, "FAIL: Output DOES NOT match the golden output\n");
fprintf(stdout, "*******************************************\n");
return 1;
}
else
{
fprintf(stdout, "*******************************************\n");
fprintf(stdout, "PASS: The output matches the golden output!\n");
fprintf(stdout, "*******************************************\n");
return 0;
}
}