SDL: Added a test case for snprintf of 0.0

From cdb4d8f22fc31b09e3f186f96c9e9f517662a558 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 7 Nov 2021 09:39:57 -0800
Subject: [PATCH] Added a test case for snprintf of 0.0

This verifies regressions in https://github.com/libsdl-org/SDL/issues/4795
---
 test/testautomation_stdlib.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index 9ea19649f9..608d92fc2b 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -64,6 +64,14 @@ stdlib_snprintf(void *arg)
   SDLTest_AssertPass("Call to SDL_snprintf(NULL, 0, \"%%s\", \"foo\")");
   SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result);
 
+  result = SDL_snprintf(text, sizeof(text), "%f", 0.0);
+  predicted = SDL_snprintf(NULL, 0, "%f", 0.0);
+  expected = "0.000000";
+  SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 0.0)");
+  SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
+  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
+  SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
+
   result = SDL_snprintf(text, sizeof(text), "%f", 1.0);
   predicted = SDL_snprintf(NULL, 0, "%f", 1.0);
   expected = "1.000000";