• Save
20111018 boost and gtest
Upcoming SlideShare
Loading in...5
×
 

20111018 boost and gtest

on

  • 980 views

 

Statistics

Views

Total Views
980
Views on SlideShare
980
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

20111018 boost and gtest 20111018 boost and gtest Presentation Transcript

  • Boost &googletest Will Shen2011/10/17
  • OutlineBoost • Smart pointer • Assign • oreach • bindgoogletest • Simple tests • Assertions2
  • 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
  • Memory Leaking Cause of Evil - new/delete4
  • 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
  • Stack and Heap Using Stack variable to manage Heap memory p1 Proxy fun() … stack heap6
  • Different smart pointers Ownership, Non-copyable, Reference counting ap1 ap1 ap2 ap2 shp1 shp1 shp2 shp27
  • 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
  • scoped_array and shared_array operator[]9
  • boost::assign – filling containers with data operator+=(), operator,() operator()()10
  • boost::assign list_of - to initialize a container repeat, repeat_fun, range11
  • boost::foreach BOOST_FOREACH, BOOST_REVERSE_FOREACH Supported Sequence Type • STL containers • arrays • Null-terminated strings (char and wchar_t) • std::pair of iterators12
  • boost::foreach + typeof BOOST_TYPEOF13
  • 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
  • boost::bind - place holders _1, _2, …, _915
  • Use boost::bind() in STL algorithm binding member function16
  • 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
  • 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
  • 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
  • Assertions Basic Assertions, Binary Comparison, String Comparison20
  • To Write Simple Tests Subject to be tested21
  • Test Fixture - Using the Same Data Configuration for Multiple Tests SUTTestFixture Tests 22
  • gtest folder in GMapShop project Tests23
  • Recommended Books24
  • Recommended Books25
  • Recommended Books26
  • Recommended Books27
  • More to talk Code Smell Refactoring method Principles of Object-oriented Design • SRP, OCP, LSP, DSP, DIP28