sqlite3/tests: Remove C-based compat tests

...they're now just duplicating the Rust ones.
This commit is contained in:
Pekka Enberg 2025-05-14 14:01:08 +03:00
parent 0db542171f
commit 7458848a56
8 changed files with 0 additions and 193 deletions

View file

@ -1,39 +0,0 @@
# Compiler settings
CC = gcc
CFLAGS = -g -Wall -std=c17 -I../include
# Libraries
LIBS ?= -lsqlite3
LIBS += -lm
# Target program
PROGRAM = sqlite3-tests
# Object files
OBJS = main.o \
test-aux.o \
test-close.o \
test-open.o \
test-prepare.o \
test-wal.o
# Default target
all: $(PROGRAM)
# Test target
test: $(PROGRAM)
./$(PROGRAM)
# Compile source files
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Link program
$(PROGRAM): $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)
# Clean target
clean:
rm -f $(PROGRAM) $(OBJS)
.PHONY: all test clean

View file

@ -1,11 +0,0 @@
#ifndef CHECK_H
#define CHECK_EQUAL(expected, actual) \
do { \
if ((expected) != (actual)) { \
fprintf(stderr, "%s:%d: Assertion failed: %d != %d\n", __FILE__, __LINE__, (expected), (actual)); \
exit(1); \
} \
} while (0)
#endif

View file

@ -1,24 +0,0 @@
extern void test_libversion();
extern void test_libversion_number();
extern void test_open_misuse();
extern void test_open_not_found();
extern void test_open_existing();
extern void test_close();
extern void test_prepare_misuse();
extern void test_wal_checkpoint();
extern void test_wal_checkpoint_v2();
int main(int argc, char *argv[])
{
test_libversion();
test_libversion_number();
test_open_misuse();
test_open_not_found();
test_open_existing();
test_close();
test_prepare_misuse();
test_wal_checkpoint();
test_wal_checkpoint_v2();
return 0;
}

View file

@ -1,11 +0,0 @@
#include "check.h"
#include <sqlite3.h>
void test_libversion(void) {
sqlite3_libversion();
}
void test_libversion_number(void) {
sqlite3_libversion_number();
}

View file

@ -1,11 +0,0 @@
#include <sqlite3.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include "check.h"
void test_close(void)
{
CHECK_EQUAL(SQLITE_OK, sqlite3_close(NULL));
}

View file

@ -1,31 +0,0 @@
#include "check.h"
#include <sqlite3.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
void test_open_misuse(void)
{
// TODO: SIGSEGV with sqlite3
// CHECK_EQUAL(SQLITE_MISUSE, sqlite3_open(NULL, NULL));
// CHECK_EQUAL(SQLITE_MISUSE, sqlite3_open("local.db", NULL));
}
void test_open_not_found(void)
{
sqlite3 *db;
CHECK_EQUAL(SQLITE_CANTOPEN, sqlite3_open("not-found/local.db", &db));
}
// TODO: test_open_create
void test_open_existing(void)
{
sqlite3 *db;
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/testing.db", &db));
CHECK_EQUAL(SQLITE_OK, sqlite3_close(db));
}

View file

@ -1,27 +0,0 @@
#include "check.h"
#include <sqlite3.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
void test_prepare_misuse(void)
{
sqlite3 *db;
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/testing.db", &db));
// Database handle is NULL.
// TODO: SIGSEGV with sqlite3
// CHECK_EQUAL(SQLITE_MISUSE, sqlite3_prepare_v2(NULL, "SELECT 1", -1, NULL, NULL));
// Output statement is NULL.
// TODO: SIGSEGV with sqlite3
// CHECK_EQUAL(SQLITE_MISUSE, sqlite3_prepare_v2(db, "SELECT 1", -1, NULL, NULL));
// SQL string length is too short, truncating the statement.
// TODO: SIGSEGV with sqlite3
// CHECK_EQUAL(SQLITE_MISUSE, sqlite3_prepare_v2(db, "SELECT 1", 7, NULL, NULL));
CHECK_EQUAL(SQLITE_OK, sqlite3_close(db));
}

View file

@ -1,39 +0,0 @@
#include "check.h"
#include <sqlite3.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
void test_wal_checkpoint(void)
{
sqlite3 *db;
// Test with NULL db handle
CHECK_EQUAL(SQLITE_MISUSE, sqlite3_wal_checkpoint(NULL, NULL));
// Test with valid db
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/testing.db", &db));
CHECK_EQUAL(SQLITE_OK, sqlite3_wal_checkpoint(db, NULL));
CHECK_EQUAL(SQLITE_OK, sqlite3_close(db));
}
void test_wal_checkpoint_v2(void)
{
sqlite3 *db;
int log_size, checkpoint_count;
// Test with NULL db handle
CHECK_EQUAL(SQLITE_MISUSE, sqlite3_wal_checkpoint_v2(NULL, NULL, SQLITE_CHECKPOINT_PASSIVE, NULL, NULL));
// Test with valid db
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/testing.db", &db));
// Test different checkpoint modes
CHECK_EQUAL(SQLITE_OK, sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_PASSIVE, &log_size, &checkpoint_count));
CHECK_EQUAL(SQLITE_OK, sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_FULL, &log_size, &checkpoint_count));
CHECK_EQUAL(SQLITE_OK, sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_RESTART, &log_size, &checkpoint_count));
CHECK_EQUAL(SQLITE_OK, sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, &log_size, &checkpoint_count));
CHECK_EQUAL(SQLITE_OK, sqlite3_close(db));
}