commit 1eef220b00777e7388e08dcc0644dcbc3d43efe1
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Tue Mar 8 21:23:41 2022 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Tue Mar 8 21:23:41 2022 -0700
tests passing
---
test/Makefile | 13 +++----
test/graphicstests.cpp | 86 +++++------------------------------------------
test/printHelperTests.cpp | 34 +------------------
test/testHelpers.cpp | 33 ++++++++++++++++++
test/testHelpers.h | 18 ++++++++++
5 files changed, 68 insertions(+), 116 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index aed3b35..e566b47 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -13,10 +13,11 @@ testrunner.a: testroot.o \
g++ -I$(CURDIR)/include -L$(CURDIR)/lib \
testroot.o \
fontdata.o fontdatatests.o \
- graphics.o graphicstests.o stringToDataHelpers.o mathhelpers.o \
+ graphics.o graphicstests.o stringToDataHelpers.o testHelpers.o mathhelpers.o \
+ printHelper.o printHelperTests.o \
Audio.o synth.o audiotests.o \
cart.o carttests.o nooplogger.o lodepng.o emojiconversion.o filehelpers.o \
- vm.o endtoendtests.o picoluaapi.o printHelper.o Input.o \
+ vm.o endtoendtests.o picoluaapi.o Input.o \
vmtests.o stubhost.o \
nibblehelpers.o nibblehelperstests.o \
filehelperstests.o \
@@ -32,18 +33,18 @@ fontdatatests.o: fontdatatests.cpp ../source/fontdata.cpp ../source/fontdata.h
nibblehelperstests.o: nibblehelperstests.cpp ../source/nibblehelpers.cpp ../source/nibblehelpers.h
g++ $(CFLAGS) nibblehelperstests.cpp ../source/nibblehelpers.cpp
-graphicstests.o: liblua.a fontdatatests.o graphicstests.cpp ../source/graphics.cpp ../source/graphics.h \
+graphicstests.o: liblua.a fontdatatests.o graphicstests.cpp testHelpers.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 \
../source/mathhelpers.h ../source/mathhelpers.cpp \
../source/nibblehelpers.h ../source/nibblehelpers.cpp
g++ $(CFLAGS) -I$(CURDIR)/include -L$(CURDIR)/lib \
- graphicstests.cpp ../source/graphics.cpp \
+ graphicstests.cpp ../source/graphics.cpp testHelpers.cpp \
../source/stringToDataHelpers.cpp ../source/nibblehelpers.cpp ../source/mathhelpers.cpp
-printHelperTests.o: graphicstests.o printHelperTests.cpp ../source/printHelper.cpp ../source/printHelper.h
- g++ $(CFLAGS) -I$(CURDIR)/include printHelperTests.cpp ../source/printHelper.cpp
+printHelperTests.o: graphicstests.o printHelperTests.cpp testHelpers.cpp ../source/printHelper.cpp ../source/printHelper.h
+ g++ $(CFLAGS) -I$(CURDIR)/include printHelperTests.cpp ../source/printHelper.cpp testHelpers.cpp
audiotests.o: audiotests.cpp ../source/Audio.cpp ../source/Audio.h \
../source/synth.cpp ../source/synth.h \
diff --git a/test/graphicstests.cpp b/test/graphicstests.cpp
index 6e4f9e5..f6f719b 100644
--- a/test/graphicstests.cpp
+++ b/test/graphicstests.cpp
@@ -7,39 +7,7 @@
#include "../source/fontdata.h"
#include "../source/PicoRam.h"
-struct coloredPoint {
- uint8_t x;
- uint8_t y;
- uint8_t c;
-};
-
-bool colorsEqual(Color* lhs, Color* rhs) {
- return lhs->Alpha == rhs->Alpha &&
- lhs->Red == rhs->Red &&
- lhs->Green == rhs->Green &&
- lhs->Blue == rhs->Blue;
-}
-
-void debugScreen(Graphics* graphics) {
- for (int x=0; x < 128; x++) {
- for (int y = 0; y < 128; y++) {
- uint8_t c = graphics->pget(x,y);
- if (c != 0) {
- printf("%d,%d,%d\n", x, y, c);
- }
- }
- }
-}
-
-void checkPoints(Graphics* graphics, std::vector<coloredPoint> expectedPoints) {
- bool isCorrect = true;
- for(size_t i = 0; i < expectedPoints.size(); i++){
- auto toCheck = expectedPoints[i];
- isCorrect &= graphics->pget(toCheck.x, toCheck.y) == toCheck.c;
- }
-
- CHECK(isCorrect);
-}
+#include "testHelpers.h"
TEST_CASE("graphics class behaves as expected") {
//general setup
@@ -1982,11 +1950,14 @@ TEST_CASE("graphics class behaves as expected") {
checkPoints(graphics, expectedPoints);
}
*/
-
SUBCASE("Remap spritesheet to screen"){
graphics->cls();
- //TODO: redo this test without print-- drawCharater?
- //graphics->print("zo", 8, 0);
+
+ //emulate print("zo",8,0)
+ picoRam.drawState.drawPaletteMap[7] = 6;
+ graphics->drawCharacter(122, 8, 0);
+ graphics->drawCharacter(111, 12, 0);
+
picoRam.hwState.spriteSheetMemMapping = 0x60;
graphics->spr(1, 0, 64, 1.0, 1.0, false, false);
@@ -2033,49 +2004,10 @@ TEST_CASE("graphics class behaves as expected") {
{2,68,6},
{3,68,0},
{4,68,6},
- {5,68,6},
- {6,68,0},
- {7,68,0},
- {8,68,0},
- {0,69,0},
- {1,69,0},
- {2,69,0},
- {3,69,0},
- {4,69,0},
- {5,69,0},
- {6,69,0},
- {7,69,0},
- {8,69,0},
- {0,70,0},
- {1,70,0},
- {2,70,0},
- {3,70,0},
- {4,70,0},
- {5,70,0},
- {6,70,0},
- {7,70,0},
- {8,70,0},
- {0,71,0},
- {1,71,0},
- {2,71,0},
- {3,71,0},
- {4,71,0},
- {5,71,0},
- {6,71,0},
- {7,71,0},
- {8,71,0},
- {0,72,0},
- {1,72,0},
- {2,72,0},
- {3,72,0},
- {4,72,0},
- {5,72,0},
- {6,72,0},
- {7,72,0},
- {8,72,0}
+ {5,68,6}
};
- //checkPoints(graphics, expectedPoints);
+ checkPoints(graphics, expectedPoints);
}
SUBCASE("Remap screen to spritesheet"){
graphics->cls();
diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index a29a602..2deace5 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -13,40 +13,8 @@
#include "../source/fontdata.h"
+#include "testHelpers.h"
-struct coloredPoint {
- uint8_t x;
- uint8_t y;
- uint8_t c;
-};
-
-bool colorsEqual(Color* lhs, Color* rhs) {
- return lhs->Alpha == rhs->Alpha &&
- lhs->Red == rhs->Red &&
- lhs->Green == rhs->Green &&
- lhs->Blue == rhs->Blue;
-}
-
-void debugScreen(Graphics* graphics) {
- for (int x=0; x < 128; x++) {
- for (int y = 0; y < 128; y++) {
- uint8_t c = graphics->pget(x,y);
- if (c != 0) {
- printf("%d,%d,%d\n", x, y, c);
- }
- }
- }
-}
-
-void checkPoints(Graphics* graphics, std::vector<coloredPoint> expectedPoints) {
- bool isCorrect = true;
- for(size_t i = 0; i < expectedPoints.size(); i++){
- auto toCheck = expectedPoints[i];
- isCorrect &= graphics->pget(toCheck.x, toCheck.y) == toCheck.c;
- }
-
- CHECK(isCorrect);
-}
TEST_CASE("Print helper functions") {
diff --git a/test/testHelpers.cpp b/test/testHelpers.cpp
new file mode 100644
index 0000000..d0eb0cc
--- /dev/null
+++ b/test/testHelpers.cpp
@@ -0,0 +1,33 @@
+#include <vector>
+#include "doctest.h"
+
+#include "testHelpers.h"
+
+
+bool colorsEqual(Color* lhs, Color* rhs) {
+ return lhs->Alpha == rhs->Alpha &&
+ lhs->Red == rhs->Red &&
+ lhs->Green == rhs->Green &&
+ lhs->Blue == rhs->Blue;
+}
+
+void debugScreen(Graphics* graphics) {
+ for (int x=0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
+ uint8_t c = graphics->pget(x,y);
+ if (c != 0) {
+ printf("%d,%d,%d\n", x, y, c);
+ }
+ }
+ }
+}
+
+void checkPoints(Graphics* graphics, std::vector<coloredPoint> expectedPoints) {
+ bool isCorrect = true;
+ for(size_t i = 0; i < expectedPoints.size(); i++){
+ auto toCheck = expectedPoints[i];
+ isCorrect &= graphics->pget(toCheck.x, toCheck.y) == toCheck.c;
+ }
+
+ CHECK(isCorrect);
+}
diff --git a/test/testHelpers.h b/test/testHelpers.h
new file mode 100644
index 0000000..c02d8e3
--- /dev/null
+++ b/test/testHelpers.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <vector>
+
+#include "../source/hostVmShared.h"
+#include "../source/graphics.h"
+
+struct coloredPoint {
+ uint8_t x;
+ uint8_t y;
+ uint8_t c;
+};
+
+bool colorsEqual(Color* lhs, Color* rhs);
+
+void debugScreen(Graphics* graphics);
+
+void checkPoints(Graphics* graphics, std::vector<coloredPoint> expectedPoints);