当前位置: 首页 > news >正文

东莞做网站的公司吗微信微商城怎么进入

东莞做网站的公司吗,微信微商城怎么进入,北京 公司网站 备案中 开通访问,重庆建设人才网0. 引子 本例是从 gtest-1.5.0 自带的 sample 中的 sample1 改写而来#xff0c;笔者只添加了一个求 n 的阶层的函数#xff0c;如下。 void Factorial(int n, int result ) { result 1; for (int i 1; i n; i) result * i; } 目的是想测试像这样将返回值放在参… 0. 引子 本例是从 gtest-1.5.0 自带的 sample 中的 sample1 改写而来笔者只添加了一个求 n 的阶层的函数如下。 void Factorial(int n, int  result ) {     result 1;     for (int i 1; i n; i)         result * i; } 目的是想测试像这样将返回值放在参数中返回的函数。 对于该函数添加的单元测试代码如下。 TEST (FactorialTest , Mytest ) {     int result 0;     Factorial (5, result);     EXPECT_EQ (120, result); } 1. 要测试的代码 要测试的代码 (Sample.h) 代码如下。 [c-sharp] view plaincopy /**   * GoogleTest test   * platform: win32, visual studio 2005/2010; Linux, gcc4.1.2   */   #ifndef _SAMPLE_H_   #define _SAMPLE_H_   // Returns n! (the factorial of n).  For negative n, n! is defined to be 1.   int Factorial(int n);   void Factorial(int n, int result);   // Returns true iff n is a prime number.   bool IsPrime(int n);   #endif   要测试的代码 (Sample.cpp) 代码如下。 [cpp] view plaincopy /**   * GoogleTest test   * platform: win32, visual studio 2005/2010; Linux, gcc4.1.2   */   #include sample.h   // 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;   }   void Factorial(int n, int result)   {       result  1;       for (int i  1; i  n; i)           result * i;   }      // Returns true iff n is a prime number.   bool IsPrime(int n)   {       // Trivial case 1: small numbers       if (n  1)           return false;       // Trivial case 2: even numbers       if (n % 2  0)           return n2;       // Now, we have that n is odd and n  3.       // Try to divide n by every odd number i, starting from 3       for (int i  3; ; i  2)       {           // We only have to try i up to the squre root of n           if (i  n/i)               break;           // Now, we have i  n/i  n.           // If n is divisible by i, n is not prime.           if (n % i  0)               return false;       }       // n has no integer factor in the range (1, n), and thus is prime.       return true;   }   2. 单元测试代码 单元测试代码 (test.cpp) 如下。 [cpp] view plaincopy /**   * GoogleTest test   * platform: win32, visual studio 2005/2010; Linux, gcc4.1.2   */   #include sample.h   #include gtest/gtest.h   // Step 2. Use the TEST macro to define your tests.   // Tests Factorial().   // Tests factorial of negative numbers.   // Test Case name is FactorialTest, Test name is Negative   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));   }   TEST(FactorialTest, Mytest)   {       int result  0;       Factorial(5, result);       EXPECT_EQ(120, result);   }   // Tests IsPrime()   // Tests negative input.   TEST(IsPrimeTest, Negative)   {       EXPECT_FALSE(IsPrime(-1));       EXPECT_FALSE(IsPrime(-2));       EXPECT_FALSE(IsPrime(INT_MIN));   }   // Tests some trivial cases.   TEST(IsPrimeTest, Trivial)   {       EXPECT_FALSE(IsPrime(0));       EXPECT_FALSE(IsPrime(1));       EXPECT_TRUE(IsPrime(2));       EXPECT_TRUE(IsPrime(3));   }   // Tests positive input.   TEST(IsPrimeTest, Positive)   {       EXPECT_FALSE(IsPrime(4));       EXPECT_TRUE(IsPrime(5));       EXPECT_FALSE(IsPrime(6));       EXPECT_TRUE(IsPrime(23));   }      // Step 3. Call RUN_ALL_TESTS() in main().   //   // We do this by linking in src/gtest_main.cc file, which consists of   // a main() function which calls RUN_ALL_TESTS() for us.   //   // This runs all the tests youve defined, prints the result, and   // returns 0 if successful, or 1 otherwise.   //   // Did you notice that we didnt register the tests?  The   // RUN_ALL_TESTS() macro magically knows about all the tests we   // defined.  Isnt this convenient?   3. 编译 3.1 Linux 平台 makefile 文件请参考 “ Linux平台如何编译使用Google test写的单元测试 ” 3.2 Win32 平台 Make.bat 文件请参考 “ Win32 平台如何编译使用 Google test 编 写的单元测试 ” 。 4. 运行结果 4.1 Linux 平台 运行结果如下。 # ./test Running main() from gtest_main.cc [] Running 7 tests from 2 test cases. [----------] Global test environment set-up. [----------] 4 tests from FactorialTest [ RUN      ] FactorialTest.Negative [       OK ] FactorialTest.Negative (0 ms) [ RUN      ] FactorialTest.Zero [       OK ] FactorialTest.Zero (0 ms) [ RUN      ] FactorialTest.Positive [       OK ] FactorialTest.Positive (0 ms) [ RUN      ] FactorialTest.Mytest [       OK ] FactorialTest.Mytest (0 ms) [----------] 4 tests from FactorialTest (0 ms total)   [----------] 3 tests from IsPrimeTest [ RUN      ] IsPrimeTest.Negative [       OK ] IsPrimeTest.Negative (0 ms) [ RUN      ] IsPrimeTest.Trivial [       OK ] IsPrimeTest.Trivial (0 ms) [ RUN      ] IsPrimeTest.Positive [       OK ] IsPrimeTest.Positive (0 ms) [----------] 3 tests from IsPrimeTest (0 ms total)   [----------] Global test environment tear-down [] 7 tests from 2 test cases ran. (0 ms total) [  PASSED  ] 7 tests. 7 个测试均通过。 4.2 Win32 平台 运行结果如下。
http://www.zqtcl.cn/news/781860/

