File: tests_vector.cpp

package info (click to toggle)
monado 25.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,708 kB
  • sloc: cpp: 175,132; ansic: 141,570; python: 2,913; java: 753; xml: 735; sh: 403; javascript: 255; makefile: 58
file content (38 lines) | stat: -rw-r--r-- 819 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
// Copyright 2022, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
 * @file
 * @brief Test u_vector C interface.
 * @author Mateo de Mayo <mateo.demayo@collabora.com>
 */

#include "catch_amalgamated.hpp"
#include "util/u_vector.h"

TEST_CASE("u_vector")
{
	SECTION("Test interface generated from macros")
	{
		struct u_vector_float vf = u_vector_float_create();
		CHECK(vf.ptr != NULL);

		constexpr float A = 2.71f;
		constexpr float B = 1.61f;
		constexpr float C = 3.14f;

		u_vector_float_push_back(vf, A);
		u_vector_float_push_back(vf, B);
		u_vector_float_push_back(vf, C);

		float a = u_vector_float_at(vf, 0);
		float b = u_vector_float_at(vf, 1);
		float c = u_vector_float_at(vf, 2);

		CHECK(a == A);
		CHECK(b == B);
		CHECK(c == C);

		u_vector_float_destroy(&vf);
		CHECK(vf.ptr == NULL);
	}
}