foxygit / fake-08-xbox360 Log in
commit 40ad976cdd75f619ffeeb972c9186879d2c0e3c6
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Sun Aug 23 10:52:45 2020 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Tue Sep 15 17:09:08 2020 -0600

    add first simple graphics test
---
 source/hostVmShared.h  |  8 ++++----
 test/Makefile          | 17 +++++++++++++----
 test/graphicstests.cpp | 26 ++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/source/hostVmShared.h b/source/hostVmShared.h
index d1374cd..2e40471 100644
--- a/source/hostVmShared.h
+++ b/source/hostVmShared.h
@@ -16,8 +16,8 @@ enum
 };

 struct Color {
-	char Red;
-	char Green;
-	char Blue;
-	char Alpha;
+	uint8_t Red;
+	uint8_t Green;
+	uint8_t Blue;
+	uint8_t Alpha;
 };
diff --git a/test/Makefile b/test/Makefile
index e518f6d..8e8be85 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,20 +1,29 @@
-CFLAGS := -Wall -g -c
+#match flags from 3ds and switch makefiles. This may not all be necessary
+CFLAGS := -Wall -g -c -O2 \
+		  -fno-rtti -fexceptions -std=gnu++17


 all: runtests


-testrunner.a: testroot.o fontdatatests.o
+testrunner.a: testroot.o fontdatatests.o graphicstests.o
 	g++ testroot.o \
 	fontdata.o fontdatatests.o \
+	graphics.o graphicstests.o stringToDataHelpers.o \
 	-o testrunner.a

-testroot.o: testroot.cpp
+testroot.o: testroot.cpp doctest.h
 	g++ $(CFLAGS) testroot.cpp

-fontdatatests.o: fontdatatests.cpp ../source/fontdata.cpp
+fontdatatests.o: fontdatatests.cpp ../source/fontdata.cpp ../source/fontdata.h
 	g++ $(CFLAGS) fontdatatests.cpp ../source/fontdata.cpp

+graphicstests.o: graphicstests.cpp ../source/graphics.cpp ../source/graphics.h \
+	../source/fontdata.cpp ../source/fontdata.h \
+	../source/PicoRam.h ../source/hostVmShared.h \
+	../source/stringToDataHelpers.h ../source/stringToDataHelpers.cpp
+	g++ $(CFLAGS) graphicstests.cpp ../source/graphics.cpp ../source/stringToDataHelpers.cpp
+

 runtests: testrunner.a
 	./testrunner.a
diff --git a/test/graphicstests.cpp b/test/graphicstests.cpp
new file mode 100644
index 0000000..a2c13e7
--- /dev/null
+++ b/test/graphicstests.cpp
@@ -0,0 +1,26 @@
+#include <string>
+
+#include "doctest.h"
+#include "../source/graphics.h"
+#include "../source/fontdata.h"
+#include "../source/PicoRam.h"
+
+TEST_CASE("graphics class behaves as expected") {
+    //general setup
+    std::string fontdata = get_font_data();
+    PicoRam picoRam;
+    picoRam = {0};
+    Graphics* graphics = new Graphics(fontdata, &picoRam);
+
+    SUBCASE("Palette set up in constructor") {
+        Color* palette = graphics->GetPaletteColors();
+
+        CHECK(palette[0].Alpha == 255);
+        CHECK(palette[0].Red ==     0);
+        CHECK(palette[0].Green ==   0);
+        CHECK(palette[0].Blue ==    0);
+    }
+
+    //general teardown
+    delete graphics;
+}
\ No newline at end of file