File: test_fib.c

package info (click to toggle)
bart 0.9.00-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,040 kB
  • sloc: ansic: 116,116; python: 1,329; sh: 726; makefile: 639; javascript: 589; cpp: 106
file content (31 lines) | stat: -rw-r--r-- 641 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
/* Copyright 2023. Institute of Biomedical Imaging, TU Graz
 * All rights reserved. Use of this source code is governed by
 * a BSD-style license which can be found in the LICENSE file.
 */

#include <math.h>
#include <stdbool.h>

#include "noncart/traj.h"

#include "utest.h"


static bool test_gen_fib(void)
{
	int ref1[10] = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };
	int ref7[10] = { 1, 7, 8, 15, 23, 38, 61, 99, 160, 259 };

	for (int i = 0; i < 10; i++) {

		if (0 != abs(ref1[i] - gen_fibonacci(1, i)))
			return false;

		if (0 != abs(ref7[i] - gen_fibonacci(7, i)))
			return false;
	}

	return true;
}

UT_REGISTER_TEST(test_gen_fib);