← cproj

tests

00d877fa3d7f79a3eff95ab2d98ddcc96de9c22c · ovidiucs · Dec 17, 2019 21:49

+28 −8 · 3 files changed

  • graph/db/include/sqltest.h +4 −1
  • graph/db/tests/sqltest.o binary
  • graph/db/tests/sqltest_test.c +24 −7
diff --git a/graph/db/include/sqltest.h b/graph/db/include/sqltest.h
index 678475d..002a925 100644
--- a/graph/db/include/sqltest.h
+++ b/graph/db/include/sqltest.h
@@ -1,4 +1,5 @@
-
+#ifndef SQLTEST_H
+#define SQLTEST_H
  /*!
   *  @dir include
   *  @brief include directory for header files
@@ -90,3 +91,5 @@ int setup(sqlite3 **p_db);
  * @return int
  */
 static int callback(void *data, int argc, char **argv, char **azColName );
+
+#endif
diff --git a/graph/db/tests/sqltest.o b/graph/db/tests/sqltest.o
new file mode 100644
index 0000000..f3abbf4
Binary files /dev/null and b/graph/db/tests/sqltest.o differ
diff --git a/graph/db/tests/sqltest_test.c b/graph/db/tests/sqltest_test.c
index c69925e..f9b1971 100644
--- a/graph/db/tests/sqltest_test.c
+++ b/graph/db/tests/sqltest_test.c
@@ -3,24 +3,41 @@
  *  @brief Unit testing folder
  *  @details No other details
  */
-
-#include <criterion/criterion.h>
 #include <sqlite3.h>
+
 #include "../include/sqltest.h"
 
+#include <criterion/criterion.h>
+
 #include <stdio.h> // fprintf, printf
 #include <stdlib.h> // exit,
 
-/**
-* Variables used by tests
-*/
 
-Test(tSuite_1, t_001){
+// --------------------------------------------------------
+// ------ Some values and variables used by tests ---------
+// --------------------------------------------------------
   sqlite3 *db = NULL;
+
+// --------------------------------------------------------
+// ------------- Setup and Teardown Functions -------------
+// --------------------------------------------------------
+/* Setup function - initializes the database */
+void t_setup(){
+}
+/* Teardown function - closes the database */
+void teardown(){
+}
+
+Test(tSuite_1, t_001, .init=t_setup, .fini=teardown){
   // test contents
-  cr_assert(setup(db) == 0);
+  int rc = setup(&db);
+  cr_assert( rc == 0);
 }
 
+Test(tSuite_2, t_002) {
+    int *ptr = NULL;
+    *ptr = 42;
+}
 /**
 * Setup and teardown
 */