some non functional tests

This commit is contained in:
jorenchik
2024-11-10 12:24:54 +02:00
parent f7f3ac5d4c
commit f99d44b69e
9 changed files with 100150 additions and 29 deletions

View File

@@ -98,7 +98,6 @@ Mdem *editMdem;
QLabel *membaseLabel;
QLabel *mdemLabel;
QLabel *lastPracticeLabel;
QMainWindow *trainWindow;
void showBacklabels(Mdem *mdem) {
@@ -115,17 +114,15 @@ void showBacklabels(Mdem *mdem) {
}
}
std::string outputMdem(std::vector<Question*> questions, time_t time = 0) {
std::string outputMdem(
std::vector<Question*> questions,
time_t time = 0,
const int wrap_width = 80,
const int timezoneOffset = 0
) {
std::stringstream ss;
int wrap_width = 80;
if (settings->contains(SETTING_CHARACTER_WRAP)) {
wrap_width = settings->value(SETTING_CHARACTER_WRAP).toInt();
}
if (time > 0) {
auto timezoneOffset = settings->value(SETTING_TIMEZONE).toInt();
/*time = time + 3600 * timezoneOffset;*/
std::tm* tm = std::localtime(&time);
char buffer[100];
std::strftime(buffer, sizeof(buffer), "%d.%m.%Y %H\\:%M", tm);
@@ -342,9 +339,13 @@ Mdem* makeMdem() {
[mdem]() {
editMdem = mdem;
if (mdem->question) {
int wrap_width = 80;
if (settings->contains(SETTING_CHARACTER_WRAP)) {
wrap_width = settings->value(SETTING_CHARACTER_WRAP).toInt();
}
editor->setText(
QString::fromStdString(
outputMdem(std::vector<Question*>{mdem->question})
outputMdem(std::vector<Question*>{mdem->question}, 0, wrap_width)
)
);
editorWindow->show();
@@ -771,7 +772,21 @@ void saveMdem() {
auto filename = getFilename(currentMdem);
std::ofstream out(currentMdem);
out << outputMdem(currentMdemBuffer->questions, currentMdemBuffer->trainedAt);
int wrap_width = 80;
if (settings->contains(SETTING_CHARACTER_WRAP)) {
wrap_width = settings->value(SETTING_CHARACTER_WRAP).toInt();
}
int timezoneOffset = 0;
if (settings->contains(SETTING_TIMEZONE)) {
timezoneOffset = settings->value(SETTING_TIMEZONE).toInt();
}
out << outputMdem(
currentMdemBuffer->questions,
currentMdemBuffer->trainedAt,
wrap_width,
timezoneOffset
);
updateMdemInfo(getFilename(currentMdem), false);
end = std::chrono::high_resolution_clock::now();