summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-12-25 23:50:28 -0500
committerJeffrey Walton <noloader@gmail.com>2015-12-25 23:50:28 -0500
commita0b078543abdfb5a508ff75dcd5865c4d6401085 (patch)
treee9b14b648544c986f0fff3967cc64e0a1c3955b3 /datatest.cpp
parent19f72fc73c232b5dabdab3263fd4f0304ed35e1b (diff)
downloadcryptopp-git-a0b078543abdfb5a508ff75dcd5865c4d6401085.tar.gz
Added CRYPTOPP_DATA_DIR patch (Issue 82)
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/datatest.cpp b/datatest.cpp
index 98b5b642..c99e2dbd 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -721,8 +721,15 @@ void OutputNameValuePairs(const NameValuePairs &v)
}
}
-void TestDataFile(const std::string &filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests)
+void TestDataFile(std::string filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests)
{
+ static const std::string dataDirectory(CRYPTOPP_DATA_DIR);
+ if (!dataDirectory.empty())
+ {
+ if(dataDirectory != filename.substr(0, dataDirectory.length()))
+ filename.insert(0, dataDirectory);
+ }
+
std::ifstream file(filename.c_str());
if (!file.good())
throw Exception(Exception::OTHER_ERROR, "Can not open file " + filename + " for reading");
@@ -805,7 +812,7 @@ bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParamet
{
s_thorough = thorough;
unsigned int totalTests = 0, failedTests = 0;
- TestDataFile(filename, overrideParameters, totalTests, failedTests);
+ TestDataFile((filename ? filename : ""), overrideParameters, totalTests, failedTests);
cout << dec << "\nTests complete. Total tests = " << totalTests << ". Failed tests = " << failedTests << ".\n";
if (failedTests != 0)
cout << "SOME TESTS FAILED!\n";