From 3abfa2c24677666cfd7ad5120e254e6e459dc202 Mon Sep 17 00:00:00 2001
From: gcontini <1121667+gcontini@users.noreply.github.com>
Date: 周六, 05 12月 2020 23:37:58 +0800
Subject: [PATCH] fix missing increment in wine

---
 test/library/LicenseLocator_test.cpp |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/test/library/LicenseLocator_test.cpp b/test/library/LicenseLocator_test.cpp
index 6c83fc0..99032a7 100644
--- a/test/library/LicenseLocator_test.cpp
+++ b/test/library/LicenseLocator_test.cpp
@@ -1,10 +1,11 @@
 #define BOOST_TEST_MODULE "test_license_locator"
+#define __STDC_WANT_LIB_EXT1__ 1
+#include <string.h>
 
 #include <iostream>
 #include <iterator>
 #include <cstdio>
 #include <fstream>
-#include <string>
 #include <vector>
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
@@ -88,13 +89,14 @@
 
 BOOST_AUTO_TEST_CASE(external_definition) {
 	// an application can define multiple license locations separated by ';'
-	const char *applicationDefinedString = MOCK_LICENSE ";/this/one/doesnt/exist";
+	string applicationDefinedString = MOCK_LICENSE ";/this/one/doesnt/exist";
 
 	// read test license
 	std::ifstream src(MOCK_LICENSE, std::ios::binary);
 	std::string referenceContent((std::istreambuf_iterator<char>(src)), std::istreambuf_iterator<char>());
 	license::EventRegistry registry;
-	const LicenseLocation licLocation = {applicationDefinedString, nullptr};
+	LicenseLocation licLocation = {LICENSE_PATH};
+	std::copy(applicationDefinedString.begin(), applicationDefinedString.end(), licLocation.licenseData);
 	ExternalDefinition externalDefinition(&licLocation);
 	vector<string> licenseInfos = externalDefinition.license_locations(registry);
 	BOOST_CHECK(registry.isGood());
@@ -109,9 +111,10 @@
  * The license file doesn't exist. Check that the locator reports the right error
  */
 BOOST_AUTO_TEST_CASE(external_definition_not_found) {
-	const char *applicationDefinedString = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
+	string applicationDefinedString = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
 	license::EventRegistry registry;
-	const LicenseLocation licLocation = {applicationDefinedString, nullptr};
+	LicenseLocation licLocation = {LICENSE_PATH};
+	std::copy(applicationDefinedString.begin(), applicationDefinedString.end(), licLocation.licenseData);
 	ExternalDefinition externalDefinition(&licLocation);
 	vector<string> licenseInfos = externalDefinition.license_locations(registry);
 
@@ -129,9 +132,9 @@
 	// an application can define multiple license locations separated by ';'
 	const char *environment_variable_value = MOCK_LICENSE ";/this/one/doesnt/exist";
 #ifdef _WIN32
-	_putenv_s(LICENSE_LOCATION_ENV_VAR, environment_variable_value);
+	_putenv_s(LCC_LICENSE_LOCATION_ENV_VAR, environment_variable_value);
 #else
-	setenv(LICENSE_LOCATION_ENV_VAR, environment_variable_value, 1);
+	setenv(LCC_LICENSE_LOCATION_ENV_VAR, environment_variable_value, 1);
 #endif
 	// read test license
 	std::ifstream src(MOCK_LICENSE, std::ios::binary);
@@ -146,7 +149,7 @@
 	BOOST_CHECK_MESSAGE(string(MOCK_LICENSE).compare(currentLocation) == 0, "file found at expected location");
 	string licenseRealContent = envVarLocationStrategy.retrieve_license_content(currentLocation);
 	BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0, "File content is same");
-	UNSETENV(LICENSE_LOCATION_ENV_VAR);
+	UNSETENV(LCC_LICENSE_LOCATION_ENV_VAR);
 }
 
 /**
@@ -154,7 +157,7 @@
  */
 BOOST_AUTO_TEST_CASE(environment_var_location_not_found) {
 	const char *environment_variable_value = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
-	SETENV(LICENSE_LOCATION_ENV_VAR, environment_variable_value);
+	SETENV(LCC_LICENSE_LOCATION_ENV_VAR, environment_variable_value);
 
 	license::EventRegistry registry;
 	EnvironmentVarLocation envVarLocationStrategy;
@@ -164,14 +167,14 @@
 	BOOST_REQUIRE_MESSAGE(!registry.isGood(), "Error detected");
 	BOOST_CHECK_EQUAL(0, licenseInfos.size());
 	BOOST_CHECK_MESSAGE(registry.getLastFailure()->event_type == LICENSE_FILE_NOT_FOUND, "Error detected");
-	UNSETENV(LICENSE_LOCATION_ENV_VAR);
+	UNSETENV(LCC_LICENSE_LOCATION_ENV_VAR);
 }
 
 /**
  * The license file doesn't exist. Check that the locator reports the right error
  */
 BOOST_AUTO_TEST_CASE(environment_var_location_not_defined) {
-	UNSETENV(LICENSE_LOCATION_ENV_VAR);
+	UNSETENV(LCC_LICENSE_LOCATION_ENV_VAR);
 	license::EventRegistry registry;
 	EnvironmentVarLocation environmentVarLocation;
 	vector<string> licenseInfos = environmentVarLocation.license_locations(registry);

--
Gitblit v1.9.1