From 90d36cd3c06c14113fade5fc3d4268679c5a8b65 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Tue, 9 Apr 2024 13:13:40 -0700 Subject: [PATCH 1/4] Fix bug where rows would reference wrong SQResult after copy --- libstuff/SQResult.cpp | 9 +++++++++ libstuff/SQResult.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/libstuff/SQResult.cpp b/libstuff/SQResult.cpp index 7a9d3e9f3..2eb447296 100644 --- a/libstuff/SQResult.cpp +++ b/libstuff/SQResult.cpp @@ -162,3 +162,12 @@ const SQResultRow& SQResult::operator[](size_t rowNum) const { STHROW("Out of range"); } } + +SQResult& SQResult::operator=(const SQResult& other) { + headers = other.headers; + rows = other.rows; + for (auto& row : rows) { + row.result = this; + } + return *this; +} diff --git a/libstuff/SQResult.h b/libstuff/SQResult.h index 001907fa9..1ecd3560f 100644 --- a/libstuff/SQResult.h +++ b/libstuff/SQResult.h @@ -6,6 +6,7 @@ using namespace std; class SQResult; class SQResultRow : public vector { + friend class SQResult; public: SQResultRow(); SQResultRow(SQResult& result, size_t count = 0); @@ -36,6 +37,7 @@ class SQResult { // Operators SQResultRow& operator[](size_t rowNum); const SQResultRow& operator[](size_t rowNum) const; + SQResult& operator=(const SQResult& other); // Serializers string serializeToJSON() const; From 6ffe376b37886064929f4e98b9922d45c08b28c1 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 9 Apr 2024 13:55:05 -0700 Subject: [PATCH 2/4] increase number of allowed tests by 20 --- test/lib/tpunit++.hpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/test/lib/tpunit++.hpp b/test/lib/tpunit++.hpp index 980fbb01a..6ec5beea1 100644 --- a/test/lib/tpunit++.hpp +++ b/test/lib/tpunit++.hpp @@ -257,7 +257,7 @@ namespace tpunit { // Use constructor delegation to add an optional default 'name' parameter that works as a first argument. // This lets us keep backwards compatibility with existing tests, and add a name to new tests without having - // to add 50 '0's for a bunch of unused methods. + // to add 70 '0's for a bunch of unused methods. TestFixture(const char* name, method* m0, method* m1 = 0, method* m2 = 0, method* m3 = 0, method* m4 = 0, method* m5 = 0, method* m6 = 0, method* m7 = 0, method* m8 = 0, method* m9 = 0, @@ -268,12 +268,18 @@ namespace tpunit { method* m30 = 0, method* m31 = 0, method* m32 = 0, method* m33 = 0, method* m34 = 0, method* m35 = 0, method* m36 = 0, method* m37 = 0, method* m38 = 0, method* m39 = 0, method* m40 = 0, method* m41 = 0, method* m42 = 0, method* m43 = 0, method* m44 = 0, - method* m45 = 0, method* m46 = 0, method* m47 = 0, method* m48 = 0, method* m49 = 0) + method* m45 = 0, method* m46 = 0, method* m47 = 0, method* m48 = 0, method* m49 = 0, + method* m50 = 0, method* m51 = 0, method* m52 = 0, method* m53 = 0, method* m54 = 0, + method* m55 = 0, method* m56 = 0, method* m57 = 0, method* m58 = 0, method* m59 = 0, + method* m60 = 0, method* m61 = 0, method* m62 = 0, method* m63 = 0, method* m64 = 0, + method* m65 = 0, method* m66 = 0, method* m67 = 0, method* m68 = 0, method* m69 = 0) : TestFixture( m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, - m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, - m20, m21, m22, m23, m24, m25, m26, m27, m28, m29, - m30, m31, m32, m33, m34, m35, m36, m37, m38, m39, - m40, m41, m42, m43, m44, m45, m46, m47, m48, m49, name) { } + m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, + m20, m21, m22, m23, m24, m25, m26, m27, m28, m29, + m30, m31, m32, m33, m34, m35, m36, m37, m38, m39, + m40, m41, m42, m43, m44, m45, m46, m47, m48, m49, + m50, m51, m52, m53, m54, m55, m56, m57, m58, m59, + m60, m61, m62, m63, m64, m65, m66, m67, m68, m69, name) { } TestFixture(bool parallel, const char* name, method* m0, method* m1 = 0, method* m2 = 0, method* m3 = 0, method* m4 = 0, @@ -285,16 +291,22 @@ namespace tpunit { method* m30 = 0, method* m31 = 0, method* m32 = 0, method* m33 = 0, method* m34 = 0, method* m35 = 0, method* m36 = 0, method* m37 = 0, method* m38 = 0, method* m39 = 0, method* m40 = 0, method* m41 = 0, method* m42 = 0, method* m43 = 0, method* m44 = 0, - method* m45 = 0, method* m46 = 0, method* m47 = 0, method* m48 = 0, method* m49 = 0) + method* m45 = 0, method* m46 = 0, method* m47 = 0, method* m48 = 0, method* m49 = 0, + method* m50 = 0, method* m51 = 0, method* m52 = 0, method* m53 = 0, method* m54 = 0, + method* m55 = 0, method* m56 = 0, method* m57 = 0, method* m58 = 0, method* m59 = 0, + method* m60 = 0, method* m61 = 0, method* m62 = 0, method* m63 = 0, method* m64 = 0, + method* m65 = 0, method* m66 = 0, method* m67 = 0, method* m68 = 0, method* m69 = 0) : TestFixture( m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, - m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, - m20, m21, m22, m23, m24, m25, m26, m27, m28, m29, - m30, m31, m32, m33, m34, m35, m36, m37, m38, m39, - m40, m41, m42, m43, m44, m45, m46, m47, m48, m49, name, parallel) { } + m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, + m20, m21, m22, m23, m24, m25, m26, m27, m28, m29, + m30, m31, m32, m33, m34, m35, m36, m37, m38, m39, + m40, m41, m42, m43, m44, m45, m46, m47, m48, m49, + m50, m51, m52, m53, m54, m55, m56, m57, m58, m59, + m60, m61, m62, m63, m64, m65, m66, m67, m68, m69, parallel) { } /** * Base constructor to register methods with the test fixture. A test - * fixture can register up to 50 methods. + * fixture can register up to 70 methods. * * @param[in] m0..m49 The methods to register with the test fixture. */ @@ -308,6 +320,10 @@ namespace tpunit { method* m35 = 0, method* m36 = 0, method* m37 = 0, method* m38 = 0, method* m39 = 0, method* m40 = 0, method* m41 = 0, method* m42 = 0, method* m43 = 0, method* m44 = 0, method* m45 = 0, method* m46 = 0, method* m47 = 0, method* m48 = 0, method* m49 = 0, + method* m50 = 0, method* m51 = 0, method* m52 = 0, method* m53 = 0, method* m54 = 0, + method* m55 = 0, method* m56 = 0, method* m57 = 0, method* m58 = 0, method* m59 = 0, + method* m60 = 0, method* m61 = 0, method* m62 = 0, method* m63 = 0, method* m64 = 0, + method* m65 = 0, method* m66 = 0, method* m67 = 0, method* m68 = 0, method* m69 = 0, const char* name = 0, bool parallel = false); ~TestFixture(); From 4512722d98ef588891dfde9440d1c4f5d44d2aa5 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 9 Apr 2024 13:57:39 -0700 Subject: [PATCH 3/4] fix function signature --- test/lib/tpunit++.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/tpunit++.hpp b/test/lib/tpunit++.hpp index 6ec5beea1..9d10390b9 100644 --- a/test/lib/tpunit++.hpp +++ b/test/lib/tpunit++.hpp @@ -302,7 +302,7 @@ namespace tpunit { m30, m31, m32, m33, m34, m35, m36, m37, m38, m39, m40, m41, m42, m43, m44, m45, m46, m47, m48, m49, m50, m51, m52, m53, m54, m55, m56, m57, m58, m59, - m60, m61, m62, m63, m64, m65, m66, m67, m68, m69, parallel) { } + m60, m61, m62, m63, m64, m65, m66, m67, m68, m69, name, parallel) { } /** * Base constructor to register methods with the test fixture. A test From ed15da59177c9e3c72070ea4b5594c70d664a574 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 9 Apr 2024 14:04:58 -0700 Subject: [PATCH 4/4] update CPP file to match --- test/lib/tpunit++.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/lib/tpunit++.cpp b/test/lib/tpunit++.cpp index 0b0f8b9a0..c884895a4 100644 --- a/test/lib/tpunit++.cpp +++ b/test/lib/tpunit++.cpp @@ -48,6 +48,10 @@ tpunit::TestFixture::TestFixture(method* m0, method* m1, method* m2, method* method* m35, method* m36, method* m37, method* m38, method* m39, method* m40, method* m41, method* m42, method* m43, method* m44, method* m45, method* m46, method* m47, method* m48, method* m49, + method* m50, method* m51, method* m52, method* m53, method* m54, + method* m55, method* m56, method* m57, method* m58, method* m59, + method* m60, method* m61, method* m62, method* m63, method* m64, + method* m65, method* m66, method* m67, method* m68, method* m69, const char* name, bool parallel) : _name(name), _parallel(parallel)