aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/UnitTests/testsqllite.pas
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 10:58:54 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 10:58:54 +0000
commit25f33e77d2254791d76cc84f0f9e67e9cccf1a67 (patch)
tree8ffbf2478e6c0131ca59eef25b6212c12af0b7c1 /Game/Code/UnitTests/testsqllite.pas
parent23ba71caadfb9adc0d70a44848899d95a0097f85 (diff)
downloadusdx-25f33e77d2254791d76cc84f0f9e67e9cccf1a67.tar.gz
usdx-25f33e77d2254791d76cc84f0f9e67e9cccf1a67.tar.xz
usdx-25f33e77d2254791d76cc84f0f9e67e9cccf1a67.zip
added first steps to building some unit tests.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@920 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/UnitTests/testsqllite.pas')
-rw-r--r--Game/Code/UnitTests/testsqllite.pas84
1 files changed, 84 insertions, 0 deletions
diff --git a/Game/Code/UnitTests/testsqllite.pas b/Game/Code/UnitTests/testsqllite.pas
new file mode 100644
index 00000000..b1b682d2
--- /dev/null
+++ b/Game/Code/UnitTests/testsqllite.pas
@@ -0,0 +1,84 @@
+unit TestSQLLite;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, fpcunit, testutils, testregistry, SQLiteTable3, unix;
+
+type
+
+ TTest_SqlLite= class(TTestCase)
+ private
+ fSQLLite : TSQLiteDatabase;
+ fFileName : string;
+ protected
+ procedure SetUp; override;
+ procedure TearDown; override;
+ published
+ procedure Test_Random_TableExists;
+ procedure Test_Delete_NonExistant_Table;
+ procedure Test_TableExists_On_0Length_File;
+ end;
+
+implementation
+
+procedure TTest_SqlLite.Test_Random_TableExists;
+begin
+ deletefile( fFileName );
+ fSQLLite := TSQLiteDatabase.Create( fFileName );
+
+ // Test if some random table exists
+ check( not fSQLLite.TableExists( 'testTable'+floattostr(now()) ) , 'Randomly Named Table Should NOT Exists (In an empty database file)' );
+end;
+
+procedure TTest_SqlLite.Test_Delete_NonExistant_Table;
+var
+ lSQL : String;
+begin
+ deletefile( fFileName );
+ fSQLLite := TSQLiteDatabase.Create( fFileName );
+ try
+ lSQL := 'DROP TABLE testtable';
+ fSQLLite.execsql( lSQL );
+ except
+ exit;
+ end;
+
+ Fail('SQLLite did not except when trying to delete a non existant table' );
+end;
+
+procedure TTest_SqlLite.Test_TableExists_On_0Length_File;
+var
+ lSQL : String;
+begin
+ deletefile( fFileName );
+ shell('cat /dev/null > '+fFileName);
+
+ if not fileexists( fFileName ) then
+ Fail('0 Length file was not created... oops' );
+
+ fSQLLite := TSQLiteDatabase.Create( fFileName );
+
+ check( not fSQLLite.TableExists( 'testTable' ) , 'Randomly Named Table Should NOT Exists' );
+end;
+
+
+procedure TTest_SqlLite.SetUp;
+begin
+ fFileName := 'test.db';
+// fSQLLite := TSQLiteDatabase.Create( fFileName );
+end;
+
+
+procedure TTest_SqlLite.TearDown;
+begin
+ freeandnil( fSQLLite );
+end;
+
+initialization
+
+ RegisterTest(TTest_SqlLite);
+end.
+