1 /*
2 * Copyright (c) 2017-2018 Dmitry Marakasov <amdmi3@amdmi3.ru>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23 #define LIBVERSION_NO_DEPRECATED /* disable deprecated APIs */
24
25 #include <libversion/version.h>
26
27 #include <stdio.h>
28
main()29 int main() {
30 const char version_chars[] = { '0', '1', 'p', 'R', 'e', '.', '-' };
31 const size_t num_version_chars = sizeof(version_chars)/sizeof(version_chars[0]);
32
33 const char* samples[] = { "0", "1", "a", "r", "z", "1alpha1", "1patch1" };
34 const size_t num_samples = sizeof(samples)/sizeof(samples[0]);
35
36 char buffer[6];
37 size_t i0, i1, i2, i3, i4, isample;
38 int res;
39
40 buffer[5] = '\0';
41
42 for (i0 = 0; i0 < num_version_chars; i0++) {
43 buffer[0] = version_chars[i0];
44 for (i1 = 0; i1 < num_version_chars; i1++) {
45 buffer[1] = version_chars[i1];
46 for (i2 = 0; i2 < num_version_chars; i2++) {
47 buffer[2] = version_chars[i2];
48 for (i3 = 0; i3 < num_version_chars; i3++) {
49 buffer[3] = version_chars[i3];
50 for (i4 = 0; i4 < num_version_chars; i4++) {
51 buffer[4] = version_chars[i4];
52
53 for (isample = 0; isample < num_samples; isample++) {
54 res = version_compare2(buffer, samples[isample]);
55
56 printf("%s %c %s\n", buffer, (res == 0) ? '=' : (res < 0) ? '<' : '>', samples[isample]);
57 }
58 }
59 }
60 }
61 }
62 }
63
64 return 0;
65 }
66