mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-21 00:01:55 -09:00
support/testing: sqlitecpp: new runtime test
build and run an SQLiteCpp example to check database writes and queries.
Assisted-by: GitHub Copilot:GPT-6 Sol
Signed-off-by: Michael Nosthoff <buildroot@heine.tech>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 93c6c91955)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
committed by
Raphaël Mélotte
parent
95f448c511
commit
9d96d396ec
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_SQLITECPP_PATH/package/sqlitecpp-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: SQLITECPP
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_SQLITECPP_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_SQLITECPP_TEST
|
||||
bool "sqlitecpp-test"
|
||||
depends on BR2_PACKAGE_SQLITECPP
|
||||
help
|
||||
Test program for the SQLiteCpp library.
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <SQLiteCpp/SQLiteCpp.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||
db.exec("CREATE TABLE fruits (name TEXT, color TEXT)");
|
||||
|
||||
SQLite::Statement insert(db, "INSERT INTO fruits VALUES (?, ?)");
|
||||
insert.bind(1, "Banana");
|
||||
insert.bind(2, "Yellow");
|
||||
insert.exec();
|
||||
|
||||
SQLite::Statement query(db, "SELECT name, color FROM fruits");
|
||||
if (!query.executeStep()) {
|
||||
return 1;
|
||||
}
|
||||
const std::string name = query.getColumn(0).getString();
|
||||
const std::string color = query.getColumn(1).getString();
|
||||
if (name != "Banana" || color != "Yellow" || query.executeStep()) {
|
||||
return 1;
|
||||
}
|
||||
std::cout << name << ": " << color << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
################################################################################
|
||||
#
|
||||
# sqlitecpp-test
|
||||
#
|
||||
################################################################################
|
||||
|
||||
SQLITECPP_TEST_DEPENDENCIES = sqlitecpp
|
||||
|
||||
define SQLITECPP_TEST_BUILD_CMDS
|
||||
$(TARGET_CXX) $(TARGET_CXXFLAGS) -o $(@D)/sqlitecpp-test \
|
||||
$(SQLITECPP_TEST_PKGDIR)/sqlitecpp-test.cpp \
|
||||
$(TARGET_LDFLAGS) -lSQLiteCpp -lsqlite3
|
||||
endef
|
||||
|
||||
define SQLITECPP_TEST_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/sqlitecpp-test $(TARGET_DIR)/usr/bin/sqlitecpp-test
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user