nancy.liao
2025-05-23 8553a8d63f97cfa8d64b5b2260e81f8c896a8398
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
 
#define BOOST_TEST_MODULE standard_license_test
 
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
 
#include <licensecc/licensecc.h>
#include <licensecc_properties_test.h>
#include <licensecc_properties.h>
#include <iostream>
#include "../../src/library/ini/SimpleIni.h"
#include "generate-license.h"
#include "../../src/library/base/file_utils.hpp"
 
namespace license {
namespace test {
namespace fs = boost::filesystem;
using namespace license;
using namespace std;
 
//测试一个通用的许可证
/**
 * Test a generic license, passing a bad license number trough the api.
 * see projects/DEFAULT/include/licensecc/DEFAULT/licensecc_properties.h (magic should be 0)
 */
BOOST_AUTO_TEST_CASE(test_bad_magic_number) {
    const vector<string> extraArgs;
    const string licLocation = generate_license("standard_license", extraArgs);
    /* */
    LicenseInfo license;
    LicenseLocation location = {LICENSE_PATH};
    std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
    // magic should be 0 for this build...
    CallerInformations callInfo{{0}, {0}, 42};
    const LCC_EVENT_TYPE result = acquire_license(&callInfo, &location, &license);
    BOOST_CHECK_EQUAL(result, LICENSE_CORRUPTED);
}
 
}  // namespace test
}  // namespace license