Skip to content

Commit

Permalink
Add test cases for broken hash
Browse files Browse the repository at this point in the history
  • Loading branch information
czchen committed Oct 22, 2014
1 parent 5be398c commit 26d303a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/data/import/uhash.dat/**/* binary
Binary file not shown.
1 change: 1 addition & 0 deletions test/data/import/uhash.dat/broken/corrupted_signature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CBi
Binary file added test/data/import/uhash.dat/broken/wrong_signature
Binary file not shown.
12 changes: 12 additions & 0 deletions test/testHashImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ TEST_F(HashImporterTest, ReadUserphrase)
// FIXME: Implement this test cases.
}

TEST_F(HashImporterTest, ReadBrokenHash)
{
auto list = QDir{TESTDATA "/import/uhash.dat/broken"}.entryList(QDir::Files);

foreach(auto file, list) {
auto path = QString("%1/%2").arg(TESTDATA "/import/uhash.dat/broken").arg(file);
HashImporter importer{path};
EXPECT_FALSE(importer.isSupportedFormat());
EXPECT_TRUE(importer.getUserphraseSet().empty());
}
}

TEST_F(HashImporterTest, PathError)
{
HashImporter importer{TESTDATA "/NoSuchPath/uhash.dat"};
Expand Down

0 comments on commit 26d303a

Please sign in to comment.