Przeglądaj źródła

Adding unit testing. Needs to be populated

Panagiotis Christopoulos Charitos 15 lat temu
rodzic
commit
6376c545bb

+ 5 - 0
run-unit-tests.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=extern/lib-x86-64-linux/
+ulimit -c unlimited
+unit-tests/build/anki-unit-tests

+ 1 - 1
src/Renderer/Is.cpp

@@ -162,7 +162,7 @@ void Is::init(const RendererInitializer& initializer)
 	viewVectorsVbo = new Vbo(GL_ARRAY_BUFFER, 4 * sizeof(Vec3), NULL, GL_DYNAMIC_DRAW, this);
 
 	vao = new Vao(this);
-	vao->attachArrayBufferVbo(*quadPositionsVbo, 0, 3, GL_FLOAT, false, 0, NULL);
+	vao->attachArrayBufferVbo(*quadPositionsVbo, 0, 2, GL_FLOAT, false, 0, NULL);
 	vao->attachArrayBufferVbo(*viewVectorsVbo, 1, 3, GL_FLOAT, false, 0, NULL);
 	vao->attachElementArrayBufferVbo(*quadVertIndecesVbo);
 }

+ 2 - 2
src/Renderer/Is.h

@@ -28,8 +28,8 @@ class Is: private RenderingPass
 		void run();
 
 	private:
-		Sm* sm;
-		Smo* smo;
+		Sm* sm; ///< Shadowmapping pass
+		Smo* smo; /// Stencil masking optimizations pass
 		Fbo fbo; ///< This FBO writes to the Is::fai
 		uint stencilRb; ///< Illumination stage stencil buffer
 		RsrcPtr<ShaderProg> ambientPassSProg; ///< Illumination stage ambient pass shader program

+ 3 - 29
src/Renderer/Renderer.cpp

@@ -21,32 +21,6 @@ Renderer::Renderer(Object* parent):
 {}
 
 
-
-GLsizei const ElementCount = 6;
-GLsizeiptr const ElementSize = ElementCount * sizeof(uint);
-uint const ElementData[ElementCount] =
-{
-	0, 1, 2,
-	0, 2, 3
-};
-
-GLsizei const VertexCount = 4;
-GLsizeiptr const PositionSize = VertexCount * sizeof(Vec2);
-Vec2 const PositionData[VertexCount] =
-{
-	Vec2(-1.0f,-1.0f),
-	Vec2( 1.0f,-1.0f),
-	Vec2( 1.0f, 1.0f),
-	Vec2(-1.0f, 1.0f)
-};
-
-GLuint VertexArrayName;
-GLuint ProgramName;
-GLuint ArrayBufferName;
-GLuint ElementBufferName;
-
-
-
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
@@ -73,12 +47,12 @@ void Renderer::init(const RendererInitializer& initializer)
 
 	// quad VBOs and VAO
 	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}};
-	quadPositionsVbo = new Vbo(GL_ARRAY_BUFFER, sizeof(quadVertCoords), quadVertCoords, GL_STATIC_DRAW);
+	quadPositionsVbo = new Vbo(GL_ARRAY_BUFFER, sizeof(quadVertCoords), quadVertCoords, GL_STATIC_DRAW, this);
 
 	ushort quadVertIndeces[2][3] = {{0, 1, 3}, {1, 2, 3}}; // 2 triangles
-	quadVertIndecesVbo = new Vbo(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces), quadVertIndeces, GL_STATIC_DRAW);
+	quadVertIndecesVbo = new Vbo(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces), quadVertIndeces, GL_STATIC_DRAW, this);
 
-	globalVao = new Vao();
+	globalVao = new Vao(this);
 	globalVao->attachArrayBufferVbo(*quadPositionsVbo, 0, 2, GL_FLOAT, false, 0, NULL);
 	globalVao->attachElementArrayBufferVbo(*quadVertIndecesVbo);
 }

+ 2 - 2
src/Util/Scanner.h

@@ -161,10 +161,10 @@ class Scanner
 		/// Extracts all tokens and prints them. Used for debugging
 		void getAllPrintAll();
 
-		/// Get the next token from the stream
+		/// Get the next token from the stream. Its virtual and you can override it
 		/// @return The next Token
 		/// @exception Exception
-		const Token& getNextToken();
+		virtual const Token& getNextToken();
 
 		/// Accessor for the current token
 		/// @return The current Token

+ 8 - 0
unit-tests/Main.cpp

@@ -0,0 +1,8 @@
+#include <gtest/gtest.h>
+
+
+int main(int argc, char** argv)
+{
+	::testing::InitGoogleTest(&argc, argv);
+	return RUN_ALL_TESTS();
+}

+ 7 - 0
unit-tests/Util/Scanner.ut.cpp

@@ -0,0 +1,7 @@
+#include <gtest/gtest.h>
+
+TEST(ScannerTests, lala)
+{
+	EXPECT_EQ(0, 1);
+	EXPECT_EQ(0, 0);
+}

Plik diff jest za duży
+ 8 - 0
unit-tests/build/Makefile


+ 14 - 0
unit-tests/build/gen.cfg.py

@@ -0,0 +1,14 @@
+sourcePaths = walkDir("../../src")
+sourcePaths.extend(list(walkDir("../", True)))
+
+includePaths = ["./"]
+includePaths.extend(list(sourcePaths))
+includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
+
+executableName = "anki-unit-tests"
+
+compiler = "g++"
+
+compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant"
+
+linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lgtest"

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików