summaryrefslogtreecommitdiff
path: root/tests/unit/CardSideView/CardSideView_test.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /tests/unit/CardSideView/CardSideView_test.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'tests/unit/CardSideView/CardSideView_test.cpp')
-rw-r--r--tests/unit/CardSideView/CardSideView_test.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/CardSideView/CardSideView_test.cpp b/tests/unit/CardSideView/CardSideView_test.cpp
new file mode 100644
index 0000000..9b08dc0
--- /dev/null
+++ b/tests/unit/CardSideView/CardSideView_test.cpp
@@ -0,0 +1,49 @@
+#include <gtest/gtest.h>
+#include <QtCore>
+#include <QtWidgets>
+
+#include "CardSideView_test.h"
+#include "../../common/printQtTypes.h"
+#include "../../../src/dictionary/Card.h"
+#include "../../../src/study/CardSideView.h"
+
+void CardSideViewTest::SetUp()
+ {
+ cardPack.addField(new Field("English", "Normal"));
+ cardPack.addField(new Field("Example", "Example"));
+ cardPack.addField(new Field("Russian", "Normal"));
+ }
+
+TEST_F(CardSideViewTest, getFormattedQuestion)
+ {
+ CardSideView view;
+ view.setPack(&cardPack);
+ view.setQstAnsr("First", QStringList());
+ ASSERT_EQ("<span style=\"font-family:'Times New Roman'; "\
+ "font-size:18pt; font-weight:bold\">First</span>",
+ view.getFormattedText());
+ }
+
+TEST_F(CardSideViewTest, getFormattedAnswer)
+ {
+ CardSideView view(CardSideView::AnsMode);
+ view.setPack(&cardPack);
+ QStringList answers = QStringList() << "First example" << "Pervyj";
+ view.setQstAnsr("First", answers);
+ ASSERT_EQ("<span style=\"font-family:'Times New Roman'; "\
+ "font-size:14pt\"><span style=\"; color:#0000ff\">First</span> example</span><br/><br/>"\
+ "<span style=\"font-family:'Times New Roman'; font-size:18pt; "\
+ "font-weight:bold\">Pervyj</span>",
+ view.getFormattedText());
+ }
+
+TEST_F(CardSideViewTest, getFormattedAnswer_1missing)
+ {
+ CardSideView view(CardSideView::AnsMode);
+ view.setPack(&cardPack);
+ QStringList answers = QStringList() << "" << "Pervyj";
+ view.setQstAnsr("First", answers);
+ ASSERT_EQ("<br/><br/><span style=\"font-family:'Times New Roman'; font-size:18pt; "\
+ "font-weight:bold\">Pervyj</span>",
+ view.getFormattedText());
+ }