diff --git a/include/database.hpp b/include/database.hpp index 60217352..a8800128 100644 --- a/include/database.hpp +++ b/include/database.hpp @@ -119,6 +119,9 @@ unsigned int Database :: actual_size() template typename Database::iterator Database :: begin() { + if (size() == 0) + return end(); + iterator it = _db.begin(); if ( (*it).valid == true ) return it; diff --git a/tests/database b/tests/database index 35830ee5..2dfac707 100755 --- a/tests/database +++ b/tests/database @@ -7,7 +7,7 @@ function test_autosave { new_test "Database Test (n = $1, autosave = true)" src/database.run -a $1 - if [ ! -f $DATA_DIR/database.db ]; then + if [ ! -f $DATA_DIR/database.db ] && [ $1 != 0 ]; then echo "ERROR: $DATA_DIR/database.db doesn't exist!" exit 1 fi @@ -34,6 +34,8 @@ function run_test fi } +run_test 0 +echo run_test 10 echo run_test 100