summaryrefslogtreecommitdiff
path: root/tests/common/RecordsParam.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/RecordsParam.h')
-rw-r--r--tests/common/RecordsParam.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/common/RecordsParam.h b/tests/common/RecordsParam.h
new file mode 100644
index 0000000..19d4532
--- /dev/null
+++ b/tests/common/RecordsParam.h
@@ -0,0 +1,58 @@
+#ifndef RECORDS_PARAM_H
+#define RECORDS_PARAM_H
+
+#include <iostream>
+#include <vector>
+#include <string>
+#include <sstream>
+#include <QtCore>
+
+class DicRecord;
+
+using std::vector;
+using std::string;
+using std::ostream;
+
+struct RecordsParam
+{
+public:
+ static vector<RecordsParam> createParams();
+
+ template <typename T>
+ static string vectorToStr(const vector<T>& v);
+
+ static vector<string> hashToStrVector(const QHash<QString, QString>& hash,
+ const vector<string>& keys);
+
+public:
+ RecordsParam(vector<int> packFields, vector<vector<string> > records,
+ vector<string> questions, vector<vector<string> > answers);
+
+ vector<string> recordsToStr() const;
+
+public:
+ static const vector<string> fieldNames;
+
+public:
+ QList<DicRecord*> records;
+ vector<int> packFields;
+ vector<string> questions;
+ vector<vector<string> > answers;
+};
+
+ostream& operator<<(ostream& os, const RecordsParam& param);
+
+template <typename T>
+string RecordsParam::vectorToStr(const vector<T>& v)
+{
+ std::stringstream ss;
+ for(unsigned i = 0; i < v.size(); i++)
+ {
+ if(i != 0)
+ ss << ", ";
+ ss << v[i];
+ }
+ return ss.str();
+}
+
+#endif