Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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"


Ïà¹ØÎĵµ£º

ǶÈëʽLinuxµÄ¼üÅÌÇý¶¯ 1£¨Í¨¹ýI2CʵÏÖ£©

CPU£ºs3c2410
OS£ºLinux Kernel 2.6.30.4
×î½ü¸Õ×öÍêµÄǶÈëʽ¼üÅ̵ÄÇý¶¯£¬ÓÉÓÚ³õ´Î½Ó´¥£¬×ܽáһϡ£
Ê×Ïȼòµ¥ËµËµÕâ¸ö¼üÅ̵ÄʵÏÖÔ­Àí£¬IIC×ÜÏß¹¤×÷Ô­Àíû±ØÒª·Ï»°£¬s3c2410µÄÊÖ²áÖн²µÄºÜÃ÷°×¡£Ó²¼þ·½ÃæÕâ¸ö¼üÅÌͨ¹ýÒ»¸öAVRµ¥Æ¬»ú£¨ATMEGA48£©½ÓÔÚIIC×ÜÏßÉÏ£¬Ò²¾ÍÊÇ˵£¬Ö±½ÓÓëIIC×ÜÏßÁ´½ÓµÄÉ豸²¢²»ÊÇÎÒÃÇÓõļüÅÌ£¬¶øÊÇ ......

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


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

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

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

ͨѶ¼C³ÌÐò´úÂë

#include <stdio.h>
#include <string.h> /* ³ÌÐò¶à´Îµ÷ÓÃbiodkey()£¬Ó¦°üº¬Í·Îļþbios.h */
#include <bios.h><br>/* ³ÌÐò¶à´Îµ÷ÓÃclrscr()£¬Ó¦°üº¬Í·Îļþconio.h */
#include <conio.h>
#define MAX 100
#define PAGE 2
#define PRINT1 printf("------------------------------ ......

extern extern ¡°C¡±

externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©.
Ëü¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿ÉÒÔÔÚ±¾Ä£¿é»òÆäËüÄ£¿éÖÐʹÓá£
1¡£¶ÔÓÚextern±äÁ¿À´Ëµ£¬½ö½öÊÇÒ»¸ö±äÁ¿µÄÉùÃ÷£¬Æä²¢²»ÊÇÔÚ¶¨Òå·ÖÅäÄÚ´æ¿Õ¼ä¡£Èç¹û¸Ã±äÁ¿¶¨Òå¶à´Î£¬»áÓÐÁ¬½Ó´íÎó
2¡£Í¨³££¬ÔÚÄ£¿éµÄÍ·ÎļþÖжԱ¾Ä£¿éÌṩ¸øÆäËüÄ£¿éÒýÓõĺ¯ÊýºÍ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