#include #include #include #include "../../libs/BeetRoundCore/model/tablemodel.h" QT_BEGIN_NAMESPACE inline void PrintTo(const QString& qString, ::std::ostream* os) { *os << qUtf8Printable(qString); } QT_END_NAMESPACE struct ModelTest : testing::Test { std::shared_ptr model; ModelTest() { model = make_shared(new QUndoStack()); } virtual ~ModelTest() {} }; struct ModelTestWithData : ModelTest { ModelTestWithData() { QList itemList; ModelItemValues itemValues1 = {{Bidding1Role, 100}, {ShareTypeRole, "bezahlt"}, {ShareAmountRole, 1}, {BiddingTypeRole, "digital"}}; itemList.append(itemValues1); ModelItemValues itemValues2 = {{Bidding1Role, 100}, {ShareTypeRole, "bezahlt"}, {ShareAmountRole, 1}, {BiddingTypeRole, ""}}; itemList.append(itemValues2); ModelItemValues itemValues3 = {{Bidding1Role, 50}, {ShareTypeRole, "teils/teils"}, {ShareAmountRole, 1}, {BiddingTypeRole, "paper"}}; itemList.append(itemValues3); ModelItemValues itemValues4 = {{Bidding1Role, 50}, {ShareTypeRole, "bezahlt"}, {ShareAmountRole, 0.5}, {BiddingTypeRole, "paper"}}; itemList.append(itemValues4); ModelItemValues itemValues5 = {{Bidding1Role, 100}, {ShareTypeRole, "erarbeitet"}, {ShareAmountRole, 1}, {BiddingTypeRole, "paper"}}; itemList.append(itemValues5); ModelItemValues itemValues6 = {{Bidding1Role, 0}, {ShareTypeRole, "bezahlt"}, {ShareAmountRole, 1}, {BiddingTypeRole, "online"}}; itemList.append(itemValues6); model->insertItems(0, itemList); } }; /// empty model TEST_F(ModelTest, TestRowCountEmpty) { const int expectedRowCount = 0; const auto actualRowCount = model->rowCount(); ASSERT_EQ(expectedRowCount, actualRowCount); } TEST_F(ModelTest, TestBidding1Average) { const int expected = 0; const auto actualBidding1Average = model->biddingAverage1(); ASSERT_EQ(expected, actualBidding1Average); } TEST_F(ModelTest, ExpectedPlacedBiddings) { const int expected = 0; const auto expectedPlacedBiddings = model->nExpectedBiddings(); ASSERT_EQ(expected, expectedPlacedBiddings); } /// model with data TEST_F(ModelTestWithData, TestRowCount) { const int expected = 6; const auto actual = model->rowCount(); ASSERT_EQ(expected, actual); } TEST_F(ModelTestWithData, TestBidding1Average) { const qreal expected = 100; const auto actual = model->biddingAverage1(); ASSERT_EQ(expected, actual); } TEST_F(ModelTestWithData, ExpectedPlacedBiddings) { const int expected = 4; const auto actual = model->nExpectedBiddings(); ASSERT_EQ(expected, actual); } TEST_F(ModelTestWithData, PlacedBiddings1) { const int expected = 3; const auto actual = model->nPlacedBiddings1(); ASSERT_EQ(expected, actual); }