-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.cc
More file actions
31 lines (29 loc) · 740 Bytes
/
test1.cc
File metadata and controls
31 lines (29 loc) · 740 Bytes
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
#include "main.h"
#include <vector>
// Verify that the naive implementation of average() works
template<typename T>
void test1 ()
{
const size_t M = 17;
const size_t N = 13;
const size_t K1 = 5;
const size_t K2 = 7;
vector<T> x (M * N, 100);
vector<T> y = slow_average (x, M, N, K1, K2);
for (size_t i = K1 / 2; i + K1 / 2 < M; ++i)
for (size_t j = K2 / 2; j + K2 / 2 < N; ++j)
verify (x[index (i, j, N)] == y[index (i, j, N)]);
}
void process ()
{
test1<char> ();
test1<unsigned char> ();
test1<short> ();
test1<unsigned short> ();
test1<int> ();
test1<unsigned int> ();
test1<long> ();
test1<unsigned long> ();
test1<float> ();
test1<double> ();
}