ProteoWizard
Namespaces | Macros | Functions
unit.hpp File Reference
#include "Exception.hpp"
#include "DateTime.hpp"
#include "Filesystem.hpp"
#include "pwiz/utility/math/round.hpp"
#include <string>
#include <sstream>
#include <cmath>
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>

Go to the source code of this file.

Namespaces

 pwiz
 
 pwiz::util
 

Macros

#define unit_assert(x)   (!(x) ? throw std::runtime_error(unit_assert_message(__FILE__, __LINE__, #x)) : 0)
 
#define unit_assert_to_stream(x, os)   ((os) << (!(x) ? unit_assert_message(__FILE__, __LINE__, #x) + "\n" : ""))
 
#define unit_assert_operator_equal(expected, actual)   (!(expected == actual) ? throw std::runtime_error(unit_assert_equal_message(__FILE__, __LINE__, lexical_cast<string>(expected), lexical_cast<string>(actual), #actual)) : 0)
 
#define unit_assert_operator_equal_to_stream(expected, actual, os)   ((os) << (!(expected == actual) ? unit_assert_equal_message(__FILE__, __LINE__, lexical_cast<string>(expected), lexical_cast<string>(actual), #actual) + "\n" : ""))
 
#define unit_assert_equal(x, y, epsilon)   (!(fabs((x)-(y)) <= (epsilon)) ? throw std::runtime_error(unit_assert_numeric_equal_message(__FILE__, __LINE__, (x), (y), (epsilon))) : 0)
 
#define unit_assert_equal_to_stream(x, y, epsilon, os)   ((os) << (!(fabs((x)-(y)) <= (epsilon)) ? unit_assert_numeric_equal_message(__FILE__, __LINE__, (x), (y), (epsilon)) + "\n" : ""))
 
#define unit_assert_throws(x, exception)
 
#define unit_assert_throws_what(x, exception, whatStr)
 
#define unit_assert_matrices_equal(A, B, epsilon)   unit_assert(boost::numeric::ublas::norm_frobenius((A)-(B)) < (epsilon))
 
#define unit_assert_vectors_equal(A, B, epsilon)   unit_assert(boost::numeric::ublas::norm_2((A)-(B)) < (epsilon))
 
#define TEST_PROLOG_EX(argc, argv, suffix)
 
#define TEST_PROLOG(argc, argv)   TEST_PROLOG_EX(argc, argv, "")
 
#define TEST_FAILED(x)
 
#define TEST_EPILOG
 

Functions

std::string pwiz::util::unit_assert_message (const char *filename, int line, const char *expression)
 
std::string pwiz::util::unit_assert_equal_message (const char *filename, int line, const std::string &x, const std::string &y, const char *expression)
 
std::string pwiz::util::unit_assert_numeric_equal_message (const char *filename, int line, double x, double y, double epsilon)
 
std::string pwiz::util::unit_assert_exception_message (const char *filename, int line, const char *expression, const std::string &exception)
 
std::string pwiz::util::quote_string (const string &str)
 
std::string pwiz::util::escape_teamcity_string (const std::string &str)
 

Macro Definition Documentation

§ unit_assert

#define unit_assert (   x)    (!(x) ? throw std::runtime_error(unit_assert_message(__FILE__, __LINE__, #x)) : 0)

Definition at line 85 of file unit.hpp.

