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"
Ïà¹ØÎĵµ£º
XCode£ºÄã¿ÉÒÔ°ÑËü¿´³ÉÊÇÒ»¸ö¿ª·¢»·¾³£¬¾ÍºÃÏñVisual Studio»òÕßNetbeans»òÕßSharpDevelopÒ»ÑùµÄÍæ
Òâ¡£Äã¿ÉÒÔ½«Interface BuilderÈÏΪÊÇVisual StudioÖÐÓÃÀ´»½çÃæµÄÄDz¿·Ö¹¦Äܵ¥¶ÀÌá³öÀ´µÄ³ÌÐò¡£
Objective-C£ºÕâÊÇÒ»ÖÖÓïÑÔ£¬¾ÍºÃÏñc++ÊÇÒ»ÖÖÓïÑÔ£¬JavaÊÇÒ»ÖÖÓïÑÔ£¬c#ÊÇÒ»ÖÖÓïÑÔ£¬Ýº¸èÀúÊ·Ò²ÊÇÒ»
ÖÖÓïÑÔÒ»Ñù¡£
Coco ......
#include<stdio.h>
#include<math.h>
float x1,x2,disc,p,q;
int main()
{
void greater_than_zero(float,float);
void equal_to_zero(float,float);
void smaller_than_zero(float,float);
float a,b,c;
printf("\ninput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c) ......
µÚ¶þÕ Êý¾ÝÀàÐÍ
Ò»¡¢Êý¾ÝÀàÐÍ·ÖÀà
1 ÁªºÏÀàÐÍ
2 º¯ÊýÀàÐÍ
3 ÊýÁ¿ÀàÐÍ
3.1ËãÊõÀàÐÍ
¢Ù »ù±¾Êý¾ÝÀàÐÍ
ÕûÐÍ£¨°üÀ¨char£©
¸¡µãÐÍ ......
µÚ¶þÕ Õ÷·þ¿É²âÐÔÄÑÌâ
2.1 ¿É²âÐÔÎÊÌâÏê½â£¨1£©
µ¥Ôª²âÊÔÐ§ÒæÌØ±ð¸ß£¬·½·¨Ò²ºÜ¼òµ¥£¬µ«È´³¢ÊÔµÄÆóÒµºÜ¶à£¬³É¹¦ÊµÊ©µÄÆóÒµºÜÉÙ£¬ÎªÊ²Ã´ÄØ£¿Ö÷ÒªÔÒò¾ÍÊÇÄÑÓÚÍ»ÆÆ¿É²âÐÔÎÊÌâ¡£“¿É²â”Õâ¸ö´Ê£¬Òâ˼ÒѾºÜÃ÷°×ÁË£¬Èç¹û²»“¿É²â”µÄ»°£¬ÄǾÍÊDz»Äܲ⣬û·¨²â£¬¾ÍÊÇ× ......