1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
//
// C++ Implementation: history-test
//
// Description:
//
//
// Author: Benjamin Mesing <bensmail@gmx.net>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifdef __UNIT_TEST_PP
#include <UnitTest++.h>
#include <iostream>
#include <string>
#include "history.h"
using namespace std;
SUITE(History)
{
// Equivalence classes
// "History()"
// Hi
// "append(T)"
// Ap1 empty, Ap2 not_empty
// Ap3 current is invalid, Ap4 current is not the last element, Ap5 current is the last element
// "empty()"
// Em1 empty, Em2 not empty
// "const T& current()"
// Cu
// "const T& back()"
// Ba1 last element is current, Ba2 middle element is current
// "const T& forward()"
// Fo1 first element is current, Fo2 middle element is current
// "const T& backPossible()"
// Bp1 first element is current, Bp2 middle element is current, Bp3 last element is current
// Bp4 empty
// "const T& forwardPossible()"
// Fp1 first element is current, Fp2 middle element is current, Fp3 last element is current
// Fp4 empty
// "clear()"
// Cl1 empty, Cl2 not empty
TEST(History_append)
{
// Hi
NBrowser::History<string> h;
// Em1
CHECK(h.empty());
// Fp4
CHECK(!h.forwardPossible());
// Bp4
CHECK(!h.backPossible());
// Cl1
h.clear();
CHECK(h.empty());
// Ap1, Ap3
h.append("first");
// Em2
CHECK(!h.empty());
// Cu
CHECK_EQUAL(h.current(), "first");
// Ap2, Ap5
h.append("second");
CHECK_EQUAL(h.current(), "second");
// Bp3
CHECK( h.backPossible());
// Fp3
CHECK(!h.forwardPossible());
// go back one entry
// Ba1
CHECK_EQUAL(h.back(), "first");
// Bp1
CHECK(!h.backPossible());
// Fp1
CHECK(h.forwardPossible());
// Fo1
CHECK_EQUAL(h.forward(), "second");
h.append("third");
h.back(); // second is current
// Bp2
CHECK(h.backPossible());
// Fp2
CHECK(h.forwardPossible());
// Ba2
CHECK_EQUAL(h.back(), "first");
h.forward(); // second
// Fo2
CHECK_EQUAL(h.forward(), "third");
h.back(); // second
// Ap4
h.append("fourth");
CHECK(!h.forwardPossible());
CHECK( h.backPossible());
CHECK_EQUAL(h.back(), "second");
// Cl2
h.clear();
CHECK(h.empty());
}
}
#endif // UNITTEST_PP
|