summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-04-16 12:35:51 +0200
committerMitya Selivanov <automainint@guattari.tech>2025-04-16 12:35:51 +0200
commit2e169096003edab21b6720a25342529b1c7e12f0 (patch)
treebdf55bc898cb965e3ecec919df40348be4aa5955
parent736b3c0ed01c7dbddd4977fd2c8cf274cdcc77bd (diff)
downloadreduced_system_layer-2e169096003edab21b6720a25342529b1c7e12f0.zip
Add test digits 42
-rwxr-xr-xgraphics.c57
1 files changed, 53 insertions, 4 deletions
diff --git a/graphics.c b/graphics.c
index 4212e45..09b5b74 100755
--- a/graphics.c
+++ b/graphics.c
@@ -2287,8 +2287,10 @@ TEST("text letter A") {
};
for (i64 i = 0; i < w * h; ++i) {
- b8 bit = pixels[i].x > 0.5;
- if (expect_bits[i] != bit) {
+ if (expect_bits[i] != (pixels[i].x > 0.5) ||
+ expect_bits[i] != (pixels[i].y > 0.5) ||
+ expect_bits[i] != (pixels[i].z > 0.5) ||
+ expect_bits[i] != (pixels[i].w > 0.5)) {
REQUIRE(0);
break;
}
@@ -2330,8 +2332,55 @@ TEST("text letter z") {
};
for (i64 i = 0; i < w * h; ++i) {
- b8 bit = pixels[i].x > 0.5;
- if (expect_bits[i] != bit) {
+ if (expect_bits[i] != (pixels[i].x > 0.5) ||
+ expect_bits[i] != (pixels[i].y > 0.5) ||
+ expect_bits[i] != (pixels[i].z > 0.5) ||
+ expect_bits[i] != (pixels[i].w > 0.5)) {
+ REQUIRE(0);
+ break;
+ }
+ }
+}
+
+TEST("text digits 42") {
+ i64 w = 10;
+ i64 h = 10;
+
+ vec4_f32 pixels[100] = {0};
+
+ draw_text_area_to_buffer(
+ (Pixel_Buffer) {
+ .width = 10,
+ .height = 10,
+ .stride = 10,
+ .pixels = pixels,
+ },
+ 0,
+ (vec4_f32) { 1.0f, 1.0f, 1.0f, 1.0f, },
+ (Box) { .x = 0, .y = 0, .width = 10, .height = 10, },
+ (vec2) { .x = 10.0, .y = 10.0, },
+ 2,
+ (c32[2]) { '4', '2', }
+ );
+
+ b8 expect_bits[100] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 1, 0, 0, 1, 1, 1, 1,
+ 1, 0, 0, 1, 0, 0, 1, 1, 1, 1,
+ 1, 0, 0, 1, 0, 0, 0, 0, 0, 1,
+ 1, 1, 1, 1, 0, 0, 0, 1, 1, 0,
+ 1, 1, 1, 1, 0, 0, 0, 1, 1, 0,
+ 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 1, 1, 1, 1,
+ 0, 0, 0, 1, 0, 0, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ };
+
+ for (i64 i = 0; i < w * h; ++i) {
+ if (expect_bits[i] != (pixels[i].x > 0.5) ||
+ expect_bits[i] != (pixels[i].y > 0.5) ||
+ expect_bits[i] != (pixels[i].z > 0.5) ||
+ expect_bits[i] != (pixels[i].w > 0.5)) {
REQUIRE(0);
break;
}