mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 21:33:59 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -13,34 +13,24 @@
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Return;
|
||||
using ::testing::AnyOf;
|
||||
using ::testing::IgnoreResult;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
using namespace dp;
|
||||
|
||||
namespace uniform_value_tests
|
||||
{
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
class MemoryComparer
|
||||
{
|
||||
public:
|
||||
MemoryComparer(T const * memory, uint32_t size)
|
||||
: m_result(false)
|
||||
, m_memory(memory)
|
||||
, m_size(size)
|
||||
{}
|
||||
MemoryComparer(T const * memory, uint32_t size) : m_result(false), m_memory(memory), m_size(size) {}
|
||||
|
||||
void Compare(int32_t id, T const * memory)
|
||||
{
|
||||
m_result = memcmp(m_memory, memory, m_size) == 0;
|
||||
}
|
||||
void Compare(int32_t id, T const * memory) { m_result = memcmp(m_memory, memory, m_size) == 0; }
|
||||
|
||||
bool GetResult() const
|
||||
{
|
||||
return m_result;
|
||||
}
|
||||
bool GetResult() const { return m_result; }
|
||||
|
||||
private:
|
||||
bool m_result;
|
||||
@@ -48,24 +38,17 @@ private:
|
||||
uint32_t m_size;
|
||||
};
|
||||
|
||||
void mock_glGetActiveUniform(uint32_t programID, uint32_t index, int32_t * size,
|
||||
glConst * type, std::string & name)
|
||||
void mock_glGetActiveUniform(uint32_t programID, uint32_t index, int32_t * size, glConst * type, std::string & name)
|
||||
{
|
||||
*size = 1;
|
||||
if (index < 9)
|
||||
{
|
||||
static std::pair<std::string, glConst> mockUniforms[9] =
|
||||
{
|
||||
{"position0", gl_const::GLIntType},
|
||||
{"position1", gl_const::GLIntVec2},
|
||||
{"position2", gl_const::GLIntVec3},
|
||||
{"position3", gl_const::GLIntVec4},
|
||||
{"position4", gl_const::GLFloatType},
|
||||
{"position5", gl_const::GLFloatVec2},
|
||||
{"position6", gl_const::GLFloatVec3},
|
||||
{"position7", gl_const::GLFloatVec4},
|
||||
{"viewModel", gl_const::GLFloatMat4}
|
||||
};
|
||||
static std::pair<std::string, glConst> mockUniforms[9] = {
|
||||
{"position0", gl_const::GLIntType}, {"position1", gl_const::GLIntVec2},
|
||||
{"position2", gl_const::GLIntVec3}, {"position3", gl_const::GLIntVec4},
|
||||
{"position4", gl_const::GLFloatType}, {"position5", gl_const::GLFloatVec2},
|
||||
{"position6", gl_const::GLFloatVec3}, {"position7", gl_const::GLFloatVec4},
|
||||
{"viewModel", gl_const::GLFloatMat4}};
|
||||
name = mockUniforms[index].first;
|
||||
*type = mockUniforms[index].second;
|
||||
}
|
||||
@@ -83,13 +66,7 @@ UNIT_TEST(UniformValueTest)
|
||||
int32_t constexpr positionLoc = 10;
|
||||
int32_t constexpr modelViewLoc = 11;
|
||||
|
||||
float matrix[16] =
|
||||
{
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
};
|
||||
float matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
MemoryComparer<float> comparer(matrix, 16 * sizeof(float));
|
||||
|
||||
@@ -136,19 +113,18 @@ UNIT_TEST(UniformValueTest)
|
||||
|
||||
EXPECTGL(glUniformValuef(positionLoc, 1.0f, 2.0f, 3.0f, 4.0f));
|
||||
|
||||
EXPECTGL(glUniformMatrix4x4Value(modelViewLoc, _))
|
||||
.WillOnce(Invoke(&comparer, &MemoryComparer<float>::Compare));
|
||||
EXPECTGL(glUniformMatrix4x4Value(modelViewLoc, _)).WillOnce(Invoke(&comparer, &MemoryComparer<float>::Compare));
|
||||
|
||||
EXPECTGL(glUseProgram(0));
|
||||
EXPECTGL(glDeleteProgram(ProgramID));
|
||||
EXPECTGL(glDeleteShader(AnyOf(VertexShaderID, FragmentShaderID))).Times(2);
|
||||
}
|
||||
|
||||
drape_ptr<Shader> vs = make_unique_dp<Shader>("", "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }",
|
||||
"", Shader::Type::VertexShader);
|
||||
drape_ptr<Shader> vs = make_unique_dp<Shader>("", "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }", "",
|
||||
Shader::Type::VertexShader);
|
||||
|
||||
drape_ptr<Shader> fs = make_unique_dp<Shader>("", "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); }",
|
||||
"", Shader::Type::FragmentShader);
|
||||
drape_ptr<Shader> fs = make_unique_dp<Shader>("", "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); }", "",
|
||||
Shader::Type::FragmentShader);
|
||||
|
||||
drape_ptr<GLGpuProgram> program = make_unique_dp<GLGpuProgram>("", make_ref(vs), make_ref(fs));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user