diff --git a/tests/test_opus_decode.c b/tests/test_opus_decode.c
index 74508a0e3d4e5e9e0262a1c061127d0035ed5509..ea970927bc435f376bcc654195fd89cacc079f32 100644
--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -36,7 +36,7 @@
 #include <math.h>
 #include <string.h>
 #include <time.h>
-#ifndef _WIN32
+#if (!defined WIN32 && !defined _WIN32) || defined(__MINGW32__)
 #include <unistd.h>
 #endif
 #include "opus.h"
diff --git a/tests/test_opus_encode.c b/tests/test_opus_encode.c
index 7d2ad655a4ae25ff1243f20e55fc25d2e503365f..9e1565dc03d00754b9a7368e3269ab22e7f64a63 100644
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -36,7 +36,7 @@
 #include <math.h>
 #include <string.h>
 #include <time.h>
-#ifndef _WIN32
+#if (!defined WIN32 && !defined _WIN32) || defined(__MINGW32__)
 #include <unistd.h>
 #endif
 #include "opus_multistream.h"