mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
[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.
This commit is contained in:
parent
610b852451
commit
a800fa7bb2
10 changed files with 147 additions and 298 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
138
modules/rostests/apitests/atl/atltest.h
Normal file
138
modules/rostests/apitests/atl/atltest.h
Normal file
|
@ -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@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_ */
|
Loading…
Reference in a new issue