GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/utils/dumplibs.cc Lines: 42 42 100.0 %
Date: 2018-07-14 Branches: 93 198 47.0 %

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
#include "debug.h"
42
43
8
TEST_CASE("dumplibs tests", "")
44
{
45



42
    SECTION("zlib")
46
    {
47
3
        const std::string build = ZLIB_VERSION;
48

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



4
        REQUIRE(build == link);
50
    }
51
52



42
    SECTION("sdl")
53
    {
54
1
        const SDL_version *linkVersion = nullptr;
55
#ifdef USE_SDL2
56
        SDL_version sdlVersion;
57
        sdlVersion.major = 0;
58
        sdlVersion.minor = 0;
59
        sdlVersion.patch = 0;
60
        SDL_GetVersion(&sdlVersion);
61
        linkVersion = &sdlVersion;
62
#else  // USE_SDL2
63
1
        linkVersion = SDL_Linked_Version();
64
#endif  // USE_SDL2
65
66
        const std::string build = strprintf("%d.%d.%d",
67
            SDL_MAJOR_VERSION,
68
            SDL_MINOR_VERSION,
69
2
            SDL_PATCHLEVEL);
70
        const std::string link = strprintf("%d.%d.%d",
71
1
            linkVersion->major,
72
1
            linkVersion->minor,
73
4
            linkVersion->patch);
74
75



4
        REQUIRE(build == link);
76
    }
77
78



42
    SECTION("sdl_net")
79
    {
80
1
        const SDL_version *const linkVersion = SDLNet_Linked_Version();
81
82
        const std::string build = strprintf("%d.%d.%d",
83
            SDL_NET_MAJOR_VERSION,
84
            SDL_NET_MINOR_VERSION,
85
2
            SDL_NET_PATCHLEVEL);
86
        const std::string link = strprintf("%d.%d.%d",
87
1
            linkVersion->major,
88
1
            linkVersion->minor,
89
4
            linkVersion->patch);
90
91



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



42
    SECTION("sdl_image")
95
    {
96
1
        const SDL_version *const linkVersion = IMG_Linked_Version();
97
98
        const std::string build = strprintf("%d.%d.%d",
99
            SDL_IMAGE_MAJOR_VERSION,
100
            SDL_IMAGE_MINOR_VERSION,
101
2
            SDL_IMAGE_PATCHLEVEL);
102
        const std::string link = strprintf("%d.%d.%d",
103
1
            linkVersion->major,
104
1
            linkVersion->minor,
105
4
            linkVersion->patch);
106
107



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



42
    SECTION("sdl_mixer")
111
    {
112
1
        const SDL_version *const linkVersion = Mix_Linked_Version();
113
114
        const std::string build = strprintf("%d.%d.%d",
115
            SDL_MIXER_MAJOR_VERSION,
116
            SDL_MIXER_MINOR_VERSION,
117
2
            SDL_MIXER_PATCHLEVEL);
118
        const std::string link = strprintf("%d.%d.%d",
119
1
            linkVersion->major,
120
1
            linkVersion->minor,
121
4
            linkVersion->patch);
122
123



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



42
    SECTION("sdl_ttf")
127
    {
128
1
        const SDL_version *const linkVersion = TTF_Linked_Version();
129
130
        const std::string build = strprintf("%d.%d.%d",
131
            SDL_TTF_MAJOR_VERSION,
132
            SDL_TTF_MINOR_VERSION,
133
2
            SDL_TTF_PATCHLEVEL);
134
        const std::string link = strprintf("%d.%d.%d",
135
1
            linkVersion->major,
136
1
            linkVersion->minor,
137
4
            linkVersion->patch);
138
139



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

9
}