Skip to content

Commit

Permalink
Merge pull request #12 from warasilapm/develop
Browse files Browse the repository at this point in the history
Add test for string longer than output buffer size
  • Loading branch information
MaJerle committed Dec 23, 2021
2 parents 1a30736 + 75116f3 commit 9c29acf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dev/VisualStudio/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdint.h>
#include "windows.h"

#define TEST_BUF_SIZE (255)

typedef struct {
char* format; /*!< Input format */
char* input_data; /*!< Input parameters */
Expand Down Expand Up @@ -64,7 +66,7 @@ printf_run_fn(const char* expected, const char* fmt, ...) {
test_data_t* test;

/* Temporary strings array */
char b1[255] = { 0 }, b2[sizeof(b1)] = { 0 };
char b1[TEST_BUF_SIZE] = { 0 }, b2[sizeof(b1)] = { 0 };
int l1, l2;

/* Set variables to non-0 values */
Expand Down Expand Up @@ -259,6 +261,11 @@ main(void) {
printf_run(NULL, "%.3s", "");
printf_run(NULL, "%yunknown", "");

/* Source string which exceeds output buffer size */
char c[TEST_BUF_SIZE+10];
memset(c, 0x5a5a5a5a, sizeof(c));
printf_run(NULL, "%s", c);

/* Alternate form */
printf_run(NULL, "%#2X", 123);
printf_run(NULL, "%#2x", 123);
Expand Down

0 comments on commit 9c29acf

Please sign in to comment.