GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/utils/dumplibs.cc Lines: 47 47 100.0 %
Date: 2018-09-20 Branches: 118 258 45.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2017-2018  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "unittests/unittests.h"
22
23
#include "utils/stringutils.h"
24
25
PRAGMA48(GCC diagnostic push)
26
PRAGMA48(GCC diagnostic ignored "-Wshadow")
27
#include <SDL_image.h>
28
#include <SDL_mixer.h>
29
PRAGMACLANG5(GCC diagnostic push)
30
PRAGMACLANG5(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")
31
PRAGMACLANG6GCC(GCC diagnostic push)
32
PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
33
#include <SDL_net.h>
34
PRAGMACLANG6GCC(GCC diagnostic pop)
35
PRAGMACLANG5(GCC diagnostic pop)
36
#include <SDL_ttf.h>
37
PRAGMA48(GCC diagnostic pop)
38
39
#include <zlib.h>
40
41
#ifdef ENABLE_LIBXML
42
#include <libxml/globals.h>
43
#endif  // ENABLE_LIBXML
44
45
#include "debug.h"
46
47
9
TEST_CASE("dumplibs tests", "")
48
{
49



49
    SECTION("zlib")
50
    {
51
3
        const std::string build = ZLIB_VERSION;
52

3
        const std::string link = zlibVersion();
53



4
        REQUIRE(build == link);
54
    }
55
56
#ifdef ENABLE_LIBXML
57



49
    SECTION("libxml2")
58
    {
59
1
        const char **xmlVersion = __xmlParserVersion();
60



4
        REQUIRE(xmlVersion != nullptr);
61



4
        REQUIRE(*xmlVersion != nullptr);
62




10
        REQUIRE(std::string(*xmlVersion) ==
63
            std::string(LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA));
64
    }
65
#endif  // ENABLE_LIBXML
66
67



49
    SECTION("sdl")
68
    {
69
1
        const SDL_version *linkVersion = nullptr;
70
#ifdef USE_SDL2
71
        SDL_version sdlVersion;
72
        sdlVersion.major = 0;
73
        sdlVersion.minor = 0;
74
        sdlVersion.patch = 0;
75
        SDL_GetVersion(&sdlVersion);
76
        linkVersion = &sdlVersion;
77
#else  // USE_SDL2
78
1
        linkVersion = SDL_Linked_Version();
79
#endif  // USE_SDL2
80
81
        const std::string build = strprintf("%d.%d.%d",
82
            SDL_MAJOR_VERSION,
83
            SDL_MINOR_VERSION,
84
2
            SDL_PATCHLEVEL);
85
        const std::string link = strprintf("%d.%d.%d",
86
1
            linkVersion->major,
87
1
            linkVersion->minor,
88
4
            linkVersion->patch);
89
90



4
        REQUIRE(build == link);
91
    }
92
93



49
    SECTION("sdl_net")
94
    {
95
1
        const SDL_version *const linkVersion = SDLNet_Linked_Version();
96
97
        const std::string build = strprintf("%d.%d.%d",
98
            SDL_NET_MAJOR_VERSION,
99
            SDL_NET_MINOR_VERSION,
100
2
            SDL_NET_PATCHLEVEL);
101
        const std::string link = strprintf("%d.%d.%d",
102
1
            linkVersion->major,
103
1
            linkVersion->minor,
104
4
            linkVersion->patch);
105
106



4
        REQUIRE(build == link);
107
    }
108
109



49
    SECTION("sdl_image")
110
    {
111
1
        const SDL_version *const linkVersion = IMG_Linked_Version();
112
113
        const std::string build = strprintf("%d.%d.%d",
114
            SDL_IMAGE_MAJOR_VERSION,
115
            SDL_IMAGE_MINOR_VERSION,
116
2
            SDL_IMAGE_PATCHLEVEL);
117
        const std::string link = strprintf("%d.%d.%d",
118
1
            linkVersion->major,
119
1
            linkVersion->minor,
120
4
            linkVersion->patch);
121
122



4
        REQUIRE(build == link);
123
    }
124
125



49
    SECTION("sdl_mixer")
126
    {
127
1
        const SDL_version *const linkVersion = Mix_Linked_Version();
128
129
        const std::string build = strprintf("%d.%d.%d",
130
            SDL_MIXER_MAJOR_VERSION,
131
            SDL_MIXER_MINOR_VERSION,
132
2
            SDL_MIXER_PATCHLEVEL);
133
        const std::string link = strprintf("%d.%d.%d",
134
1
            linkVersion->major,
135
1
            linkVersion->minor,
136
4
            linkVersion->patch);
137
138



4
        REQUIRE(build == link);
139
    }
140
141



49
    SECTION("sdl_ttf")
142
    {
143
1
        const SDL_version *const linkVersion = TTF_Linked_Version();
144
145
        const std::string build = strprintf("%d.%d.%d",
146
            SDL_TTF_MAJOR_VERSION,
147
            SDL_TTF_MINOR_VERSION,
148
2
            SDL_TTF_PATCHLEVEL);
149
        const std::string link = strprintf("%d.%d.%d",
150
1
            linkVersion->major,
151
1
            linkVersion->minor,
152
4
            linkVersion->patch);
153
154



4
        REQUIRE(build == link);
155
    }
156

10
}