Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C³ÌÐò£ºÊ¹Óà googletest ²âÊÔ¿ò¼Ü

googletest C/C++ ²âÊÔ¿ò¼Ü·Ç³£ºÃÓ㬽éÉܼ°ÏÂÔØÇë¿´  http://code.google.com/p/googletest/
//============================================================================
// ʹÓà googletest ²âÊÔ¿ò¼Ü
//============================================================================

// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
int Factorial(int n)
{
int result = 1;
for (int i = 1; i <= n; i++)
{
result *= i;
}

return result;
}

#include "src/gtest-all.cc"

// Tests Factorial().
// Tests factorial of negative numbers.
TEST(FactorialTest, Negative)
{
EXPECT_EQ(1, Factorial(-5));
EXPECT_EQ(1, Factorial(-1));
EXPECT_TRUE(Factorial(-10)> 0);
}

// Tests factorial of 0.
TEST(FactorialTest, Zero)
{
EXPECT_EQ(1, Factorial(0));
}

// Tests factorial of positive numbers.
TEST(FactorialTest, Positive)
{
EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8));
}

#include "src/gtest_main.cc"


Ïà¹ØÎĵµ£º

C/C++ÃüÃû¹æÔò


ÔÚÈí¼þ¿ª·¢ÕâÒ»¸ß¶È³éÏó¶øÇÒÊ®·Ö¸´ÔӵĻÖУ¬ÃüÃû¹æÔòµÄÖØÒªÐÔ¸üÏÔµÃÓÈΪͻ³ö¡£Ò»Ì׶¨ÒåÁ¼ºÃ²¢ÇÒÍêÕûµÄ¡¢ÔÚÕû¸öÏîÄ¿ÖÐͳһʹÓõÄÃüÃû¹æ·¶½«´ó´óÌáÉýÔ´´úÂëµÄ¿É¶ÁÐÔºÍÈí¼þµÄ¿Éά»¤ÐÔ¡£
ÔÚÒýÈëϸ½Ú֮ǰ£¬ÏÈ˵Ã÷Ò»ÏÂÃüÃû¹æ·¶µÄÕûÌåÔ­Ôò£º
 
ͬһÐÔ
ÔÚ±àдһ¸ö×ÓÄ£¿é»òÅÉÉúÀàµÄʱºò£¬Òª×ñÑ­Æä»ùÀà»òÕûÌåÄ£¿éµÄÃüÃû ......

C/C++ ³ÌÐòÉè¼ÆԱӦƸ³£¼ûÃæÊÔÊÔÌâÉîÈëÆÊÎöÖ®Èý


ÊÔÌâ5£º±àдһ¸öº¯Êý£¬×÷ÓÃÊÇ°ÑÒ»¸öchar×é³ÉµÄ×Ö·û´®Ñ­»·ÓÒÒÆn¸ö¡£±ÈÈçÔ­À´ÊÇ“abcdefghi”Èç¹ûn=2£¬ÒÆλºóÓ¦¸ÃÊÇ“hiabcdefgh” 
¡¡¡¡º¯ÊýÍ·ÊÇÕâÑùµÄ£º
//pStrÊÇÖ¸ÏòÒÔ'\0'½áβµÄ×Ö·û´®µÄÖ¸Õë
//stepsÊÇÒªÇóÒƶ¯µÄn
void LoopMove ( char * pStr, int steps )
{
¡¡//ÇëÌî³ä...
}
¡¡¡¡½ ......

C/C++µ¥Ôª²âÊÔÀíÂÛ¾«Òª£¨ËÄ£©

ÌâÍâƪ£ºµ¥Ôª²âÊÔÄÑÓÚ³¤ÆÚ¼á³ÖµÄÔ­ÒòÓë½â¾ö̽ÌÖ
    ÉÏһƪ¡¶µ¥Ôª²âÊÔЧÒæ¡·£¬ÓÐÍøÓÑÆÀÂÛ˵£º“µ¥Ôª²âÊԵĺô¦»ù±¾ÈËÈËÖªµÀ£¬¾ÍÊÇÄѼá³Ö£¡”¡£ÕâÒ»ÆÀÂÛÑÏÖØÌáÐÑÁËÎÒ£¬²»´í£¬“ÄѼá³Ö”Ò²ÊÇÒ»¸öÆÕ±éÏÖ×´¡£Èç¹û²»Äܼá³Ö£¬ÄÇÒ»Çж¼ÊÇ°×´î¡£Òò´Ë£¬ÕâÀï²åÈëÒ»¸öÌâÍâƪ£¬Ì½ÌÖµ¥Ôª²âÊÔÄÑÓÚ³¤Æ ......

C/C++Öж¯Ì¬Á´½Ó¿âµÄ´´½¨ºÍµ÷ÓÃ

ת×Ô£ºhttp://dev.yesky.com/12/3067012.shtml
¶¯Ì¬Á¬½Ó¿âµÄ´´½¨²½Ö裺
¡¡¡¡Ò»¡¢´´½¨Non-MFC DLL¶¯Ì¬Á´½Ó¿â
¡¡¡¡1¡¢´ò¿ªFile —> New —> ProjectÑ¡ÏѡÔñWin32 Dynamic-Link Library —>sample project
¡¡¡¡—>¹¤³ÌÃû£ºDllDemo
¡¡¡¡2¡¢Ð½¨Ò»¸ö.hÎļþDllDemo.h
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