相关文章:

  • 剑灵网站模板效果图网站源码
  • 个人工作室网站源码带后台安徽服装网站建设
  • SEO案例网站建设公司好听的公司名字大全
  • 一些网站只能在微信打开怎么做的别人做的网站域名到期怎么办
  • 姑苏区做网站网站建设一条
  • 赣州人才网站wordpress论坛查看用户密码
  • asp.net 网站开发架构网站你懂我意思正能量不用下载视频
  • 沈阳网站设计推广诸暨网络推广
  • 福建网站开发公司电话成都丁香人才网官网专区
  • 做网站标题居中代码对网页设计作品的意见
  • 网站建设实训考试普洱网站搭建
  • 你认为视频网站如何做推广asp网站木马扫描
  • 学校门户网站什么意思c2c网站建设要多少钱
  • asp怎么样做网站后台陕西咸阳做网站的公司
  • 手机网站模板wordpress编辑图像
  • 汉语国际网站建设靖江做网站的
  • 网站防止采集如何运行安装wordpress
  • 高端论坛网站建设忘记了wordpress登录密码忘记
  • 哈尔滨网站运营服务商wordpress 访问缓慢
  • 织梦网站上传及安装定制网站建设广告
  • 阳光创信-网站建设首选品牌wordpress rss插件
  • 钦州网站建设公司哪家好邢台制作
  • 网站广告赚钱吗中国小型加工机械网
  • 2015做网站前景东莞公司的网页怎么做的
  • 专业网站设计制作过程网站什么模板做的
  • 如何制作网页的软件网站推广与搜索引擎优化
  • 四川内江网站建设太原网站建设网格未来
  • 陕西 网站建设 陕ICP创建商务站点的主要工作
  • 做照明出口的网站深圳 网站制作
  • 门户网站建设 简报嘉兴设计公司有哪些