110#if QT_VERSION < QT_VERSION_CHECK (6, 9, 0)
111template<
typename... Args>
112QDebug
operator<< (QDebug dbg,
const std::tuple<Args...>& tup)
114 return std::apply ([&] (
auto&&... args) {
return ((dbg.nospace () << args <<
' '), ...); }, tup);
124 void OralTest::testAutoPKeyRecordInsertSelect ()
128 const auto& list = adapted->Select ();
129 QCOMPARE (list, (QList<AutogenPKeyRecord> { { 1,
"0" }, { 2,
"1" }, { 3,
"2" } }));
132 void OralTest::testAutoPKeyRecordInsertRvalueReturnsPKey ()
137 for (
int i = 0; i < 3; ++i)
138 ids << adapted->Insert ({ 0, QString::number (i) });
140 QCOMPARE (ids, (QList<int> { 1, 2, 3 }));
143 void OralTest::testAutoPKeyRecordInsertConstLvalueReturnsPKey ()
147 QList<AutogenPKeyRecord> records;
148 for (
int i = 0; i < 3; ++i)
149 records.push_back ({ 0, QString::number (i) });
152 for (
const auto& record : records)
153 ids << adapted->Insert (record);
155 QCOMPARE (ids, (QList<int> { 1, 2, 3 }));
158 void OralTest::testAutoPKeyRecordInsertSetsPKey ()
162 QList<AutogenPKeyRecord> records;
163 for (
int i = 0; i < 3; ++i)
164 records.push_back ({ 0, QString::number (i) });
166 for (
auto& record : records)
167 adapted->Insert (record);
169 QCOMPARE (records, (QList<AutogenPKeyRecord> { { 1,
"0" }, { 2,
"1" }, { 3,
"2" } }));
172 void OralTest::testNoPKeyRecordInsertSelect ()
175 const auto& list = adapted->Select ();
176 QCOMPARE (list, (QList<NoPKeyRecord> { { 0,
"0" }, { 1,
"1" }, { 2,
"2" } }));
179 void OralTest::testNonInPlaceConstructibleRecordInsertSelect ()
182 for (
int i = 0; i < 3; ++i)
183 adapted->Insert ({ i, QString::number (i), 0 });
185 const auto& list = adapted->Select ();
186 QCOMPARE (list, (QList<NonInPlaceConstructibleRecord> { { 0,
"0", 0 }, { 1,
"1", 0 }, { 2,
"2", 0 } }));
191 template<
typename Ex,
typename F>
192 void ShallThrow (F&& f)
204 QCOMPARE (failed,
true);
208 void OralTest::testComplexConstraintsRecordInsertSelectDefault ()
212 adapted->Insert ({ 0,
"first", 1, 2 });
213 ShallThrow<oral::QueryException> ([&] { adapted->Insert ({ 0,
"second", 1, 2 }); });
214 ShallThrow<oral::QueryException> ([&] { adapted->Insert ({ 0,
"first", 1, 3 }); });
215 adapted->Insert ({ 0,
"second", 1, 3 });
216 ShallThrow<oral::QueryException> ([&] { adapted->Insert ({ 0,
"first", 1, 3 }); });
218 const auto& list = adapted->Select ();
219 QCOMPARE (list, (QList<ComplexConstraintsRecord> { { 0,
"first", 1, 2 }, { 0,
"second", 1, 3 } }));
222 void OralTest::testComplexConstraintsRecordInsertSelectIgnore ()
232 const auto& list = adapted->Select ();
233 QCOMPARE (list, (QList<ComplexConstraintsRecord> { { 0,
"first", 1, 2 }, { 0,
"second", 1, 3 } }));
236 void OralTest::testComplexConstraintsRecordInsertSelectReplace ()
241 &ComplexConstraintsRecord::ID_,
242 &ComplexConstraintsRecord::Value_
245 &ComplexConstraintsRecord::Weight_,
246 &ComplexConstraintsRecord::Age_
248 adapted->Insert ({ 0,
"first", 1, 2 }, idValueFields);
249 adapted->Insert ({ 0,
"second", 1, 2 }, weightAgeFields);
250 adapted->Insert ({ 0,
"first", 1, 3 }, idValueFields);
251 adapted->Insert ({ 0,
"third", 1, 3 }, weightAgeFields);
252 adapted->Insert ({ 0,
"first", 1, 3 }, weightAgeFields);
254 const auto& list = adapted->Select ();
255 QCOMPARE (list, (QList<ComplexConstraintsRecord> { {0,
"second", 1, 2 }, { 0,
"first", 1, 3 } }));