-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.cc
More file actions
35 lines (33 loc) · 862 Bytes
/
test2.cc
File metadata and controls
35 lines (33 loc) · 862 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
32
33
34
35
#include "main.h"
#include <vector>
// Verify that the naive implementation of average() works
template<typename T>
void test2 ()
{
const size_t M = 13;
const size_t N = 23;
const size_t K = 2;
vector<T> x (M * N, 2);
for (size_t i = 0; i < x.size (); i += 2)
x[i] = 1;
vector<T> y = slow_average (x, M, N, K);
for (size_t i = K / 2; i + K / 2 < M; ++i)
for (size_t j = K / 2; j + K / 2 < N; ++j)
if (is_integral<T>::value)
verify (y[index (i, j, N)] == 2);
else
verify (y[index (i, j, N)] == 1.5);
}
void process ()
{
test2<char> ();
test2<unsigned char> ();
test2<short> ();
test2<unsigned short> ();
test2<int> ();
test2<unsigned int> ();
test2<long> ();
test2<unsigned long> ();
test2<float> ();
test2<double> ();
}