Google Test的简单使用
百里意智
2023-12-01
#pragma once
#include <conio.h>
#include <fcntl.h>
#include <io.h>
#include "gtest/gtest.h"
class CConsole
{
public:
CConsole(void)
{
AllocConsole();
int hCrun;
hCrun = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
FILE* hFile = _fdopen(hCrun, "w");
// use default stream buffer
setvbuf(hFile, NULL, _IONBF, 0);
*stdout = *hFile;
}
public:
~CConsole(void)
{
FreeConsole();
}
};
#define RUN_TEST() \
CConsole cc; \
int argc = 1; \
TCHAR* argv = _T("E:\xxxx\trunk\Bin\xxxx.exe"); \
testing::InitGoogleTest(&argc, &argv); \
RUN_ALL_TESTS(); \
HWND hwnd = GetConsoleWindow(); \
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); \
AfxMessageBox(_T("about to exit!")); \
exit(0);