MCPcopy Create free account
hub / github.com/LUX-Core/lux / TestDataFile

Function TestDataFile

src/cryptopp/datatest.cpp:754–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754void TestDataFile(std::string filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests)
755{
756 static const std::string dataDirectory(CRYPTOPP_DATA_DIR);
757 if (!dataDirectory.empty())
758 {
759 if(dataDirectory != filename.substr(0, dataDirectory.length()))
760 filename.insert(0, dataDirectory);
761 }
762
763 std::ifstream file(filename.c_str());
764 if (!file.good())
765 throw Exception(Exception::OTHER_ERROR, "Can not open file " + filename + " for reading");
766 TestData v;
767 s_currentTestData = &v;
768 std::string name, value, lastAlgName;
769
770 while (file)
771 {
772 while (file.peek() == '#')
773 file.ignore((std::numeric_limits<std::streamsize>::max)(), '\n');
774
775 if (file.peek() == '\n' || file.peek() == '\r')
776 v.clear();
777
778 if (!GetField(file, name, value))
779 break;
780 v[name] = value;
781
782 if (name == "Test" && (s_thorough || v["SlowTest"] != "1"))
783 {
784 bool failed = true;
785 std::string algType = GetRequiredDatum(v, "AlgorithmType");
786
787 if (lastAlgName != GetRequiredDatum(v, "Name"))
788 {
789 lastAlgName = GetRequiredDatum(v, "Name");
790 cout << "\nTesting " << algType.c_str() << " algorithm " << lastAlgName.c_str() << ".\n";
791 }
792
793 try
794 {
795 if (algType == "Signature")
796 TestSignatureScheme(v);
797 else if (algType == "SymmetricCipher")
798 TestSymmetricCipher(v, overrideParameters);
799 else if (algType == "AuthenticatedSymmetricCipher")
800 TestAuthenticatedSymmetricCipher(v, overrideParameters);
801 else if (algType == "AsymmetricCipher")
802 TestAsymmetricCipher(v);
803 else if (algType == "MessageDigest")
804 TestDigestOrMAC(v, true);
805 else if (algType == "MAC")
806 TestDigestOrMAC(v, false);
807 else if (algType == "KDF")
808 TestKeyDerivationFunction(v);
809 else if (algType == "FileList")
810 TestDataFile(GetRequiredDatum(v, "Test"), g_nullNameValuePairs, totalTests, failedTests);
811 else

Callers 1

RunTestDataFileFunction · 0.85

Calls 15

GetFieldFunction · 0.85
TestSignatureSchemeFunction · 0.85
TestSymmetricCipherFunction · 0.85
TestAsymmetricCipherFunction · 0.85
TestDigestOrMACFunction · 0.85
ignoreMethod · 0.80
ExceptionFunction · 0.70
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected