I have two C++ functions, which each construct an SQLite database.
First function constructs database version 1, and then upgrades it to newest version by adding all tables/columns that have been added to the database since the first version. Another function constructs a database that is already in the newest version. As result, each function gives one database that has all necessary tables and columns, but no values.
I wish to write an unit test that compares the results of those two functions. I want to test that they have exactly the same tables and columns, and that all columns have the same CHECK and NOT NULL constraints. I only need to compare columns and tables, because the databases have no values in them at this point.
I would prefer to get the differences in a human readable form (to place them in an error message), but a boolean value (different/not different) is also fine.
How can I do that, given that both databases are in different variables and I cannot combine them?
There are other questions that suggest external applications for this, but can I do it in a simple way in C++? One possibility is to execute some SQL commands for each database, and compare the results in a for loop, but which commands do I need?
Aucun commentaire:
Enregistrer un commentaire