Skip to content

Commit

Permalink
Fix for #5
Browse files Browse the repository at this point in the history
Why: This was a serious bug
How: By replacing cin with getline
What: closes #5
Tags: getline, bugfix
  • Loading branch information
Abir-Tx committed May 17, 2021
1 parent 2b4f826 commit 0fb8f9a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = appnotex
pkgdesc = Quick terminal based note keeper for Linux Apps
pkgver = 0.9.0
pkgrel = 1
pkgrel = 1.1
url = https://github.com/Abir-Tx/AppNotEx.git
arch = x86_64
license = GPL
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"driver": "SQLite",
"database": "${workspaceFolder:AppNotEx}/data/data.db",
"name": "AppNotExData"
},
{
"previewLimit": 50,
"driver": "SQLite",
"name": "AppNotExTestData",
"database": "${workspaceFolder:AppNotEx}/data/test/data.db"
}
],
"sqltools.useNodeRuntime": true,
Expand Down
8 changes: 4 additions & 4 deletions appnotex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ int main(int argc, char const *argv[]) {

std::string appnameData, distroname, link, note;
std::cout << "App Name: ";
std::cin >> appnameData;
getline(std::cin, appnameData);
std::cout << "Distro Name: ";
std::cin >> distroname;
getline(std::cin, distroname);
std::cout << "App Link: ";
std::cin >> link;
getline(std::cin, link);
std::cout << "Extra Notes: ";
std::cin >> note;
getline(std::cin, note);
bool queryStatus =
db->insertData(dbfilename, tbname, appnameData.c_str(),
distroname.c_str(), link.c_str(), note.c_str());
Expand Down
16 changes: 16 additions & 0 deletions test/appnotexTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ TEST(DatabaseTest, insertQueryTest) {
EXPECT_TRUE(status);
}

TEST(DatabaeTest, fullLineTextTest) {
// Creating database& Table
const char *dbfilename = "../data/test/data.db";
const char *tbname = "DataTest";
Database *db = new Database();

db->createDb(dbfilename);
db->createTable(dbfilename, tbname);

bool status = db->insertData(dbfilename, tbname, "mutt", "Arch",
"www.mutt.org", "Emailclient terminal based");

delete db;
EXPECT_TRUE(status);
}

TEST(DatabaseTest, createDbTest) {
const char *dbfilename = "../data/test/data.db";
const char *tbname = "DataTest";
Expand Down

0 comments on commit 0fb8f9a

Please sign in to comment.