Commit Graph

44 Commits

Author SHA1 Message Date
Martin Kleusberg
7e0adabd6a Fix primary key names not being escaped
See issue #613.
2016-05-27 22:32:53 +02:00
Martin Kleusberg
00ee9b8da4 Actually fix tests
I'm stupid.
2015-12-22 19:10:31 +01:00
Martin Kleusberg
0e18e36aa9 Parse foreign key clauses instead of just treating them as a big string
This changes the SQL grammar parser so that it parses foreign key
clauses instead of just reading to the end of the clause when
encoutering one. This allows using the information inside the clause
later in a more effective way. However, as of now this isn't used yet.
This commit only attempts to imitate the old behaviour using the new
approach (and might fail doing so, causing new errors...).
2015-06-21 22:09:36 +02:00
Pino Toscano
ae08f772a2 cmake: use an external antlr2 if available
Look for an installed antlr v2, and if available use it instead of its
embedded copy.
2015-05-03 15:44:42 +02:00
Pino Toscano
8d07f120bf tests: remove DBBrowserDB usage from test-import
Apparently DBBrowserDB is not really used, so remove it and cleanup
test-import from the extra sources and dependencies needed by that.
2015-05-03 14:37:18 +02:00
Pino Toscano
27df9cfa4d tests: split sqlb-unittests
Instead of a single executable running different unit tests at the
same time, split the sqlobjects and import parts out of it.
While this currently duplicates the cmake boilerplate for each,
it allows to finetune each properly (like build only the sources for
it, in the future), and to call each separately.

Add the QTEST_MAIN in each test, and remove the manual QCoreApplication
handling in TestImport (handled by QTEST_MAIN).
2015-05-03 14:34:09 +02:00
Pino Toscano
57f2622e34 tests: merge build of tests within main build
Instead of a separate CMakeLists.txt for the tests, make them built
together with the rest of the main project. This behaviour is off
by default, and can be enabled using ENABLE_TESTING.

Furthermore, the testing facilities of cmake are now used, so ctest
(invoked by `make test`) knows about the sqlb-unittests. Thus, adapt
the Travis build steps, building the main sources and executing the
tests twice, one for sqlite and one for sqlcipher.
2015-05-03 14:29:00 +02:00
Pino Toscano
584f5d66bb tests: fix encoding handling in TestImport
Make sure to write the temporary CSV file in the proper encoding
(i.e. the one specified by the test data), and to use that encoding
when reading back from it.
This way the test should behave correctly, no matter the current
system charset.

Furthermore, fix and extend unicode data: the current utf8chars is
actually UTF-16 data, so rename it and change its encoding as such.
Add a proper utf8chars data with UTF-8-only characters.
2015-05-02 16:31:09 +02:00
Samir Aguiar
d4215052dd unittests: Pass a safely modifiable arg to QCoreApplication
This also silents C++11 warning about deprecated conversion.
2015-03-10 10:18:56 +01:00
Samir Aguiar
f1ac26e216 csvparser: Unit tests for old Mac line endings and empty strings 2015-03-04 21:29:03 +01:00
Pino Toscano
afaf2ca73c tests: fix QCoreApplication parameters
The argument count (first parameter) is a reference, and thus must be
kept alive for the whole lifetime of the QCoreApplication instance,
as also the Qt apidocs say.

Also properly create a "string array" for the actual args, instead
of badly casting a string to that.

