r/cpp • u/According_Leopard_80 • Feb 28 '26
Mocking the Standard Template Library
https://middleraster.github.io/TBCI/MockingTheSTL.htmlWriting a test double for just one function or type in the STL can be achieved with "Test Base Class Injection" and namespace shadowing.
18
Upvotes
50
u/lucidbadger Feb 28 '26
Having read this title, I hoped to see a witty and humorous trolling of STL or something...
12
u/grady_vuckovic Feb 28 '26
"Standard, yeah, good label for it, definitely doesn't feel like a premium library."
"The most common reaction to the STL: 'Is that it?'."
How's that?
1
u/eyes-are-fading-blue Feb 28 '26
Why not inject components of the class directly instead of a base that doesn’t tell what it is from the get-go?