#5657 Added more unit tests for member functions in SerialKey

This commit is contained in:
Jerry (Xinyu Hou) 2016-10-14 12:43:58 +01:00
parent dce4b382e6
commit 1e5dfd3cb5
1 changed files with 121 additions and 0 deletions

View File

@ -78,3 +78,124 @@ TEST(SerialKeyTests, parse_validV2Serial_valid)
EXPECT_EQ(true, serial.isExpiring(1)); EXPECT_EQ(true, serial.isExpiring(1));
EXPECT_EQ(true, serial.isTrial()); EXPECT_EQ(true, serial.isTrial());
} }
TEST(SerialKeyTests, isValid_validV1BasicSerial_valid)
{
// {v1;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76313B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isValid(0));
EXPECT_EQ(kBasic, serial.edition());
}
TEST(SerialKeyTests, isValid_expiredV1ProSerial_valid)
{
// {v1;pro;Bob;1;email;company name;0;86400}
SerialKey serial("7B76313B70726F3B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isValid(0));
EXPECT_EQ(kPro, serial.edition());
}
TEST(SerialKeyTests, isValid_validV2LifetimeBasicSerial_valid)
{
// {v2;lifetime;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B6C69666574696D653B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isValid(0));
EXPECT_EQ(kBasic, serial.edition());
}
TEST(SerialKeyTests, isValid_validV2LifetimeProSerial_valid)
{
// {v2;lifetime;pro;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B6C69666574696D653B70726F3B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isValid(0));
EXPECT_EQ(kPro, serial.edition());
}
TEST(SerialKeyTests, isValid_validV2TrialBasicSerial_valid)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_EQ(true, serial.isValid(0));
EXPECT_EQ(kBasic, serial.edition());
}
TEST(SerialKeyTests, isValid_expiredV2TrialProSerial_invalid)
{
// {v2;trial;pro;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B70726F3B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_FALSE(serial.isValid(86401));
EXPECT_EQ(kPro, serial.edition());
}
TEST(SerialKeyTests, isExpiring_validV2TrialBasicSerial_returnFalse)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_FALSE(serial.isExpiring(0));
EXPECT_EQ(kBasic, serial.edition());
}
TEST(SerialKeyTests, isExpiring_expiringV2TrialBasicSerial_returnTrue)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_EQ(true, serial.isExpiring(1));
}
TEST(SerialKeyTests, isExpiring_expiredV2TrialBasicSerial_returnFalse)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_FALSE(serial.isExpiring(86401));
}
TEST(SerialKeyTests, isExpired_validV2TrialBasicSerial_returnFalse)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_FALSE(serial.isExpired(0));
}
TEST(SerialKeyTests, isExpired_expiringV2TrialBasicSerial_returnFalse)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_FALSE(serial.isExpired(1));
}
TEST(SerialKeyTests, isExpired_expiredV2TrialBasicSerial_returnTrue)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(true, serial.isTrial());
EXPECT_EQ(true, serial.isExpired(86401));
}
TEST(SerialKeyTests, dayLeft_validExactlyOneDayV2TrialBasicSerial_returnOne)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(1, serial.dayLeft(0));
}
TEST(SerialKeyTests, dayLeft_validWithinOneDayV2TrialBasicSerial_returnOne)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(1, serial.dayLeft(1));
}
TEST(SerialKeyTests, dayLeft_expiredV2TrialBasicSerial_returnZero)
{
// {v2;trial;basic;Bob;1;email;company name;0;86400}
SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
EXPECT_EQ(0, serial.dayLeft(86401));
}