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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2017  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
PRAGMACLANG6GCC(GCC diagnostic push)
30
PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
31
#include <SDL_net.h>
32
PRAGMACLANG6GCC(GCC diagnostic pop)
33
#include <SDL_ttf.h>
34
PRAGMA48(GCC diagnostic pop)
35
36
#include <zlib.h>
37
38
#include "debug.h"
39
40
16
TEST_CASE("dumplibs tests", "")
41
{
42



84
    SECTION("zlib")
43
    {
44
8
        const std::string build = ZLIB_VERSION;
45

8
        const std::string link = zlibVersion();
46



8
        REQUIRE(build == link);
47
    }
48
49



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



8
        REQUIRE(build == link);
73
    }
74
75



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



8
        REQUIRE(build == link);
89
    }
90
91



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



8
        REQUIRE(build == link);
105
    }
106
107



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



8
        REQUIRE(build == link);
121
    }
122
123



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



8
        REQUIRE(build == link);
137
    }
138

18
}