Google Test的简单使用

随笔1天前发布 深刻
4 0 0

#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 runkBinxxxx.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);

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...