Referenced by checkSpectrumInfo(), checkTestPair(), compare(), createTestPath(), diff(), doSomething(), main(), modificationTest(), operatorTest(), readData(), runSpecialTest(), SecondHandler::startElement(), test(), test1(), test2(), test256(), test5peptide(), test5peptideFT(), test_compute(), test_createFilter(), test_createFilters(), test_default_double(), test_default_float(), test_format_date_time(), test_multiplier(), test_parse_date_time(), test_SampledData(), test_SNR(), test_time_from_OADATE(), test_v3(), test_xml_datetime(), testAbbreviateByteSize(), testAccept(), testAddition(), testAlternativeProtein(), testAmbiguousResidue(), testAminoAcidModification(), testAnalysisData(), testAnalysisResult(), testAnalysisSampleCollection(), testAnalysisSoftware(), testAnalyzer(), testAutomaticUpdate(), testBadFile(), testBandedComplex(), testBasic(), testBinaryDataArray(), testBinaryDataArrayExternalMetadata(), testBinaryDataOnly(), testBombesin(), testCancel(), testChromatogram(), testChromatogramList(), testChromatogramListWithPositions(), testChromatograms(), testCleavageAgents(), testComplex(), testComponent(), testComponentList(), testCompound(), testConfiguration(), testContact(), testContactRole(), testContacts(), testContainer(), testContains(), testCreation(), testCV(), testCVMap(), testCVMapIO(), testCVParam(), testData(), testData2_LocalMax(), testData2_Parabola(), testDatabaseTranslation(), testDataCollection(), testDataProcessing(), testDBSequence(), testDefault(), testDefaultTabHandler(), testDeisotoping(), testDetector(), testDigestedPeptides(), testDouble(), testEnzymaticSearchConstraint(), testEnzyme(), testEquality(), testEven(), testEvenMS2(), testEvidence(), testExpandPathmask(), testExtraction(), testFeature(), testFeatureAux(), testFeatureDetectorSimple(), testFeatureField(), testFile(), testFileContent(), testFileDescription(), testFilename(), testFileReads(), testFilter(), testFind(), testFloating(), testFormula(), testFormulaOperations(), testFragmentArray(), testGaussian_Bombesin2(), testGaussian_Bombesin3(), testGet(), testHasBinaryData(), testIdentData(), testIdentifiable(), testIDParsing(), testIDTranslation(), testIndexSet(), testInfo(), testInputs(), testInstantiation(), testInstrument(), testInstrumentConfiguration(), testIntegralReally(), testIntensityThresholding(), testIntervalExtraction(), testIntervalExtraction2(), testIntExtraction(), testIO(), testIonisation(), testIonType(), testIs(), testIsA(), testIsChildOf(), testIStream(), testIsWithinTolerance(), testIteratorEquality(), testMassAbundance(), testMassAnalyzerFilter(), testMassTable(), testMatch(), testMatchData(), testMaxPrecisionDiff(), testMeasure(), testMemoryMRUCache(), testMetadata(), testMillion(), testModAminoAcidMass(), testModeBinaryDataOnly(), testModelAndManufacturer(), testModeMetaDataAndBinaryData(), testModeMetaDataAndSequence(), testModeMetaDataOnly(), testModeOff(), testModification(), testModificationInfo(), testMRU(), testMS2Activation(), testMS2Denoising(), testMSData(), testMSDataConstruction(), testMSDiffUpdate(), testMSInspectIStream(), testMSLevelSet(), testMSMSPipelineAnalysis(), testMSMSRunSummary(), testMulti(), testMultiplePeaks(), testMZPresentFilter(), testNontrypticBSA(), testNormalization(), testObject(), testObject_ChromatogramList(), testObject_SpectrumList(), testObjectWithMSData(), testOtherRelations(), testParabola(), testParamContainer(), testParameterConversion(), testParamGroup(), testParse(), testParse2(), testPeak(), testPeakData(), testPeakel(), testPeakelAux(), testPeakelConstruction(), testPeakelField(), testPeakEquality(), testPeakFamily(), testPeptide(), testPeptideEvidence(), testPeptideHypothesis(), testPeptideProphetResult(), testPepXMLSpecificity(), testPerson(), testPrecursor(), testPrecursorMassRemoval(), testPrecursorRefine(), testPredicate(), testPredicate_Feature(), testPrediction(), testProcessingMethod(), testProduct(), testProjected(), testProtein(), testProteinAmbiguityGroup(), testProteinDetectionHypothesis(), testProteinDetectionList(), testProteinDetectionProtocol(), testProteinList(), testProteinListSimple(), testProteomeData(), testQ3RatioResult(), testQR(), testRead(), testReader(), testRectangularQR(), testRegexCVMap(), testRegexCVMapIO(), testRemove(), testResidue(), testRetentionTime(), testReversedList(), testRun(), testSample(), testSampleEnzyme(), testScan(), testScanEventSet(), testScanList(), testScanNumberSet(), testScanSettings(), testScanTimeRange(), testSearchDatabase(), testSearchHit(), testSearchModification(), testSearchResult(), testSearchSummary(), testSelectedIndices(), testSemitrypticBSA(), testSemitrypticMethionineClippingBSA(), testSerialize(), testSerializeReally(), testSHA1(), testShift(), testShuffledList(), testSieve(), testSnapModifications(), testSoftware(), testSource(), testSourceFile(), testSpecificity(), testSpectraData(), testSpectrum(), testSpectrumIdentificationList(), testSpectrumIdentificationProtocol(), testSpectrumList(), testSpectrumListSimple(), testSpectrumListWithPositions(), testSpectrumListWriteProgress(), testSpectrumQuery(), testStatic(), testStream(), testString(), testSynonyms(), testTarget(), testThreadSafety(), testThreadSafetyWorker(), testToy(), testToyExample(), testTraData(), testTransition(), testTranslation(), testTrypticBSA(), testUpdateRequest(), testUpperBound(), testUserParam(), testValidation(), testVectorIO(), testWrap(), testWrapActivation(), testWrapDefaultArrayLength(), testWrapMassAnalyzer(), testWrapMSLevel(), testWrapMZWindow(), testWrapPolarity(), testWrapScanTimeRange(), testWrapSortScanTime(), testWriteRead(), testWriteReadBMS1(), testWriteReadBMS2(), testWriteReadCMS1(), testWriteReadCMS2(), testWriteReadMS1(), testWriteReadMS2(), testZeroSamplesFilter(), validateMmgfMzxmlRoundTrip(), validateRecalculation(), validateWriteRead(), verifyBombesinFeatures(), verifyBombesinPeakels(), verifyPrecursorInfo(), verifyPrecursorMZ(), verifyScanInfo(), MyWrapper::verifySize(), and verifySpectrumSize().

