Commit 605cfcf6 by xiaoqing.gu

1、TestSession测试用例 2、TestCoupon测试用例

parent 5b8f71e5
...@@ -19,6 +19,10 @@ public: ...@@ -19,6 +19,10 @@ public:
connect(this, &FMPVipInterface::TriggerUninit, this, &FMPVipInterface::OnTriggerUninit); connect(this, &FMPVipInterface::TriggerUninit, this, &FMPVipInterface::OnTriggerUninit);
} }
bool isBusy() {return true;}
void pay() {}
void list() {}
signals: signals:
void TriggerInit(); void TriggerInit();
void TriggerUninit(); void TriggerUninit();
......
...@@ -12,6 +12,16 @@ class Coupon ...@@ -12,6 +12,16 @@ class Coupon
public: public:
explicit Coupon(QString name="", QString code="", QString type="", double disAmount=0, double limitAmount=0, QString limitTime="", bool isCompatible=true); explicit Coupon(QString name="", QString code="", QString type="", double disAmount=0, double limitAmount=0, QString limitTime="", bool isCompatible=true);
bool operator ==(const Coupon &rhs)
{
return (this->code().compare(rhs.code())==0);
}
const bool operator ==(const Coupon &rhs) const
{
return (this->code().compare(rhs.code())==0);
}
void paint(QPainter *painter, const QRect &rect, void paint(QPainter *painter, const QRect &rect,
const QPalette &palette) const; const QPalette &palette) const;
QSize sizeHint() const; QSize sizeHint() const;
......
...@@ -9,7 +9,8 @@ CONFIG += qt console warn_on depend_includepath testcase ...@@ -9,7 +9,8 @@ CONFIG += qt console warn_on depend_includepath testcase
HEADERS += \ HEADERS += \
tst_db_query.h \ tst_db_query.h \
tst_db_create.h \ tst_db_create.h \
tst_session.h tst_session.h \
tst_coupon.h
SOURCES += main.cpp SOURCES += main.cpp
......
#include "tst_db_create.h" #include "tst_db_create.h"
#include "tst_db_query.h" #include "tst_db_query.h"
#include "tst_session.h" #include "tst_session.h"
#include "tst_coupon.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
......
#ifndef TST_COUPON_H
#define TST_COUPON_H
#include "coupon.h"
#include <gtest/gtest.h>
using namespace testing;
class TestCoupon : public ::testing::Test
{
};
TEST_F(TestCoupon, CouponData)
{
Coupon c("coupon","123456789","vip",10.00,11.00);
EXPECT_EQ(c.name(), "coupon");
EXPECT_EQ(c.code(), "123456789");
EXPECT_EQ(c.typeModeFlag(), "vip");
EXPECT_EQ(c.disAmount(), 10.00);
EXPECT_EQ(c.limitAmount(), 11.00);
EXPECT_EQ(c.isCompatible(), true);
}
TEST_F(TestCoupon, Operator)
{
Coupon c1("coupon","123456","vip");
Coupon c2("coupon","456789","vip");
Coupon c3("couponCode","123456","user");
EXPECT_EQ((c1 == c2), false);
EXPECT_EQ((c1 == c3), true);
}
#endif // TST_COUPON_H
...@@ -161,8 +161,6 @@ TEST_F(TestDBQuery, GetCanRefund) ...@@ -161,8 +161,6 @@ TEST_F(TestDBQuery, GetCanRefund)
PayList pays = order->getCanRefundPatList(); PayList pays = order->getCanRefundPatList();
ASSERT_EQ(pays.size(), 4); ASSERT_EQ(pays.size(), 4);
EXPECT_EQ(pays.first()->refundAmount(), 50); EXPECT_EQ(pays.first()->refundAmount(), 50);
t.commit();
} catch (const odb::exception& e) { } catch (const odb::exception& e) {
FAIL() << "Exception: " << e.what() << std::endl; FAIL() << "Exception: " << e.what() << std::endl;
} }
......
...@@ -33,4 +33,25 @@ TEST_F(TestSession, Clear) ...@@ -33,4 +33,25 @@ TEST_F(TestSession, Clear)
EXPECT_EQ(s.data("string").toString(), ""); EXPECT_EQ(s.data("string").toString(), "");
} }
TEST_F(TestSession, GetCouponMap)
{
Session s;
Coupon c("name","123456","1");
QMap<QString, Coupon> couponMap;
couponMap.insert("123456",c);
s.addData("map",couponMap);
EXPECT_EQ(s.getCouponMap("map"),couponMap);
}
TEST_F(TestSession, Reset)
{
Session s;
s.addData("string","s");
EXPECT_EQ(s.data("string").toString(),"s");
s.reset();
EXPECT_EQ(s.data("string").toString(), "");
EXPECT_EQ(s.createdTime(), QDateTime::currentDateTime());
}
#endif // TST_SESSION_H #endif // TST_SESSION_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment