diff options
| author | 2019-07-19 02:01:56 +0200 | |
|---|---|---|
| committer | 2019-07-19 02:01:56 +0200 | |
| commit | ab0492f387a7ac3355e1e4500f0838d04a31e340 (patch) | |
| tree | afdb40778b1f4be48f2b8c8263af21d1a5969629 /tests/tst_dice.cpp | |
| parent | 63edd55e030475bd4abe1f39967cacf6e5adf892 (diff) | |
| download | OneRoll-ab0492f387a7ac3355e1e4500f0838d04a31e340.tar.gz OneRoll-ab0492f387a7ac3355e1e4500f0838d04a31e340.zip | |
Add test on spread operator
Diffstat (limited to 'tests/tst_dice.cpp')
| -rw-r--r-- | tests/tst_dice.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/tests/tst_dice.cpp b/tests/tst_dice.cpp index 58fb605..0be7692 100644 --- a/tests/tst_dice.cpp +++ b/tests/tst_dice.cpp @@ -52,7 +52,7 @@ public: TestDice(); private slots: - void initTestCase(); + void init(); void getAndSetTest(); void diceRollD10Test(); void diceRollD20Test(); @@ -114,12 +114,12 @@ private slots: void filterTest(); void filterTest_data(); - void splitTest(); - void splitTest_data(); - void uniqueTest(); void uniqueTest_data(); + void spreadTest(); + void spreadTest_data(); + void groupTest(); void groupTest_data(); @@ -136,7 +136,7 @@ private: TestDice::TestDice() {} -void TestDice::initTestCase() +void TestDice::init() { m_die.reset(new Die()); m_diceParser.reset(new DiceParser()); @@ -473,6 +473,18 @@ void makeResult(DiceResult& result, const QVector<int>& values) } } +void makeResultExplode(DiceResult& result, const QVector<int>& values) +{ + auto die= new Die(); + die->setBase(1); + die->setMaxValue(10); + for(int val : values) + { + die->insertRollValue(val); + } + result.insertResult(die); +} + Validator* makeValidator(int number, BooleanCondition::LogicOperator op) { BooleanCondition* validator= new BooleanCondition(); @@ -891,9 +903,34 @@ void TestDice::filterTest_data() QTest::addRow("cmd2") << QVector<int>({0, 0, 0}) << 1 << false; } -void TestDice::splitTest() {} -void TestDice::splitTest_data() {} +void TestDice::spreadTest() +{ + QFETCH(QVector<int>, values); + + TestNode node; + SplitNode split; + + DiceResult result; + makeResultExplode(result, values); + node.setResult(&result); + + node.setNextNode(&split); + + node.run(nullptr); + + auto list= dynamic_cast<DiceResult*>(split.getResult())->getResultList(); + + auto expected= result.getResultList(); + QVERIFY(list.size() == values.size()); +} + +void TestDice::spreadTest_data() +{ + QTest::addColumn<QVector<int>>("values"); + + QTest::addRow("cmd1") << QVector<int>({8, 4, 2}); +} void TestDice::uniqueTest() {} void TestDice::uniqueTest_data() {} |