Your SlideShare is downloading. ×
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
20111018 boost and gtest
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

20111018 boost and gtest

641

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
641
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Boost &googletest Will Shen2011/10/17
  • 2. OutlineBoost • Smart pointer • Assign • oreach • bindgoogletest • Simple tests • Assertions2
  • 3. Hundred of boost libraries hpp hpp hpp + lib hpp + lib (.h+.cpp) (.h+.cpp) up to 90% without linking date_time filesystem regex program_otpions test thread python3
  • 4. Memory Leaking Cause of Evil - new/delete4
  • 5. boost – Smart pointer Cause of Evil - new/delete Managing memory in a smart way • std::auto_ptr  Ownership • boost::scoped_ptr  Non-copyable • boost:: shared_ptr  Reference counting5
  • 6. Stack and Heap Using Stack variable to manage Heap memory p1 Proxy fun() … stack heap6
  • 7. Different smart pointers Ownership, Non-copyable, Reference counting ap1 ap1 ap2 ap2 shp1 shp1 shp2 shp27
  • 8. Used in STL Container Both auto_ptr and scoped_ptr can not be used in STL container. vec[0 vec[0 ] e ] vec[1 vec[1 ] ] vec[2 vec[2 ] ]8
  • 9. scoped_array and shared_array operator[]9
  • 10. boost::assign – filling containers with data operator+=(), operator,() operator()()10
  • 11. boost::assign list_of - to initialize a container repeat, repeat_fun, range11
  • 12. boost::foreach BOOST_FOREACH, BOOST_REVERSE_FOREACH Supported Sequence Type • STL containers • arrays • Null-terminated strings (char and wchar_t) • std::pair of iterators12
  • 13. boost::foreach + typeof BOOST_TYPEOF13
  • 14. boost::bind A generalization of the standard functions std::bind1st and std::bind2nd. Supports: function objects, functions, function pointers, and member function pointers Able to bind any argument to a specific value or route input arguments into arbitrary positions. Function object14
  • 15. boost::bind - place holders _1, _2, …, _915
  • 16. Use boost::bind() in STL algorithm binding member function16
  • 17. googletest - Unit Testing Framework Execute test cases through the GUI Google test framework (gtest) • Easy to execute • Easy to implement test cases“Unicode Debug-test” configuration Execute test cases in console17
  • 18. gtest is more lightweight than cppunitCppunit gtest1. Write a test class derived from TestFixture 1. One TEST macro2. Write setup3. Write teardown4. Write test method5. Define test suite6. Context-switch between .h/.cpp files18
  • 19. Basic concepts Start by writing ASSERTIONS • statements that check whether a condition is true. • success, nonfatal failure, or fatal failure. A test case contains one or many tests. A test program can contain multiple test cases.19
  • 20. Assertions Basic Assertions, Binary Comparison, String Comparison20
  • 21. To Write Simple Tests Subject to be tested21
  • 22. Test Fixture - Using the Same Data Configuration for Multiple Tests SUTTestFixture Tests 22
  • 23. gtest folder in GMapShop project Tests23
  • 24. Recommended Books24
  • 25. Recommended Books25
  • 26. Recommended Books26
  • 27. Recommended Books27
  • 28. More to talk Code Smell Refactoring method Principles of Object-oriented Design • SRP, OCP, LSP, DSP, DIP28

×