From 0a7855281e7653cac1776369d520ab1482d53860 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Mon, 1 Nov 2021 22:33:16 +0800 Subject: [PATCH] works ave --- RedPandaIDE/RedPandaIDE.pro | 2 ++ RedPandaIDE/problems/problemcasevalidator.cpp | 22 +++++++++++++++++++ RedPandaIDE/problems/problemcasevalidator.h | 13 +++++++++++ 3 files changed, 37 insertions(+) create mode 100644 RedPandaIDE/problems/problemcasevalidator.cpp create mode 100644 RedPandaIDE/problems/problemcasevalidator.h diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 89604661..ef5cd25a 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -36,6 +36,7 @@ SOURCES += \ parser/parserutils.cpp \ parser/statementmodel.cpp \ problems/ojproblemset.cpp \ + problems/problemcasevalidator.cpp \ project.cpp \ projectoptions.cpp \ projecttemplate.cpp \ @@ -157,6 +158,7 @@ HEADERS += \ platform.h \ problems/ojproblemset.h \ problems/problemcasevalidator.h \ + problems/problemcasevalidator.h \ project.h \ projectoptions.h \ projecttemplate.h \ diff --git a/RedPandaIDE/problems/problemcasevalidator.cpp b/RedPandaIDE/problems/problemcasevalidator.cpp new file mode 100644 index 00000000..b3a70552 --- /dev/null +++ b/RedPandaIDE/problems/problemcasevalidator.cpp @@ -0,0 +1,22 @@ +#include "problemcasevalidator.h" +#include "../utils.h" + +ProblemCaseValidator::ProblemCaseValidator() +{ + +} + +bool ProblemCaseValidator::validate(POJProblemCase problemCase) +{ + if (!problemCase) + return false; + QStringList output = TextToLines(problemCase->output); + QStringList expected = TextToLines(problemCase->expected); + if (output.count()!=expected.count()) + return false; + for (int i=0;i