fputc, fwrite tests: Avoid test failure on MSVC.
[gnulib.git] / tests / test-fwrite.c
index d5d47a1..f6699eb 100644 (file)
@@ -26,6 +26,8 @@ SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *));
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "msvc-inval.h"
+
 #include "macros.h"
 
 int
@@ -33,6 +35,12 @@ main (int argc, char **argv)
 {
   const char *filename = "test-fwrite.txt";
 
+  /* We don't have an fwrite() function that installs an invalid parameter
+     handler so far.  So install that handler here, explicitly.  */
+#if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+  gl_msvc_inval_ensure_handler ();
+#endif
+
   /* Test that fwrite() on an unbuffered stream sets errno if someone else
      closes the stream fd behind the back of stdio.  */
   {