gcontini
2020-01-01 9d7cd404cc2d09c82b65be4828be0ac74eca20a7
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
50
51
52
53
54
55
#define BOOST_TEST_MODULE test_date
 
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
 
#include <licensecc_properties.h>
#include <licensecc_properties_test.h>
 
#include <licensecc/licensecc.h>
#include "../../src/library/ini/SimpleIni.h"
#include "generate-license.h"
 
namespace fs = boost::filesystem;
using namespace license;
using namespace std;
 
namespace license {
namespace test {
 
BOOST_AUTO_TEST_CASE(license_not_expired) {
    vector<string> extraArgs;
    extraArgs.push_back("-e");
    extraArgs.push_back("2050-10-10");
    const string licLocation = generate_license("not_expired.lic", extraArgs);
    /* */
    LicenseInfo license;
    LicenseLocation location = {LICENSE_PATH};
    std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
 
    const EVENT_TYPE result = acquire_license(nullptr, &location, &license);
    BOOST_CHECK_EQUAL(result, LICENSE_OK);
    BOOST_CHECK_EQUAL(license.has_expiry, true);
    BOOST_CHECK_EQUAL(license.linked_to_pc, false);
    BOOST_CHECK_GT(license.days_left, 0);
}
 
BOOST_AUTO_TEST_CASE(license_expired) {
    vector<string> extraArgs;
    extraArgs.push_back("-e");
    extraArgs.push_back("2013-10-10");
    const string licLocation = generate_license("expired", extraArgs);
    /* */
    LicenseInfo license;
    LicenseLocation location = {LICENSE_PATH};
    std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
    BOOST_TEST_MESSAGE("before acquire license");
    const EVENT_TYPE result = acquire_license(nullptr, &location, &license);
    BOOST_CHECK_EQUAL(result, PRODUCT_EXPIRED);
    BOOST_CHECK_EQUAL(license.has_expiry, true);
    BOOST_CHECK_EQUAL(license.linked_to_pc, false);
    BOOST_CHECK_EQUAL(license.days_left, 0);
}
 
}  // namespace test
}  // namespace license