https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a800fa7bb2277771be141…
commit a800fa7bb2277771be14196f1a0f012776f8b260
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Aug 12 19:24:08 2019 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Aug 12 19:24:08 2019 +0900
[ATL_APITEST] Add 'atltest.h' and use it (#1822)
- Add "atltest.h" header file for common use in atl_apitest.
- Delete the duplicated and simplify.
---
modules/rostests/apitests/atl/CAtlArray.cpp | 27 +----
modules/rostests/apitests/atl/CAtlFileMapping.cpp | 59 +--------
modules/rostests/apitests/atl/CAtlList.cpp | 27 +----
modules/rostests/apitests/atl/CComObject.cpp | 27 +----
modules/rostests/apitests/atl/CComQIPtr.cpp | 27 +----
modules/rostests/apitests/atl/CImage.cpp | 27 +----
modules/rostests/apitests/atl/CSimpleArray.cpp | 27 +----
modules/rostests/apitests/atl/CSimpleMap.cpp | 27 +----
modules/rostests/apitests/atl/CString.cpp | 59 +--------
modules/rostests/apitests/atl/atltest.h | 138 ++++++++++++++++++++++
10 files changed, 147 insertions(+), 298 deletions(-)
diff --git a/modules/rostests/apitests/atl/CAtlArray.cpp
b/modules/rostests/apitests/atl/CAtlArray.cpp
index 8527c4ac47d..b1e654bf109 100644
--- a/modules/rostests/apitests/atl/CAtlArray.cpp
+++ b/modules/rostests/apitests/atl/CAtlArray.cpp
@@ -9,27 +9,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, bool value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
#include <atlbase.h>
@@ -161,9 +141,4 @@ START_TEST(CAtlArray)
ok(CCreature::s_nCCtorCount == 1, "Expected CCreature::s_nCCtorCount is 1, was:
%d\n", CCreature::s_nCCtorCount);
ok(CCreature::s_nDtorCount == 102, "Expected CCreature::s_nDtorCount is 102,
was: %d\n", CCreature::s_nDtorCount);
ok(CCreature::s_nOpIsCount == 1, "Expected CCreature::s_nOpIsCount is 1, was:
%d\n", CCreature::s_nOpIsCount);
-
-#ifndef HAVE_APITEST
- printf("CAtlArray: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CAtlFileMapping.cpp
b/modules/rostests/apitests/atl/CAtlFileMapping.cpp
index 0e0ef5909c9..c0e2348d170 100644
--- a/modules/rostests/apitests/atl/CAtlFileMapping.cpp
+++ b/modules/rostests/apitests/atl/CAtlFileMapping.cpp
@@ -10,59 +10,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <windows.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- int g_tests_skipped = 0;
- const char *g_file = NULL;
- int g_line = 0;
- void set_location(const char *file, int line)
- {
- g_file = file;
- g_line = line;
- }
- void ok_func(int value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", g_file, g_line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- void skip_func(const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- printf("%s (%d): test skipped: ", g_file, g_line);
- vprintf(fmt, va);
- g_tests_skipped++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) do { \
- set_location(__FILE__, __LINE__); \
- ok_func(value, __VA_ARGS__); \
- } while (0)
- #define ok_(x1,x2) set_location(x1,x2); ok_func
- #define skip(...) do { \
- set_location(__FILE__, __LINE__); \
- skip_func(__VA_ARGS__); \
- } while (0)
- #define START_TEST(x) int main()
- char *wine_dbgstr_w(const wchar_t *wstr)
- {
- static char buf[512];
- WideCharToMultiByte(CP_ACP, 0, wstr, -1, buf, _countof(buf), NULL, NULL);
- return buf;
- }
+ #include "atltest.h"
#endif
struct TestData
@@ -246,9 +194,4 @@ START_TEST(CAtlFileMapping)
{
test_SharedMem();
test_FileMapping();
-
-#ifndef HAVE_APITEST
- printf("CAtlFile: %i tests executed (0 marked as todo, %i failures), %i
skipped.\n", g_tests_executed, g_tests_failed, g_tests_skipped);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CAtlList.cpp
b/modules/rostests/apitests/atl/CAtlList.cpp
index eb8cb761620..1f5e4c7d789 100644
--- a/modules/rostests/apitests/atl/CAtlList.cpp
+++ b/modules/rostests/apitests/atl/CAtlList.cpp
@@ -9,27 +9,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, bool value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
#include <atlbase.h>
@@ -73,9 +53,4 @@ START_TEST(CAtlList)
index++;
}
ok(it == NULL, "it does still point to something!\n");
-
-#ifndef HAVE_APITEST
- printf("CAtlList: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CComObject.cpp
b/modules/rostests/apitests/atl/CComObject.cpp
index e40e0b8f691..396290dfd5e 100644
--- a/modules/rostests/apitests/atl/CComObject.cpp
+++ b/modules/rostests/apitests/atl/CComObject.cpp
@@ -12,27 +12,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, BOOL value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
@@ -141,9 +121,4 @@ START_TEST(CComObject)
ok(g_DTOR == 1, "Expected 1, got %lu\n", g_DTOR);
ok(g_BLIND == 1, "Expected 1, got %lu\n", g_BLIND);
}
-
-#ifndef HAVE_APITEST
- printf("CComObject: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CComQIPtr.cpp
b/modules/rostests/apitests/atl/CComQIPtr.cpp
index 677e6231890..f662d15028b 100644
--- a/modules/rostests/apitests/atl/CComQIPtr.cpp
+++ b/modules/rostests/apitests/atl/CComQIPtr.cpp
@@ -11,27 +11,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, BOOL value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
@@ -154,9 +134,4 @@ START_TEST(CComQIPtr)
#endif
ok(g_QI == 5, "Expected g_QI 5, got %lu\n", g_QI);
}
-
-#ifndef HAVE_APITEST
- printf("CComQIPtr: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CImage.cpp
b/modules/rostests/apitests/atl/CImage.cpp
index 1692cd71a48..f2dd08481ec 100644
--- a/modules/rostests/apitests/atl/CImage.cpp
+++ b/modules/rostests/apitests/atl/CImage.cpp
@@ -11,27 +11,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, BOOL value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
const TCHAR* szFiles[] = {
@@ -331,9 +311,4 @@ START_TEST(CImage)
ok(lstrcmpA(psz, "All Image
Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.TIFF;*.PNG;*.ICO|BMP
(*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|JPEG
(*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF (*.GIF)|*.GIF|EMF
(*.EMF)|*.EMF|WMF (*.WMF)|*.WMF|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|PNG (*.PNG)|*.PNG|ICO
(*.ICO)|*.ICO||") == 0,
"The exporter filter string is bad, was: %s\n", psz);
#endif
-
-#ifndef HAVE_APITEST
- printf("CImage: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CSimpleArray.cpp
b/modules/rostests/apitests/atl/CSimpleArray.cpp
index 80603066440..dcb6c5661cf 100644
--- a/modules/rostests/apitests/atl/CSimpleArray.cpp
+++ b/modules/rostests/apitests/atl/CSimpleArray.cpp
@@ -8,27 +8,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, bool value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
#include <atlbase.h>
@@ -178,9 +158,4 @@ START_TEST(CSimpleArray)
}
ok(!!array1.RemoveAt(0), "Expected RemoveAt(0) to succeed\n");
ok(array1.GetSize() == 0, "Expected array1.GetSize() is 0, was: %d\n",
array1.GetSize());
-
-#ifndef HAVE_APITEST
- printf("CSimpleArray: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CSimpleMap.cpp
b/modules/rostests/apitests/atl/CSimpleMap.cpp
index 2d1afb9c8d7..f21e9831be4 100644
--- a/modules/rostests/apitests/atl/CSimpleMap.cpp
+++ b/modules/rostests/apitests/atl/CSimpleMap.cpp
@@ -8,27 +8,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- void ok_func(const char *file, int line, bool value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", file, line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
- #define START_TEST(x) int main(void)
+ #include "atltest.h"
#endif
#include <atlbase.h>
@@ -198,9 +178,4 @@ START_TEST(CSimpleMap)
ok(map1.GetSize() == 1, "Expected map1's size is 1, was %d\n",
map1.GetSize());
ok(!!map1.RemoveAt(0), "Expected RemoveAt(0) to succeed\n");
ok(map1.GetSize() == 0, "Expected map1's size is 0, was %d\n",
map1.GetSize());
-
-#ifndef HAVE_APITEST
- printf("CSimpleMap: %i tests executed (0 marked as todo, %i failures), 0
skipped.\n", g_tests_executed, g_tests_failed);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/CString.cpp
b/modules/rostests/apitests/atl/CString.cpp
index 22ce8dfc0dc..bb96f3f7d8b 100644
--- a/modules/rostests/apitests/atl/CString.cpp
+++ b/modules/rostests/apitests/atl/CString.cpp
@@ -12,59 +12,7 @@
#ifdef HAVE_APITEST
#include <apitest.h>
#else
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <windows.h>
- int g_tests_executed = 0;
- int g_tests_failed = 0;
- int g_tests_skipped = 0;
- const char *g_file = NULL;
- int g_line = 0;
- void set_location(const char *file, int line)
- {
- g_file = file;
- g_line = line;
- }
- void ok_func(int value, const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- if (!value)
- {
- printf("%s (%d): ", g_file, g_line);
- vprintf(fmt, va);
- g_tests_failed++;
- }
- g_tests_executed++;
- va_end(va);
- }
- void skip_func(const char *fmt, ...)
- {
- va_list va;
- va_start(va, fmt);
- printf("%s (%d): test skipped: ", g_file, g_line);
- vprintf(fmt, va);
- g_tests_skipped++;
- va_end(va);
- }
- #undef ok
- #define ok(value, ...) do { \
- set_location(__FILE__, __LINE__); \
- ok_func(value, __VA_ARGS__); \
- } while (0)
- #define ok_(x1,x2) set_location(x1,x2); ok_func
- #define skip(...) do { \
- set_location(__FILE__, __LINE__); \
- skip_func(__VA_ARGS__); \
- } while (0)
- #define START_TEST(x) int main(void)
- char *wine_dbgstr_w(const wchar_t *wstr)
- {
- static char buf[512];
- WideCharToMultiByte(CP_ACP, 0, wstr, -1, buf, _countof(buf), NULL, NULL);
- return buf;
- }
+ #include "atltest.h"
#endif
struct traits_test
@@ -256,9 +204,4 @@ START_TEST(CString)
test_bstrW();
test_bstrA();
-
-#ifndef HAVE_APITEST
- printf("CString: %i tests executed (0 marked as todo, %i failures), %i
skipped.\n", g_tests_executed, g_tests_failed, g_tests_skipped);
- return g_tests_failed;
-#endif
}
diff --git a/modules/rostests/apitests/atl/atltest.h
b/modules/rostests/apitests/atl/atltest.h
new file mode 100644
index 00000000000..9fb1ede6ac5
--- /dev/null
+++ b/modules/rostests/apitests/atl/atltest.h
@@ -0,0 +1,138 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE: Testing
+ * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com)
+ */
+
+#ifndef ATLTEST_H_
+#define ATLTEST_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#ifndef _INC_WINDOWS
+ #include <windows.h>
+#endif
+
+int g_atltest_executed = 0;
+int g_atltest_failed = 0;
+int g_atltest_skipped = 0;
+
+const char *g_atltest_file = NULL;
+int g_atltest_line = 0;
+
+void atltest_set_location(const char *file, int line)
+{
+ g_atltest_file = file;
+ g_atltest_line = line;
+}
+
+void atltest_ok(int value, const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ if (!value)
+ {
+ printf("%s (%d): ", g_atltest_file, g_atltest_line);
+ vprintf(fmt, va);
+ g_atltest_failed++;
+ }
+ g_atltest_executed++;
+ va_end(va);
+}
+
+void atltest_skip(const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ printf("%s (%d): test skipped: ", g_atltest_file, g_atltest_line);
+ vprintf(fmt, va);
+ g_atltest_skipped++;
+ va_end(va);
+}
+
+#undef ok
+#define ok(value, ...) do { \
+ atltest_set_location(__FILE__, __LINE__); \
+ atltest_ok(value, __VA_ARGS__); \
+} while (0)
+#define ok_(x1,x2) atltest_set_location(x1,x2); atltest_ok
+
+#undef skip
+#define skip(...) do { \
+ atltest_set_location(__FILE__, __LINE__); \
+ atltest_skip(__VA_ARGS__); \
+} while (0)
+
+#undef trace
+#define trace printf
+
+static void atltest_start_test(void);
+extern const char *g_atltest_name;
+
+#define START_TEST(x) \
+ const char *g_atltest_name = #x; \
+ static void atltest_start_test(void)
+
+int main(void)
+{
+ atltest_start_test();
+ printf("%s: %d tests executed (0 marked as todo, %d failures), %d
skipped.\n",
+ g_atltest_name, g_atltest_executed, g_atltest_failed, g_atltest_skipped);
+ return g_atltest_failed;
+}
+
+char *wine_dbgstr_w(const wchar_t *wstr)
+{
+ static char buf[512];
+ WideCharToMultiByte(CP_ACP, 0, wstr, -1, buf, _countof(buf), NULL, NULL);
+ return buf;
+}
+
+#define ok_hex(expression, result) \
+ do { \
+ int _value = (expression); \
+ ok(_value == (result), "Wrong value for '%s', expected: "
#result " (0x%x), got: 0x%x\n", \
+ #expression, (int)(result), _value); \
+ } while (0)
+
+#define ok_dec(expression, result) \
+ do { \
+ int _value = (expression); \
+ ok(_value == (result), "Wrong value for '%s', expected: "
#result " (%d), got: %d\n", \
+ #expression, (int)(result), _value); \
+ } while (0)
+
+#define ok_ptr(expression, result) \
+ do { \
+ void *_value = (expression); \
+ ok(_value == (result), "Wrong value for '%s', expected: "
#result " (%p), got: %p\n", \
+ #expression, (void*)(result), _value); \
+ } while (0)
+
+#define ok_size_t(expression, result) \
+ do { \
+ size_t _value = (expression); \
+ ok(_value == (result), "Wrong value for '%s', expected: "
#result " (%Ix), got: %Ix\n", \
+ #expression, (size_t)(result), _value); \
+ } while (0)
+
+#define ok_char(expression, result) ok_hex(expression, result)
+
+#define ok_err(error) \
+ ok(GetLastError() == (error), "Wrong last error. Expected " #error ",
got 0x%lx\n", GetLastError())
+
+#define ok_str(x, y) \
+ ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got
'%s'\n", y, x)
+
+#define ok_wstr(x, y) \
+ ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got
'%S'\n", y, x)
+
+#define ok_long(expression, result) ok_hex(expression, result)
+#define ok_int(expression, result) ok_dec(expression, result)
+#define ok_ntstatus(status, expected) ok_hex(status, expected)
+#define ok_hdl ok_ptr
+
+#endif /* ndef ATLTEST_H_ */