Unit testing with cpptest

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

Unit testing is a fundamental activity in software development, even if not as widespread as it should. As C++ has been around for quite some time, several libraries are available for carrying out this activity. This week I’ve had a look at cpptest. In the future, I plan to compare compare it to another pretty popular test library, googletest.

Read More

The SQLite3 C++ API

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

I was looking for some practice with DBs, and my choice fell on the SQLite project, maybe only because it looked lighter than PostgreSQL, which I also plan to play with. My first general impression about the API is that it looks a little too much C-oriented, even though I am not sure whether this is a good or a bad thing, and I am ignorant about the latitude of choice an engineer has when designing an API that has to interact with applications written in either C or C++.

Read More

Hash tables

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

Before C++11, hash tables could be used in C++ only with some tricks. The only associative container available in the STL used to be the std::map (along with its sibling, the multimap). This class, however, is implemented as a binary search tree, and does not provide a way to customize a hash function. What hurt me most was that you didn’t have the great performances offered by a true hash map: almost constant time insert, delete, and search (depending on how good is the hash function). You insert in O(log N) time. You find in O(log N) time. Too bad.

Read More

Accessing APIs

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

I was curious about all the great sites I know of releasing their API. Twitter, Google, Facebook, Yelp, are only a few examples of websites providing a way to access their services in a programmatic way. In this post, I have investigated a simple but very interesting API, offered by Rotten Tomatoes, a website about movies.

Read More

Use files

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

Recently I’ve found myself in the common situation where I have to open a file and make something with its content. This is a basic task and should present no difficulties to a programmer; I happened, however, to get stuck for a while in search of a good way to carry out this apparently simple task. In particular, I have run into the recent addition of regular expression processing to the STL. Spoiler alert: I was not particularly happy of what I’ve found along the way.

Read More

Time in C++

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

Using time: the chrono header

Until before the introduction of the chrono library in the STL with the C++11 standard, we were forced to deal with time in a couple of ways, notably using Boost or using some wrapper around the time.h library header, from C.

Read More

STL Algorithms, part 4

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

We have seen some examples of usage of the find algorithm, with its variants find_if and find_if_not. In this installment, we are going to see other variants of finding algorithms, plus another algorithm useful when counting items in a sequence, count. Remember that we are still in the realm of non-modifying sequence algorithms (but see the discussion about for_each here).

Read More

STL Algorithms, part 3

This post has been created more than 3 months ago. It might contain inaccurate or stale (or both!) information. Use with caution!

In the previous posts of this series, we have had a glance at non-modifying sequence algorithms, i.e., the algorithms that are supposed not to modify the elements of a sequence (or at least, the structure of the sequence; see the observations about for_each.

In this installment, as anticipated, we will start looking at the algorithms for searching.

Read More