From 9afdac17dcc8956fd795797bfc5b6e1c09285342 Mon Sep 17 00:00:00 2001
From: Gabriele Contini <contini.mailing@gmail.com>
Date: 周日, 08 3月 2020 21:27:16 +0800
Subject: [PATCH] Issues #14 and #6

---
 test/functional/date_test.cpp |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/functional/date_test.cpp b/test/functional/date_test.cpp
index 2c9c43d..9638f1b 100644
--- a/test/functional/date_test.cpp
+++ b/test/functional/date_test.cpp
@@ -1,4 +1,4 @@
-#define BOOST_TEST_MODULE date_test
+#define BOOST_TEST_MODULE test_date
 
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
@@ -18,39 +18,37 @@
 namespace test {
 
 BOOST_AUTO_TEST_CASE(license_not_expired) {
-	const string licLocation(PROJECT_TEST_TEMP_DIR "/not_expired.lic");
 	vector<string> extraArgs;
 	extraArgs.push_back("-e");
 	extraArgs.push_back("2050-10-10");
-	generate_license(licLocation, extraArgs);
+	const string licLocation = generate_license("not_expired.lic", extraArgs);
 	/* */
 	LicenseInfo license;
-	LicenseLocation licenseLocation;
-	licenseLocation.licenseFileLocation = licLocation.c_str();
-	licenseLocation.licenseData = "";
-	const EVENT_TYPE result = acquire_license(nullptr, &licenseLocation, &license);
+	LicenseLocation location = {LICENSE_PATH};
+	std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
+
+	const LCC_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, (unsigned int)0);
 }
 
 BOOST_AUTO_TEST_CASE(license_expired) {
-	const string licLocation(PROJECT_TEST_TEMP_DIR "/expired.lic");
-	remove(licLocation.c_str());
 	vector<string> extraArgs;
 	extraArgs.push_back("-e");
 	extraArgs.push_back("2013-10-10");
-	generate_license(licLocation, extraArgs);
+	const string licLocation = generate_license("expired", extraArgs);
 	/* */
 	LicenseInfo license;
-	LicenseLocation licenseLocation;
-	licenseLocation.licenseFileLocation = licLocation.c_str();
-	licenseLocation.licenseData = nullptr;
+	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, &licenseLocation, &license);
+	const LCC_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

--
Gitblit v1.9.1