aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--tests/simplegame.cpp4
-rw-r--r--tests/structtest.cpp49
-rw-r--r--yage/core/texture.h2
-rw-r--r--yage/core/vertex.h2
-rw-r--r--yage/core/window.cpp6
6 files changed, 58 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12711e71..c5e13ab4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@ if($ENV{UNIT_TESTS})
make_test(yagetest 1)
make_test(matrixtest ${SIMULATION_RUNS})
- make_test(particlebodytest ${SIMULATION_RUNS})
+ make_test(particlebodytest 100)
make_test(windowtest ${SIMULATION_RUNS})
make_test(spritesheettest ${SIMULATION_RUNS})
make_test(vector3test ${SIMULATION_RUNS})
@@ -50,4 +50,5 @@ if($ENV{UNIT_TESTS})
make_test(threadtest 1)
make_test(syncqueuetest 1)
make_test(activetest 1)
+ make_test(structtest ${SIMULATION_RUNS})
endif()
diff --git a/tests/simplegame.cpp b/tests/simplegame.cpp
index 4fdb38d0..54ead815 100644
--- a/tests/simplegame.cpp
+++ b/tests/simplegame.cpp
@@ -21,7 +21,7 @@ int main()
program.compileShaders("/home/yannherklotz/Github/YAGE/resources/defaultshader.vert", "/home/yannherklotz/Github/YAGE/tests/resources/defaultshader.frag");
program.addAttribute("vertex_position");
- program.addAttribute("vertex_color");
+ program.addAttribute("vertex_colour");
program.addAttribute("vertex_uv");
program.linkShaders();
@@ -31,7 +31,7 @@ int main()
window.clearBuffer();
sp.begin();
- sp.draw(std::vector<float>({0, 0, 50, 50}), std::vector<float>({0, 0, 1, 1}), fountain.id, Color(), 0);
+ sp.draw(std::vector<float>({0, 0, 50, 50}), std::vector<float>({0, 0, 1, 1}), fountain.id, Colour(), 0);
sp.render();
window.pollEvents();
diff --git a/tests/structtest.cpp b/tests/structtest.cpp
new file mode 100644
index 00000000..13a2c591
--- /dev/null
+++ b/tests/structtest.cpp
@@ -0,0 +1,49 @@
+#include <yage/yage.h>
+#include <gtest/gtest.h>
+
+#include <ctime>
+#include <cstdlib>
+
+TEST(StructTest, ColourDefault)
+{
+ yage::Colour c;
+ ASSERT_EQ(c.r, 0);
+ ASSERT_EQ(c.g, 0);
+ ASSERT_EQ(c.b, 0);
+ ASSERT_EQ(c.a, 0);
+}
+
+TEST(StructTest, ColourConstructor)
+{
+ int r = rand()%255, g = rand()%255, b = rand() % 255, a = rand() % 255;
+ yage::Colour c(r, g, b, a);
+
+ ASSERT_EQ(c.r, r);
+ ASSERT_EQ(c.g, g);
+ ASSERT_EQ(c.b, b);
+ ASSERT_EQ(c.a, a);
+}
+
+TEST(StructTest, TextureDefault)
+{
+ yage::Texture t;
+ ASSERT_EQ(t.id, static_cast<unsigned>(0));
+ ASSERT_EQ(t.width, 0);
+ ASSERT_EQ(t.height, 0);
+}
+
+TEST(StructTest, TextureConstructor)
+{
+ int id = rand(), width = rand(), height = rand();
+ yage::Texture t(static_cast<unsigned>(id), width, height);
+ ASSERT_EQ(t.id, static_cast<unsigned>(id));
+ ASSERT_EQ(t.width, width);
+ ASSERT_EQ(t.height, height);
+}
+
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+ srand(static_cast<unsigned>(time(nullptr)));
+ return RUN_ALL_TESTS();
+}
diff --git a/yage/core/texture.h b/yage/core/texture.h
index 6f61afd3..85f74647 100644
--- a/yage/core/texture.h
+++ b/yage/core/texture.h
@@ -19,7 +19,7 @@ struct Texture {
int width;
int height;
- Texture() = default;
+ Texture() : id(0), width(0), height(0) {}
Texture(GLuint id_i, int width_i, int height_i)
: id(id_i), width(width_i), height(height_i)
diff --git a/yage/core/vertex.h b/yage/core/vertex.h
index da3c2bfa..f81b4f42 100644
--- a/yage/core/vertex.h
+++ b/yage/core/vertex.h
@@ -29,7 +29,7 @@ struct Colour {
GLubyte b;
GLubyte a;
- Colour() = default;
+ Colour() : r(0), g(0), b(0), a(0) {}
Colour(GLubyte r_, GLubyte g_, GLubyte b_, GLubyte a_)
: r(r_), g(g_), b(b_), a(a_)
diff --git a/yage/core/window.cpp b/yage/core/window.cpp
index f9246ea2..3508e835 100644
--- a/yage/core/window.cpp
+++ b/yage/core/window.cpp
@@ -17,9 +17,9 @@ void key_callback(GLFWwindow *window, int key, int scanCode, int action,
int mods)
{
if (key == GLFW_KEY_E && action == GLFW_PRESS) {
- glClearColour(0.5f, 0.f, 0.f, 1.f);
+ glClearColor(0.5f, 0.f, 0.f, 1.f);
} else {
- glClearColour(0.f, 0.5f, 0.f, 1.f);
+ glClearColor(0.f, 0.5f, 0.f, 1.f);
}
}
@@ -59,7 +59,7 @@ void Window::create(std::string window_name, int width, int height)
glfwSwapInterval(1);
// set the clear colour to black
- glClearColour(0.f, 0.5f, 0.f, 1.f);
+ glClearColor(0.f, 0.5f, 0.f, 1.f);
// set alpha blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);