This fixes sporadic crashes in this test.
2015-01-17 13:06:22 +01:00
Martin Kleusberg
a090875575 tests: Add test for grammar fix in 1ea67c33d2 2015-01-06 14:12:08 +01:00
Martin Kleusberg
4b7766a0fe tests: Add tests for foreign key parsing 2014-11-06 18:29:34 +01:00
Martin Kleusberg
19baeb2a7a grammar: Fix double quote characters as used for escaping one
SQL allows you to use two quote characters instead of just one in order
to escape them. Example: ['aa''bb'] is read as [aa'bb]. Add detection
for these doubled quote characters to our grammar parser.

See issue #128.
2014-10-15 19:29:19 +02:00
Martin Kleusberg
b841025bae tests: Add test to check escaping quotes by using two of them 2014-10-15 12:57:37 +02:00
Peinthor Rene
0031c0723f tests: fix tests to run without x server 2014-09-18 08:05:45 +02:00
Peinthor Rene
98ab683662 tests: fix tests to run without x server 2014-09-18 08:01:04 +02:00
Peinthor Rene
97e2025cc9 cvsparser: Newly implemented CSV Parser
Moved parser into it's own class
This parser now proper supports new lines in quoted text
and returns a QVector<QStringList> result.
2014-09-02 18:05:04 +02:00
Martin Kleusberg
03879d93f0 ImportCsvDialog: Allow other file encoding than UTF-8
Add a combobox and a text field for choosing a different encoding of the
input file than the default UTF-8.
2014-08-31 13:10:25 +02:00
Sandro Mani
27b6bef37d Fix bad test 2014-08-27 19:04:38 +02:00
Sandro Mani
6b4d079e6a Fix syntax issues 2014-08-27 19:04:35 +02:00
Martin Kleusberg
ba75bd16fe Use common format for all include guards and avoid leading underscores
Use a common format for all include guards, make sure each header file
has one and make sure it's named after the file name.

And as a random extra in this commit: Make sure the gen_version.h file
generated by cmake ends with a line break.

Closes #59.
2014-07-31 21:32:58 +02:00
Martin Kleusberg
42a2faf411 Tests: Simplify the cmake file
Now that the dependeny to the main window is removed from the
DBBrowserDB class we can get rid of all the dialogs and widget related
stuff in the cmake file used for the unit test project. Because our
Application class depends on the main window, too, the code for the CSV
tests is changed to use Qt's standard QApplication class.
2014-07-12 16:21:08 +02:00
Martin Kleusberg
e7924f3739 Tests: Add unit tests for CSV import
Add a new test class for testing the import functionality. Currently
it's only covers some test cases for the CSV import.

Since the function to test here (DBBrowserDB::decodeCSV) is part of the
DBBrowserDB class, that class has a reference to the main window and the
main window basically depends on the entire rest of the project the
makefile grew quite a bit unfortunately.
2014-07-11 21:31:34 +02:00
Martin Kleusberg
ceb74a8cd4 Tests: Make sure the TestTable::parseSQLdefaultexpr() passes
Fix some issues in the parseSQLdefaultexpr unit test to make it actuall
pass.
2014-07-10 21:38:35 +02:00
Peinthor Rene
0df6148afe unittest: add test for literalvalue in default constraint 2014-07-10 07:30:25 +02:00
Peinthor Rene
f2658958ce unittest: add a check for not exists 2014-07-05 15:16:16 +02:00
Peinthor Rene
e1ea78fdda grammar: add tests for like operator and between 2014-06-25 19:20:58 +02:00
Martin Kleusberg
3da0d36463 Tests: Make sure all unit tests pass
Two unit tests where failing because of missing spaces in the expected
result string.
2014-06-20 12:51:56 +02:00
Martin Kleusberg
980f42d200 Tests: Add unit test for CHECK NOT LIKE constraint
Add a unit test for the grammar fix in
9cb0614ecf.
2014-06-20 12:50:30 +02:00
Peinthor Rene
f246ddde1e correctly extract check expression from AST 2014-06-11 22:48:51 +02:00
Peinthor Rene
55d8c9f9d8 add a test with create table with IN 2014-06-11 22:48:51 +02:00
Martin Kleusberg
1f8686d1d4 Add tests for the new 'without rowid' parsing
Add tests for the 'without rowid' parsing in our SQL grammar added in
commit 3761acfd02.
2014-05-09 14:49:32 +02:00
Peinthor Rene
192ee9c0a8 add unittest for non ascii characters 2014-02-12 19:15:27 +01:00
Peinthor Rene
9214cfbc21 add a unittest for the keyword in column name issue 2013-11-24 10:26:32 +01:00
Martin Kleusberg
b924859392 Tests: Add test for ed04128a74
Add a test for table and column names in single quotes for which support
was added in ed04128a74.
2013-07-18 20:45:27 +02:00
Peinthor Rene
1bef2501c0 tests: make this statement work in sqlite3 2013-07-18 15:42:33 +02:00
Peinthor Rene
26bb0e1adf split unittest class into header and cpp file 2013-07-11 16:12:45 +02:00
Martin Kleusberg
63cf871017 SqliteTypes: Move PK flag from table to field
Store the primary key flag(s) inside the sqlb::Field objects instead of
the sqlb::Table object. Technically this doesn't make a lot of sense but
then again it makes things a lot easier for us. So this should fix quite
a few issues in the entire program, especially - again - in
renameColumn(). It also magically fixes createColumn() which had no
chance of guessing which column should be a PK prior to this.

To benefit from these changes the EditTableDialog has changes as well.
- It should now be possible to set and unset PK and AI flags and they
  are actually saved.
- Setting the AI flag automatically sets the data type to Integer
  because that's the only type SQLite can handle in an autoincrement
  field.
- Clicking on the entry in the data type combobox which is currently
  selected doesn't update the DB anymore.

This commit also makes some changes to the unit tests to reflect the API
changes made. But it also adds missing quote characters in some
verification strings.

I hope this is a worthy 500th commit - at least it's got a long commit
message...
2013-06-03 20:15:29 +02:00
Peinthor Rene
a95d33e5ee add unittest for foreign key parser problem 2013-05-03 21:12:56 +02:00
Peinthor Rene
f4187521ee improve the unittests for create table parsing 2013-03-22 15:50:26 +01:00
Peinthor Rene
1b0d5a2ff9 Fix view updating after remove field in edittable dialog
rename the FieldList typedef to FieldVector
use a object instead of a table pointer in edittable dialog
2013-03-19 17:18:52 +01:00
Peinthor Rene
5737925079 Add a sqlite3 antlr2 "create table" grammar + generated parser files
There is also a "create table" ast walker which fills
info for the new sqlitetype objects.
A dependency to the antlr2 runtime was added.
The grammar most probably still contain bugs.
Why all this?
First writing grammars is fun and this is the only way
we can get all information for proper table editing + some time
in the future when the grammar is finished we can provide real
auto completion.
2013-03-16 20:18:57 +01:00
Peinthor Rene
9394caffa9 add classes for a new sqlite field and table objects
plus a unittest build mode
2013-02-28 17:15:03 +01:00