QuickCheck++ã¯ãHaskellã§åºã使ããã¦ãããã¹ããã¬ã¼ã ã¯ã¼ã¯ã§ãã
QuickCheckãC++ã«ç§»æ¤ããã©ã¤ãã©ãªã§ãã
ããã¥ã¡ã³ãã¨ææ°çã¯ä»¥ä¸ã«ããã¾ãã
QuickCheck++ Documentation 0.0.2
Version 0.0.2ã§ã¯signed/unsignedå¨ãã§ãã°ãããã®ã§
generate.hhã以ä¸ãããã¦ã³ãã¼ããã¦ç½®ãæãã¦ãã ããã
ãã¦ãã§ã¯ä½¿ãæ¹ãè¦ã¦ããã¾ãããã
1.ã¤ã³ã¯ã«ã¼ã
QuickCheck++ã¯ããããã¡ã¤ã«ã®ã¿ã®ã©ã¤ãã©ãªãªã®ã§ã¤ã³ã¯ã«ã¼ãããã ãã§ãã使ãã¾ãã
#include <quickcheck/quickcheck.hh>
2.ãã¹ãããããããã£ã®ä½æ
以ä¸ã¯ãreverseã2åããçµæãå
ã«æ»ããã®ãã¹ãã¯ã©ã¹ã§ãã
quickcheck::Propertyã¯ã©ã¹ãç¶æ¿ãã¦ãholdsForã¡ã³ãé¢æ°ãå®ç¾©ãã¾ãã
class prop_reverse : public quickcheck::Property<Vector> { bool holdsFor(const Vector& xs) { Vector ys = xs; std::reverse(ys.begin(), ys.end()); std::reverse(ys.begin(), ys.end()); return xs == ys; } };
3.ãã¹ããã
ãã¹ãã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ãä½æããcheck()ã¡ã³ãé¢æ°ãå¼ã³ã¾ã
prop_reverse().check();
4.çµæ
ãã¹ãçµæãæ¨æºåºåã«åºåããã¾ãã
OK, passed 100 tests.
5. ãã¹ãã«å¤±æããå ´å
2åç®ã®reverseãã³ã¡ã³ãã¢ã¦ããã¦ãã¹ããã¦ã¿ã¾ãã
std::reverse(ys.begin(), ys.end());
//std::reverse(ys.begin(), ys.end());
ãã¹ãçµæã¨ãã¦ã失æããã±ã¼ã¹ãåºåãã¦ããã¾ãã
Falsifiable after 2 tests for input: 0: [1732365957, 410726649]
åºæ¬çã«ã¯ããã ãã§ãã
ãã¹ããã¼ã¿æ¸ãã¦ãªããï¼ã¨æãã§ããããã
QuickCheck++ã§ã¯ãã¹ããã¼ã¿ãã©ã³ãã ã«èªåçæãã¦ããã¾ãã
ããã©ã«ãã§ã¯ã100件ã®ãã¹ããã¼ã¿ãä½æãã¾ãã
ã©ããªãã¹ããã¼ã¿ãä½æããããè¦ããå ´åã¯ã
check()é¢æ°ã®å¼æ°ãè¨å®ãã¾ãã
prop_reverse().check(3, 0, true, std::cout);
ããã§ã¯ã
ãã¹ããã¼ã¿ï¼3件
æå¹ãªå¤ã®æ大å¤ï¼ããã©ã«ãå¤
詳細åºåï¼ON
åºåå
ï¼std::cout
ã«è¨å®ãã¦ãã¾ãã
以ä¸ã®ããã«åºåããã¾ãã
Test 0: 0: [] Test 1: 0: [1732365957, 410726649] Test 2: 0: [1116964137, 1395238485] OK, passed 3 tests.
ã©ã³ãã ãã¹ãã®å 容ã確èªããå¿ è¦ã¯ãã¾ããªãã®ã§ãé常ã¯è©³ç´°è¡¨ç¤ºã¯ãã¾ããã
次å以éãããã«èª¿ã¹ã¦ããã¾ãã