-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1b7ce4
commit c10a87a
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <libstuff/SQuery.h> | ||
#include <test/lib/BedrockTester.h> | ||
|
||
struct SQueryTest : tpunit::TestFixture { | ||
SQueryTest() : tpunit::TestFixture(true, "SQuery", | ||
TEST(SQueryTest::testPrepare) | ||
) | ||
{} | ||
|
||
void testPrepare() { | ||
// single param | ||
ASSERT_EQUAL(SQuery::prepare("SELECT * FROM accounts WHERE accountID = {accountID};", {{"accountID", 42}}), "SELECT * FROM accounts WHERE accountID = 42;"); | ||
|
||
// multiple params | ||
ASSERT_EQUAL(SQuery::prepare("SELECT * FROM reports WHERE accountID = {accountID} AND reportID = {reportID};", {{"accountID", 42}, {"reportID", 52}}), "SELECT * FROM reports WHERE accountID = 42 AND reportID = 52;"); | ||
|
||
// multiple params, multiple instances | ||
ASSERT_EQUAL(SQuery::prepare("SELECT * FROM reportActions WHERE action == {actionCreated} OR (action != {actionCreated} AND created < {timestamp});", {{"actionCreated", "CREATED"}, {"timestamp", "2024-01-01 12:00:00"}}), "SELECT * FROM reportActions WHERE action == 'CREATED' OR (action != 'CREATED' AND created < '2024-01-01 12:00:00');"); | ||
} | ||
} __SQueryTest; |