summaryrefslogtreecommitdiffstats
path: root/libtests/pdf_version.cc
blob: 5db444b3f66b994c153c78621eb5f4dfb550030e (plain) (blame)
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
#include <qpdf/assert_test.h>

#include <qpdf/PDFVersion.hh>

#include <iostream>

int
main()
{
    PDFVersion v1;
    assert(v1.getMajor() == 0);
    assert(v1.getMinor() == 0);
    assert(v1.getExtensionLevel() == 0);
    v1 = PDFVersion(1, 7, 8);
    assert(v1.getMajor() == 1);
    assert(v1.getMinor() == 7);
    assert(v1.getExtensionLevel() == 8);
    std::string version;
    int extension_level = -1;
    v1.getVersion(version, extension_level);
    assert(version == "1.7");
    assert(extension_level == 8);
    PDFVersion v2(1, 5);
    v2.getVersion(version, extension_level);
    assert(version == "1.5");
    assert(extension_level == 0);
    assert(v2 < v1);
    PDFVersion v3 = v1;
    assert(v3 == v1);
    v1.updateIfGreater(v2);
    assert(v3 == v1);
    assert(!(v3 == v2));
    assert(!(v2 == v1));
    v2.updateIfGreater(v1);
    assert(v2 == v1);
    v2.getVersion(version, extension_level);
    assert(version == "1.7");
    assert(extension_level == 8);
    assert(PDFVersion(1, 2) < PDFVersion(1, 3));
    assert(PDFVersion(1, 2) < PDFVersion(1, 2, 1));
    assert(PDFVersion(1, 2, 1) < PDFVersion(1, 2, 2));
    assert(!(PDFVersion(1, 2, 2) < PDFVersion(1, 2, 2)));
    assert(!(PDFVersion(1, 2, 3) < PDFVersion(1, 2, 2)));
    assert(PDFVersion(1, 1) < PDFVersion(1, 2, 2));
    assert(!(PDFVersion(1, 3) < PDFVersion(1, 2, 2)));
    assert(!(PDFVersion(2, 0) < PDFVersion(1, 9, 9)));
    assert(!(PDFVersion(2, 0) < PDFVersion(2, 0)));
    assert(PDFVersion(2, 0) == PDFVersion(2, 0));
    assert(PDFVersion(2, 0, 1) == PDFVersion(2, 0, 1));

    std::cout << "PDFVersion assertions passed" << std::endl;
    return 0;
}