"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/test/unittests/shared/SerialKeyTests.cpp" between
synergy-core-1.14.4.37-stable.tar.gz and synergy-core-1.14.5.13-stable.tar.gz

About: Synergy is software for sharing one mouse and one keyboard between multiple computers on your desk allowing to seamlessly move the mouse cursor from one screen to another (works on Linux, Windows and Mac OS X). Synergy 1.

SerialKeyTests.cpp  (synergy-core-1.14.4.37-stable):SerialKeyTests.cpp  (synergy-core-1.14.5.13-stable)
skipping to change at line 25 skipping to change at line 25
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define TEST_ENV #define TEST_ENV
#include <climits> #include <climits>
#include "shared/SerialKey.h" #include "shared/SerialKey.h"
#include "test/global/gtest.h" #include "test/global/gtest.h"
TEST(SerialKeyTests, decode_empty_returnEmptyString)
{
std::string plainText = SerialKey::decode("");
EXPECT_EQ(0, plainText.size());
}
TEST(SerialKeyTests, decode_invalidDigit_returnEmptyString)
{
std::string plainText = SerialKey::decode("MOCKZ");
EXPECT_EQ(0, plainText.size());
}
TEST(SerialKeyTests, decode_validSerial_returnPlainText)
{
std::string plainText = SerialKey::decode("53796E6572677920726F636B7321");
EXPECT_EQ("Synergy rocks!", plainText);
}
TEST(SerialKeyTests, parse_noParty_invalid)
{
SerialKey serial;
bool r = serial.parse("MOCK");
EXPECT_FALSE(r);
}
TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid)
{
SerialKey serial;
bool r = serial.parse("{Synergy;Rocks}");
EXPECT_FALSE(r);
}
TEST(SerialKeyTests, parse_validV1Serial_valid)
{
SerialKey serial;
bool r = serial.parse("{v1;basic;Bob;1;email;company name;0;86400}");
EXPECT_EQ(true, r);
EXPECT_EQ(kBasic, serial.edition());
EXPECT_FALSE(serial.isExpired(0));
EXPECT_EQ(true, serial.daysLeft(0));
EXPECT_FALSE(serial.isExpiring(1));
}
TEST(SerialKeyTests, parse_validV2Serial_valid)
{
SerialKey serial;
bool r = serial.parse("{v2;trial;pro;Bob;1;email;company name;0;86400}");
EXPECT_EQ(true, r);
EXPECT_EQ(kPro, serial.edition());
EXPECT_FALSE(serial.isExpired(0));
EXPECT_EQ(true, serial.daysLeft(0));
EXPECT_EQ(true, serial.isExpiring(1));
EXPECT_EQ(true, serial.isTrial());
EXPECT_EQ(true, serial.isTemporary());
}
TEST(SerialKeyTests, isExpiring_validV2TrialBasicSerial_returnFalse) TEST(SerialKeyTests, isExpiring_validV2TrialBasicSerial_returnFalse)
{ {
// {v2;trial;basic;Bob;1;email;company name;1;86400} // {v2;trial;basic;Bob;1;email;company name;1;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B63 6F6D70616E79206E616D653B313B38363430307D"); SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B63 6F6D70616E79206E616D653B313B38363430307D");
EXPECT_EQ(true, serial.isTrial()); EXPECT_EQ(true, serial.isTrial());
EXPECT_EQ(true, serial.isTemporary()); EXPECT_EQ(true, serial.isTemporary());
EXPECT_FALSE(serial.isExpiring(0)); EXPECT_FALSE(serial.isExpiring(0));
EXPECT_EQ(kBasic, serial.edition()); EXPECT_EQ(kBasic, serial.edition());
} }
skipping to change at line 175 skipping to change at line 119
EXPECT_EQ(kBasic, serial.edition()); EXPECT_EQ(kBasic, serial.edition());
} }
TEST(SerialKeyTests, isExpiring_expiringV2SubscriptionBasicSerial_returnTrue) TEST(SerialKeyTests, isExpiring_expiringV2SubscriptionBasicSerial_returnTrue)
{ {
// {v2;subscription;basic;Bob;1;email;company name;0;86400} // {v2;subscription;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B737562736372697074696F6E3B62617369633B426F623B313B 656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); SerialKey serial("7B76323B737562736372697074696F6E3B62617369633B426F623B313B 656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(false, serial.isTrial()); EXPECT_EQ(false, serial.isTrial());
EXPECT_EQ(true, serial.isTemporary()); EXPECT_EQ(true, serial.isTemporary());
EXPECT_EQ(true, serial.isExpiring(1)); EXPECT_EQ(true, serial.isExpiring(1));
EXPECT_FALSE(serial.isMaintenance());
}
TEST(SerialKeyTests, isExpiring_expiringV2MentenanceSerial_returnTrue)
{
// {v2;maintenance;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B6D61696E74656E616E63653B70726F3B736572686969206861
647A68696C6F763B313B7365726869694073796D6C6573732E636F6D3B203B303B31363535313234
3139307D");
EXPECT_FALSE(serial.isTrial());
EXPECT_FALSE(serial.isTemporary());
EXPECT_TRUE(serial.isMaintenance());
} }
TEST(SerialKeyTests, isExpired_expiredV2SubscriptionBasicSerial_returnTrue) TEST(SerialKeyTests, isExpired_expiredV2SubscriptionBasicSerial_returnTrue)
{ {
// {v2;subscription;basic;Bob;1;email;company name;0;86400} // {v2;subscription;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B737562736372697074696F6E3B62617369633B426F623B313B 656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); SerialKey serial("7B76323B737562736372697074696F6E3B62617369633B426F623B313B 656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(false, serial.isTrial()); EXPECT_EQ(false, serial.isTrial());
EXPECT_EQ(true, serial.isTemporary()); EXPECT_EQ(true, serial.isTemporary());
EXPECT_EQ(true, serial.isExpired(86401)); EXPECT_EQ(true, serial.isExpired(86401));
} }
 End of changes. 2 change blocks. 
56 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)