File size: 1,207 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// SPDX-License-Identifier: LGPL-2.1-or-later

#include <gtest/gtest.h>

#include "App/License.h"

TEST(License, isLicenseEmpty)
{
    EXPECT_EQ(App::findLicense(""), -1);
}

TEST(License, isLicenseNull)
{
    EXPECT_EQ(App::findLicense(nullptr), -1);
}

TEST(License, isLicenseYesStr)
{
    EXPECT_EQ(App::findLicense("CC_BY_40"), 1);
}

TEST(License, UnknownIdentifier)
{
    int index {App::findLicense("junk")};
    EXPECT_EQ(index, -1);
}

TEST(License, direct)
{
    int posn {App::findLicense("CC_BY_40")};
    App::TLicenseArr tt {
        "CC_BY_40",
        "Creative Commons Attribution 4.0",
        "https://creativecommons.org/licenses/by/4.0/"
    };
    EXPECT_STREQ(App::licenseItems.at(posn).at(0), tt.at(0));
    EXPECT_STREQ(App::licenseItems.at(posn).at(1), tt.at(1));
    EXPECT_STREQ(App::licenseItems.at(posn).at(2), tt.at(2));
}

TEST(License, findLicenseByIdent)
{
    App::TLicenseArr arr {App::licenseItems.at(App::findLicense("CC_BY_40"))};

    EXPECT_STREQ(arr.at(App::posnOfIdentifier), "CC_BY_40");
    EXPECT_STREQ(arr.at(App::posnOfFullName), "Creative Commons Attribution 4.0");
    EXPECT_STREQ(arr.at(App::posnOfUrl), "https://creativecommons.org/licenses/by/4.0/");
}