In Chapter 5, Data, we created various classes deriving from DataDecorator. Let's create companion test classes for each of those and test the following functionalities:
- Object construction
- Setting the value
- Getting the value as JSON
- Updating the value from JSON
In cm-tests/source/data, create the DateTimeDecoratorTests, EnumeratorDecoratorTests, IntDecoratorTests, and StringDecoratorTests classes.
Let’s begin with the simplest suite, IntDecoratorTests. The tests will be broadly similar across the suites, so once we’ve written one suite, we will be able to copy most of it across to the other suites and then supplement as necessary.
int-decorator-tests.h:
#ifndef INTDECORATORTESTS_H #define INTDECORATORTESTS_H
#include <QtTest>
#include <data/int-decorator.h> #include <test-suite.h>
namespace cm { namespace data {
class...