§ unit_assert_to_stream

#define unit_assert_to_stream (   x,
  os 
)    ((os) << (!(x) ? unit_assert_message(__FILE__, __LINE__, #x) + "\n" : ""))

Definition at line 88 of file unit.hpp.

§ unit_assert_operator_equal

#define unit_assert_operator_equal (   expected,
  actual 
)    (!(expected == actual) ? throw std::runtime_error(unit_assert_equal_message(__FILE__, __LINE__, lexical_cast<string>(expected), lexical_cast<string>(actual), #actual)) : 0)

§ unit_assert_operator_equal_to_stream

#define unit_assert_operator_equal_to_stream (   expected,
  actual,
  os 
)    ((os) << (!(expected == actual) ? unit_assert_equal_message(__FILE__, __LINE__, lexical_cast<string>(expected), lexical_cast<string>(actual), #actual) + "\n" : ""))

Definition at line 95 of file unit.hpp.

§ unit_assert_equal

#define unit_assert_equal (   x,
  y,
  epsilon 
)    (!(fabs((x)-(y)) <= (epsilon)) ? throw std::runtime_error(unit_assert_numeric_equal_message(__FILE__, __LINE__, (x), (y), (epsilon))) : 0)

§ unit_assert_equal_to_stream

#define unit_assert_equal_to_stream (   x,
  y,
  epsilon,
  os 
)    ((os) << (!(fabs((x)-(y)) <= (epsilon)) ? unit_assert_numeric_equal_message(__FILE__, __LINE__, (x), (y), (epsilon)) + "\n" : ""))

Definition at line 102 of file unit.hpp.

Referenced by test().

§ unit_assert_throws

#define unit_assert_throws (   x,
  exception 
)
Value:
{ \
bool threw = false; \
try { (x); } \
catch (exception&) \
{ \
threw = true; \
} \
if (!threw) \
throw std::runtime_error(unit_assert_exception_message(__FILE__, __LINE__, #x, #exception)); \
}
std::string unit_assert_exception_message(const char *filename, int line, const char *expression, const std::string &exception)
Definition: unit.hpp:75
KernelTraitsBase< Kernel >::space_type::abscissa_type x

Definition at line 106 of file unit.hpp.

Referenced by test(), testCleavageAgents(), testFind(), testRootElement(), testWrapActivation(), testWrapMassAnalyzer(), and testWrapPolarity().

§ unit_assert_throws_what

#define unit_assert_throws_what (   x,
  exception,
  whatStr 
)
Value:
{ \
bool threw = false; \
try { (x); } \
catch (exception& e) \
{ \
if (e.what() == std::string(whatStr)) \
threw = true; \
else \
throw std::runtime_error(unit_assert_exception_message(__FILE__, __LINE__, #x, std::string(#exception)+" "+quote_string(whatStr)+"\nBut a different exception was thrown: ")+quote_string(e.what())); \
} \
if (!threw) \
throw std::runtime_error(unit_assert_exception_message(__FILE__, __LINE__, #x, std::string(#exception)+" "+quote_string(whatStr))); \
}
std::string quote_string(const string &str)
Definition: unit.hpp:82
std::string unit_assert_exception_message(const char *filename, int line, const char *expression, const std::string &exception)
Definition: unit.hpp:75
KernelTraitsBase< Kernel >::space_type::abscissa_type x

Definition at line 119 of file unit.hpp.

Referenced by modificationTest(), test(), testDuplicateId(), and testInfo().

§ unit_assert_matrices_equal

#define unit_assert_matrices_equal (   A,
  B,
  epsilon 
)    unit_assert(boost::numeric::ublas::norm_frobenius((A)-(B)) < (epsilon))

§ unit_assert_vectors_equal

#define unit_assert_vectors_equal (   A,
  B,
  epsilon 
)    unit_assert(boost::numeric::ublas::norm_2((A)-(B)) < (epsilon))

Definition at line 139 of file unit.hpp.

Referenced by test().

§ TEST_PROLOG_EX

#define TEST_PROLOG_EX (   argc,
  argv,
  suffix 
)
Value:
bnw::args args(argc, argv); \
std::locale global_loc = std::locale(); \
std::locale loc(global_loc, new boost::filesystem::detail::utf8_codecvt_facet); \
bfs::path::imbue(loc); \
bfs::path testName = bfs::change_extension(bfs::basename(argv[0]), (suffix)); \
string teamcityTestName = pwiz::util::escape_teamcity_string(testName.string()); \
bpt::ptime testStartTime; \
vector<string> testArgs(argv, argv+argc); \
bool teamcityTestDecoration = find(testArgs.begin(), testArgs.end(), "--teamcity-test-decoration") != testArgs.end(); \
if (teamcityTestDecoration) \
{ \
testStartTime = bpt::microsec_clock::local_time(); \
cout << "##teamcity[testStarted name='" << teamcityTestName << "']" << endl; \
} \
int testExitStatus = 0;
std::string escape_teamcity_string(const std::string &str)
Definition: unit.hpp:145

Definition at line 157 of file unit.hpp.

Referenced by main().

§ TEST_PROLOG

#define TEST_PROLOG (   argc,
  argv 
)    TEST_PROLOG_EX(argc, argv, "")

Definition at line 174 of file unit.hpp.

Referenced by main().

§ TEST_FAILED

#define TEST_FAILED (   x)
Value:
if (teamcityTestDecoration) \
cout << "##teamcity[testFailed name='" << teamcityTestName << "' message='" << pwiz::util::escape_teamcity_string((x)) << "']\n"; \
cerr << (x) << endl; \
testExitStatus = 1;
std::string escape_teamcity_string(const std::string &str)
Definition: unit.hpp:145
KernelTraitsBase< Kernel >::space_type::abscissa_type x

Definition at line 176 of file unit.hpp.

Referenced by main().

§ TEST_EPILOG

#define TEST_EPILOG
Value:
if (teamcityTestDecoration) \
cout << "##teamcity[testFinished name='" << teamcityTestName << \
"' duration='" << round((bpt::microsec_clock::local_time() - testStartTime).total_microseconds() / 1000.0) << "']" << endl; \
return testExitStatus;

Definition at line 182 of file unit.hpp.

Referenced by main().