aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-11-17 23:44:00 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-11-17 23:44:00 +0000
commitf7791709745e6c8b82ff95629f597493aff6613a (patch)
treefb8cf829601a709eabb7e520464431a98c056af3 /tests
parent186279ee1ee54f2cdf619f4740679bb0d8b74db4 (diff)
downloadYAGE-f7791709745e6c8b82ff95629f597493aff6613a.tar.gz
YAGE-f7791709745e6c8b82ff95629f597493aff6613a.zip
more tests added
Diffstat (limited to 'tests')
-rw-r--r--tests/simplegame.cpp4
-rw-r--r--tests/structtest.cpp49
2 files changed, 51 insertions, 2 deletions
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();
+}