File: interpolator.cpp

package info (click to toggle)
libcamera 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,488 kB
  • sloc: cpp: 85,656; python: 18,099; ansic: 12,763; sh: 1,309; makefile: 60
file content (47 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download
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
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2024, Ideas on Board Oy
 *
 * Interpolator tests
 */

#include "../src/ipa/libipa/interpolator.h"

#include <cmath>
#include <iostream>
#include <map>
#include <stdint.h>
#include <stdio.h>

#include "test.h"

using namespace std;
using namespace libcamera;
using namespace ipa;

#define ASSERT_EQ(a, b)                    \
	if ((a) != (b)) {                  \
		printf(#a " != " #b "\n"); \
		return TestFail;           \
	}

class InterpolatorTest : public Test
{
protected:
	int run()
	{
		Interpolator<int> interpolator;
		interpolator.setData({ { 10, 100 }, { 20, 200 }, { 30, 300 } });

		ASSERT_EQ(interpolator.getInterpolated(0), 100);
		ASSERT_EQ(interpolator.getInterpolated(10), 100);
		ASSERT_EQ(interpolator.getInterpolated(20), 200);
		ASSERT_EQ(interpolator.getInterpolated(25), 250);
		ASSERT_EQ(interpolator.getInterpolated(30), 300);
		ASSERT_EQ(interpolator.getInterpolated(40), 300);

		return TestPass;
	}
};

TEST_REGISTER(InterpolatorTest)