VS2012下cocos2d-x3.0添加google test1.7

1 篇文章 0 订阅
1 篇文章 0 订阅



google test创建测试工程的资料请参考其它文章。

注意:cocos2d-x的win32工程默认是Multithreaded-debug DLL,所以修改gtest工程为这个(工程->属性->C/C++->Code Generation->Runtime Library),编译的lib给cocos2d-x就正常链接了。
其它按照gtest测试工程添加头,库和变量_VARIADIC_MAX=10。

然后修改win32下的main.cpp(我加入了一个#if是为了方便切换到测试模式。)

#include "main.h"
#include "AppDelegate.h"
#include "cocos2d.h"
#include <shellapi.h>  
#include <gtest\gtest.h>

int Foo(int a, int b){
 if (a == 0 || b == 0) {
  throw "don't do that";
 }

 int c = a % b;
 if (c == 0){
    return b; }

 return Foo(b, c);

}

TEST(FooTest, HandleNoneZeroInput){
 EXPECT_EQ(2, Foo(4, 10));
 EXPECT_EQ(6, Foo(30, 18));
}

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
#if 0 
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    return Application::getInstance()->run();

#else 


 AllocConsole();   //创建一个控制台  
 freopen("CONIN$","r",stdin);    //将标准输入输出流定位到这个控制台  
 freopen("CONOUT$","w",stdout);  
 freopen("CONOUT$","w",stderr);  

 LPWSTR *szArgList;
 int argCount;
 szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);

 testing::InitGoogleTest(&argCount, szArgList );
 RUN_ALL_TESTS();

 system("pause");
  FreeConsole();   
 return 0;    #endif

}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值