Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minorsecond committed Oct 1, 2022
1 parent daa8ba5 commit d82ff7b
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/graphing_calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <map>
#include <cstring>
#include <sstream>
#include <algorithm>
#include "graphing_calculations.h"

#ifdef __WIN32
Expand Down
35 changes: 30 additions & 5 deletions test/test_calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ TEST_CASE("Oz Alcohol Remaining", "[Drink Calculations]") {
}

TEST_CASE("Mean ABV", "[Drink Calculations]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -183,7 +188,12 @@ TEST_CASE("Mean ABV", "[Drink Calculations]") {
}

TEST_CASE("Mean IBU", "[Drink Calculations]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -257,7 +267,12 @@ TEST_CASE("Mean IBU", "[Drink Calculations]") {
}

TEST_CASE("Favorite Brewery", "[Favorite Calculations]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -331,7 +346,12 @@ TEST_CASE("Favorite Brewery", "[Favorite Calculations]") {
}

TEST_CASE("Favorite Drink", "[Favorite Calculations]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -405,7 +425,12 @@ TEST_CASE("Favorite Drink", "[Favorite Calculations]") {
}

TEST_CASE("Favorite Type", "[Favorite Calculations]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down
90 changes: 77 additions & 13 deletions test/test_database_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ inline bool exists (const std::string& name) {
}

TEST_CASE("Init DB", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif
const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand All @@ -35,7 +39,12 @@ TEST_CASE("Init DB", "[DB Functions]") {
}

TEST_CASE("DB IO", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -101,7 +110,12 @@ TEST_CASE("DB IO", "[DB Functions]") {
}

TEST_CASE("Truncate DB", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -160,7 +174,12 @@ TEST_CASE("Truncate DB", "[DB Functions]") {
}

TEST_CASE("Delete Row", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -232,7 +251,12 @@ TEST_CASE("Delete Row", "[DB Functions]") {
}

TEST_CASE("Read Row", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -294,7 +318,12 @@ TEST_CASE("Read Row", "[DB Functions]") {
}

TEST_CASE("Write Row", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -332,7 +361,12 @@ TEST_CASE("Write Row", "[DB Functions]") {
}

TEST_CASE("Update Row", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -410,7 +444,12 @@ TEST_CASE("Update Row", "[DB Functions]") {
}

TEST_CASE("Increment Version", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand All @@ -426,7 +465,12 @@ TEST_CASE("Increment Version", "[DB Functions]") {
}

TEST_CASE("Filter DB", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -516,7 +560,12 @@ TEST_CASE("Filter DB", "[DB Functions]") {
}

TEST_CASE("Get Drink By Name", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -593,7 +642,12 @@ TEST_CASE("Get Drink By Name", "[DB Functions]") {
}

TEST_CASE("Get Beers By Type", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -672,7 +726,12 @@ TEST_CASE("Get Beers By Type", "[DB Functions]") {
}

TEST_CASE("Get Beers By Brewery", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down Expand Up @@ -751,7 +810,12 @@ TEST_CASE("Get Beers By Brewery", "[DB Functions]") {
}

TEST_CASE("DB Sort", "[DB Functions]") {
std::string current_path = std::filesystem::current_path();
#ifdef __WIN32
const std::string current_path {std::filesystem::current_path().string()};
#else
const std::string current_path = std::filesystem::current_path();
#endif

const char *file_name = "testdb.db";
std::string db_path = current_path + "/" + file_name;

Expand Down

0 comments on commit d82ff7b

Please sign in to comment.