Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get familiar with C++ #2

Open
13 tasks done
nike0good opened this issue Apr 8, 2019 · 5 comments
Open
13 tasks done

Get familiar with C++ #2

nike0good opened this issue Apr 8, 2019 · 5 comments

Comments

@nike0good
Copy link
Owner

nike0good commented Apr 8, 2019

@nike0good
Copy link
Owner Author

nike0good commented Apr 9, 2019

Michael VanLoon “STL Algorithms in Action ”

STL in C++ is useful. By using STL, we spend less time coding and focus on other important things. For instance, by using accumulate(s.begin(),s.end()), which is used for calc the sum of a container, we can save time in writing sth. like:

ll ans=0;
for(auto p:s) ans+=p;
return p;

There are various useful algorithms:

 - sort
 - nth_element
 - rotate(it_fir, it_mid, it_end)
 - slide
 - gather //means gather element with same types together
 - set_difference(a.begin(),a.end(),b.begin(),b.end().back_inserter(new_items)); // return new_items (set of what is exist in $a$ and not exist in $b$ )
 - stable_partition

WeChat Image_20210522165425

@nike0good
Copy link
Owner Author

nike0good commented Apr 9, 2019

T. Winters & H. Wright “All Your Tests are Terrible..."

How to make good tests?

Correctness

  • executing real scenarios
  • not depend upon known bugs

Readability

  • avoid too much boilerplate or distraction
  • enough context
  • no advanced test framework feature if it is not necessary

Completeness

  • common inputs, corner cases, outlandish cases
  • only tests API behaves properly while it uses that API

Demonstrability

  • not reliance on private/friend/TestOnly method

Resilience

  • avoid flaky tests, brittle tests, test depend on execution ordering, mocks with deep dependence upon underlying API, non-hermetic tests.
    WeChat Image_20210522165515

nike0good pushed a commit that referenced this issue Apr 12, 2021
@nike0good
Copy link
Owner Author

nike0good commented May 13, 2021

WeChat Image_20210522170942

img4

@nike0good
Copy link
Owner Author

img5

@nike0good
Copy link
Owner Author

nike0good commented May 13, 2021

img6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant