Sign In
Forgot Password?
Sign In | | Create Account

C++ Q&A

Colin Walls

Colin Walls

Posted May 15, 2014
2 Comments

As my interest in C++ continues, I have been soliciting questions about C++ for embedded on various social media platforms. I you have a question, please email or tweet and I will do my best to answer it.

Here is a question that came in yesterday:

How testable is C++, specifically for constructs like abstract classes, templates, exceptions?

This is quite a complex question to address, partly because it can be hard to separate “testing” from “debugging”. Taking these example constructs, classes and templates may largely be tested by means of instantiations. For a temple, for example, you need to write a test harness that instantiates the template using a variety of likely data types and verify that the resulting code is valid. Exception handling is a different issue. There are a finite number of exception types to test, so the test harness just needs to include code that throws each one. Then it is a question of ensuring that the right catch block is invoked for each exception [and that the code therein does what is required].

Maybe the questioner has a broader concern, in which case they are invited come back with clarification.

More Blog Posts

About Colin Walls Follow on Twitter

Colin WallsI have over twenty-five years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, I am a member of the marketing team of the Mentor Graphics Embedded Systems Division, and am based in the UK. Away from work, I have a wide range of interests including photography and trying to point my two daughters in the right direction in life. Learn more about Colin, including his go-to karaoke song and the best parts of being British: http://go.mentor.com/3_acv Visit The Colin Walls Blog

More Posts by Colin Walls

Comments 2

Post a Comment
Hi Colin, I attended your online lecture on C++ yesterday and found it really informative. Looking forward to learn more from you. What do you think of using a C++ testing framework like Google Mock and Google Test. Came across an application where unit tests were written using these two ?

Muhammad Yasir Khan
5:43 PM May 20, 2014

Glad you are enjoying the class Muhammad. I think that any tool that makes unit testing easy is a good thing. IMHO, C++ for embedded is most successful when doing a bottom up implementation and testing/measuring as you go.

Colin Walls
8:22 AM May 21, 2014

Add Your Comment

Please complete the following information to comment or sign in.

(Your email will not be published)

Archives

 
Online Chat