Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved tokenizer function to handle extra spaces #85

Merged
merged 2 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ namespace xeus_sqlite
/*
Separetes the input with spaces.
*/
std::stringstream sanitized_input(sanitize_string(input));
std::istringstream sanitized_input(sanitize_string(input));
std::string segment;
std::vector<std::string> tokenized_input;

while(std::getline(sanitized_input, segment, ' '))
while(sanitized_input >> segment)
{
tokenized_input.push_back(segment);
}
Expand All @@ -80,5 +80,4 @@ namespace xeus_sqlite
return upper_case_input;
}


}
14 changes: 7 additions & 7 deletions test/test_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ TEST(xeus_sqlite_interpreter, sanitize_string_check)
EXPECT_EQ(sanitized_string, " Some input");
}

// TEST(xeus_sqlite_interpreter, tokenizer_check)
// {
// std::string code = "%LOAD database.db rw";
// std::vector<std::string> tokenized_code;
// tokenized_code = tokenizer(code);
// EXPECT_EQ(tokenized_code[2], "database.db");
// }
TEST(xeus_sqlite_interpreter, tokenizer_check)
{
std::string code = "%LOAD database.db rw";
std::vector<std::string> tokenized_code;
tokenized_code = tokenizer(code);
EXPECT_EQ(tokenized_code[2], "database.db");
}

// TEST(xeus_sqlite_interpreter, is_magic_check)
// {
Expand Down