Blender  V3.3
COM_BufferRange_test.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. */
3 
4 #include "testing/testing.h"
5 
6 #include "COM_BufferRange.h"
7 
9 
10 TEST(BufferRange, Constructor)
11 {
12  const int size = 5;
13  BufferRange<float> range(nullptr, 1, size, 4);
14  EXPECT_EQ(range.size(), size);
15 }
16 
17 static void fill_buffer_with_indexes(float *buf, int buf_len)
18 {
19  for (int i = 0; i < buf_len; i++) {
20  buf[i] = i;
21  }
22 }
23 
24 TEST(BufferRange, Subscript)
25 {
26  const int start = 2;
27  const int size = 4;
28  const int num_channels = 3;
29  const int buf_len = (start + size) * num_channels;
30  float buf[buf_len];
31 
32  BufferRange<float> range(buf, start, size, num_channels);
33 
34  fill_buffer_with_indexes(buf, buf_len);
35  int buf_index = start * num_channels;
36  for (int i = 0; i < size; i++) {
37  const float *elem = range[i];
38  for (int ch = 0; ch < num_channels; ch++) {
39  EXPECT_NEAR(elem[ch], buf_index, FLT_EPSILON);
40  buf_index++;
41  }
42  }
43  EXPECT_EQ(buf_index, buf_len);
44 }
45 
46 TEST(BufferRange, SingleElemBufferIteration)
47 {
48  const int start = 1;
49  const int size = 3;
50  const int num_channels = 4;
51  float buf[num_channels];
52  const int stride = 0;
53  BufferRange<float> range(buf, start, size, stride);
54 
55  int elems_count = 0;
56  for (float *elem : range) {
57  EXPECT_EQ(elem, buf);
58  elems_count++;
59  }
60  EXPECT_EQ(elems_count, 1);
61 }
62 
63 TEST(BufferRange, FullBufferIteration)
64 {
65  const int start = 2;
66  const int size = 5;
67  const int num_channels = 4;
68  const int buf_len = (start + size) * num_channels;
69  float buf[buf_len];
70  BufferRange<float> range(buf, start, size, num_channels);
71 
72  fill_buffer_with_indexes(buf, buf_len);
73  int buf_index = start * num_channels;
74  for (float *elem : range) {
75  for (int ch = 0; ch < num_channels; ch++) {
76  EXPECT_NEAR(elem[ch], buf_index, FLT_EPSILON);
77  buf_index++;
78  }
79  }
80  EXPECT_EQ(buf_index, buf_len);
81 }
82 
83 } // namespace blender::compositor::tests
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
constexpr int64_t size() const
static void fill_buffer_with_indexes(float *buf, int buf_len)
TEST(BufferArea, BufferConstructor)