shader test

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent b2ee272327
commit a6a2ebbefc
5 changed files with 56 additions and 1 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ target_link_libraries(vb01 glad)
target_link_libraries(vb01 assimp)
target_link_libraries(vb01 freetype)
set(renderTest nodeTest.cpp cameraTest.cpp)
set(renderTest nodeTest.cpp cameraTest.cpp shaderTest.cpp)
set(armatureTest boneTest.cpp)
set(modelTest vbModelReaderTest.cpp)
set(animationTest animationChannelTest.cpp)
+2
View File
@@ -8,6 +8,7 @@
#include "boneTest.h"
#include "vbModelReaderTest.h"
#include "animationChannelTest.h"
#include "shaderTest.h"
using namespace CppUnit;
using namespace vb01;
@@ -19,6 +20,7 @@ int main(){
runner.addTest(BoneTest::suite());
runner.addTest(VbModelReaderTest::suite());
runner.addTest(AnimationChannelTest::suite());
runner.addTest(ShaderTest::suite());
runner.run();
return 0;
}
+3
View File
@@ -12,6 +12,7 @@ namespace vb01{
enum ErrorType{VERTEX_ERROR, GEOMETRY_ERROR, FRAGMENT_ERROR, PROGRAM_ERROR};
enum ShaderType{VERTEX_SHADER, FRAGMENT_SHADER, GEOMETRY_SHADER};
Shader(){}
Shader(std::string, std::string, std::string = "");
~Shader();
void setNumLights(int);
@@ -33,6 +34,8 @@ namespace vb01{
unsigned int id;
bool geometry = false;
std::string vString, fString, gString;
friend class ShaderTest;
};
}
+23
View File
@@ -0,0 +1,23 @@
#include "shaderTest.h"
#include "shader.h"
#include <string>
using namespace std;
namespace vb01{
void ShaderTest::setUp(){
shader = new Shader();
shader->vString = "var x = 1\nvar y = 1\nvar z = 1";
}
void ShaderTest::tearDown(){
}
void ShaderTest::testReplaceLine(){
string replacement = "var y = 10";
shader->replaceLine(Shader::ShaderType::VERTEX_SHADER, 1, replacement);
size_t spot = shader->vString.find(replacement);
CPPUNIT_ASSERT(spot != string::npos);
}
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef SHADER_TEST_H
#define SHADER_TEST_H
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
namespace vb01{
class Shader;
class ShaderTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE(ShaderTest);
CPPUNIT_TEST(testReplaceLine);
CPPUNIT_TEST_SUITE_END();
public:
ShaderTest(){}
~ShaderTest(){}
void setUp();
void tearDown();
private:
Shader *shader = nullptr;
void testReplaceLine();
};
}
#endif