mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 03:02:24 +01:00
Add tests for single include
This commit is contained in:
parent
434f8c9b9f
commit
0c71bc3eab
768
scripts/sivalidateVSTests.py
Normal file
768
scripts/sivalidateVSTests.py
Normal file
@ -0,0 +1,768 @@
|
|||||||
|
#!/c/Python27/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
import xml.etree.cElementTree as etree
|
||||||
|
|
||||||
|
from scriptCommon import catchPath
|
||||||
|
from catch_test_run import TestRunApprovedHandler
|
||||||
|
from catch_test_run import TestRunData
|
||||||
|
from catch_test_run import TestRunResultHandler
|
||||||
|
from catch_test_case import TestCaseResultParser
|
||||||
|
from catch_test_case import TestCaseData
|
||||||
|
from catch_conditions import RandomOutput
|
||||||
|
|
||||||
|
rootPath = os.path.join(os.path.join(os.path.join( catchPath, 'single_include_projects'), 'SelfTest'), 'Baselines' )
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
cmdPath = sys.argv[1]
|
||||||
|
else:
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
cmdPath = os.path.join( catchPath, 'single_include_projects\\VS2010\\TestCatch\\Release\\TestCatch.exe' )
|
||||||
|
# VS2010
|
||||||
|
dllPath = os.path.join( catchPath, 'single_include_projects\\VS2010\\ManagedTestCatch\\Release\\ManagedTestCatch.dll' )
|
||||||
|
#dllPath = os.path.join( catchPath, 'single_include_projects\\VS2010\\ManagedTestCatch\\Debug\\ManagedTestCatch.dll' )
|
||||||
|
# VS2012 managed
|
||||||
|
#dllPath = os.path.join( catchPath, 'single_include_projects\\VS2012\\ManagedTestCatch\\Debug\\ManagedTestCatch.dll' )
|
||||||
|
# VS2012 native
|
||||||
|
#dllPath = os.path.join( catchPath, 'single_include_projects\\VS2012\\NativeTestCatch\\Debug\\NativeTestCatch.dll' )
|
||||||
|
else:
|
||||||
|
cmdPath = os.path.join( catchPath, 'single_include_projects/XCode4/CatchSelfTest/DerivedData/CatchSelfTest/Build/Products/Debug/CatchSelfTest' )
|
||||||
|
|
||||||
|
print cmdPath
|
||||||
|
|
||||||
|
overallResult = 0
|
||||||
|
|
||||||
|
def approve( baseName, args ):
|
||||||
|
global overallResult
|
||||||
|
args[0:0] = [cmdPath]
|
||||||
|
baselinesPath = os.path.join( rootPath, '{0}.approved.txt'.format( baseName ) )
|
||||||
|
baselinesSortedPath = os.path.join( rootPath, '{0}.sorted.approved.txt'.format( baseName ) )
|
||||||
|
rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) )
|
||||||
|
if os.path.exists( baselinesPath ):
|
||||||
|
approvedFileHandler = TestRunApprovedHandler(baselinesPath)
|
||||||
|
#baselinesPathNew = os.path.join( rootPath, '{0}.approved.new.txt'.format( baseName ) )
|
||||||
|
#approvedFileHandler.writeRawFile(baselinesPathNew)
|
||||||
|
approvedFileHandler.writeSortedRawFile(baselinesSortedPath)
|
||||||
|
else:
|
||||||
|
raise Exception("Base file does not exist: '" + baselinesPath + "'")
|
||||||
|
|
||||||
|
if not(os.path.exists( args[0] )):
|
||||||
|
raise Exception("Executable does not exist: '" + args[0] + "'")
|
||||||
|
|
||||||
|
f = open( rawResultsPath, 'w' )
|
||||||
|
subprocess.call( args, stdout=f, stderr=f )
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if os.path.exists( rawResultsPath ):
|
||||||
|
resultFileHandler = TestRunResultHandler(rawResultsPath)
|
||||||
|
#rawPathNew = os.path.join( rootPath, '{0}.rewrite.txt'.format( baseName ) )
|
||||||
|
#print "F:",rawPathNew,",",approvedFileHandler.current.outputLine
|
||||||
|
#resultFileHandler.writeRawFile(rawPathNew)
|
||||||
|
rawPathNewSorted = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) )
|
||||||
|
resultFileHandler.writeSortedUnapprovedFile(rawPathNewSorted, approvedFileHandler.current.outputLine)
|
||||||
|
os.remove( rawResultsPath )
|
||||||
|
else:
|
||||||
|
raise Exception("Results file does not exist: '" + rawResultsPath + "'")
|
||||||
|
|
||||||
|
def callDiff():
|
||||||
|
#os.remove( rawResultsPath )
|
||||||
|
print
|
||||||
|
print baseName + ":"
|
||||||
|
if os.path.exists( baselinesSortedPath ) and os.path.exists( rawPathNewSorted ):
|
||||||
|
diffResult = subprocess.call([ "diff", "--ignore-all-space", baselinesSortedPath, rawPathNewSorted ] )
|
||||||
|
if diffResult == 0:
|
||||||
|
#os.remove( filteredResultsPath )
|
||||||
|
if not(sys.platform == 'win32'):
|
||||||
|
print " \033[92mResults matched"
|
||||||
|
else:
|
||||||
|
print " Results matched"
|
||||||
|
else:
|
||||||
|
if not(sys.platform == 'win32'):
|
||||||
|
print " \n****************************\n \033[91mResults differed"
|
||||||
|
else:
|
||||||
|
print " \n****************************\n Results differed"
|
||||||
|
if diffResult > overallResult:
|
||||||
|
overallResult = diffResult
|
||||||
|
if not(sys.platform == 'win32'):
|
||||||
|
print "\033[0m"
|
||||||
|
|
||||||
|
def approveJunit( baseName, args ):
|
||||||
|
global overallResult
|
||||||
|
args[0:0] = [cmdPath]
|
||||||
|
baselinesPath = os.path.join( rootPath, '{0}.approved.txt'.format( baseName ) )
|
||||||
|
baselinesSortedPath = os.path.join( rootPath, '{0}.sorted.approved.txt'.format( baseName ) )
|
||||||
|
#baselinesFixedPath = os.path.join( rootPath, '{0}.rewrite.approved.txt'.format( baseName ) )
|
||||||
|
rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) )
|
||||||
|
if os.path.exists( baselinesPath ):
|
||||||
|
xml = ""
|
||||||
|
f = open( baselinesPath, 'r' )
|
||||||
|
for line in f:
|
||||||
|
xml += line
|
||||||
|
xml = xml.replace("<line number>", "<line number>")
|
||||||
|
xml = xml.replace("<hex digits>", "<hex digits>")
|
||||||
|
#f2 = open( baselinesFixedPath, 'wb' )
|
||||||
|
#f2.write(xml)
|
||||||
|
#f2.close()
|
||||||
|
|
||||||
|
# ClassTests.cpp:<line number>
|
||||||
|
otherApprovedTestParser = re.compile( r'(.*\..pp).*:<(.*).*>' )
|
||||||
|
testRun = TestRunData()
|
||||||
|
testcase = None
|
||||||
|
root = etree.fromstring(xml)
|
||||||
|
for testsuites in root:
|
||||||
|
if testsuites.tag == "testsuite":
|
||||||
|
testRun = TestRunData()
|
||||||
|
testRun.appname = testsuites.get("name")
|
||||||
|
testRun.errors = testsuites.get("errors")
|
||||||
|
testRun.failures = testsuites.get("failures")
|
||||||
|
testRun.tests = testsuites.get("tests")
|
||||||
|
for tc in testsuites:
|
||||||
|
if tc.tag == "testcase":
|
||||||
|
cls = tc.get("classname")
|
||||||
|
#print "C:",cls,tc
|
||||||
|
if len(cls):
|
||||||
|
testcase = testRun.addClassTestCase(cls, tc.get("name"))
|
||||||
|
else:
|
||||||
|
testcase = testRun.addTestCase(tc.get("name"))
|
||||||
|
for prop in tc:
|
||||||
|
if prop.tag == "failure":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
filename = ""
|
||||||
|
lineNumber = ""
|
||||||
|
output = []
|
||||||
|
for l in lines:
|
||||||
|
m = otherApprovedTestParser.match(l)
|
||||||
|
if m:
|
||||||
|
filename = m.group(1)
|
||||||
|
lineNumber = m.group(2)
|
||||||
|
else:
|
||||||
|
output.append(l)
|
||||||
|
testcase.addFailure(filename, lineNumber, output, prop.get("message"), prop.get("type"))
|
||||||
|
elif prop.tag == "error":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
filename = ""
|
||||||
|
lineNumber = ""
|
||||||
|
output = []
|
||||||
|
for l in lines:
|
||||||
|
m = otherApprovedTestParser.match(l)
|
||||||
|
if m:
|
||||||
|
filename = m.group(1)
|
||||||
|
lineNumber = m.group(2)
|
||||||
|
else:
|
||||||
|
output.append(l)
|
||||||
|
testcase.addError(filename, lineNumber, output, prop.get("message"), prop.get("type"))
|
||||||
|
elif prop.tag == "system-out":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testcase.addSysout(lines)
|
||||||
|
elif prop.tag == "system-err":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testcase.addSyserr(lines)
|
||||||
|
elif tc.tag == "system-out":
|
||||||
|
text = tc.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testRun.addSysout(lines)
|
||||||
|
elif tc.tag == "system-err":
|
||||||
|
text = tc.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testRun.addSyserr(lines)
|
||||||
|
else:
|
||||||
|
print tc.tag
|
||||||
|
|
||||||
|
lines = testRun.generateSortedUnapprovedJunit()
|
||||||
|
|
||||||
|
rawWriteFile = open( baselinesSortedPath, 'wb' )
|
||||||
|
for line in lines:
|
||||||
|
#print "L:",line
|
||||||
|
rawWriteFile.write(line + "\n")
|
||||||
|
rawWriteFile.close()
|
||||||
|
|
||||||
|
if not(os.path.exists( args[0] )):
|
||||||
|
raise Exception("Executable does not exist: '" + args[0] + "'")
|
||||||
|
|
||||||
|
f = open( rawResultsPath, 'w' )
|
||||||
|
subprocess.call( args, stdout=f, stderr=f )
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
rawSortedPath = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) )
|
||||||
|
if os.path.exists( rawResultsPath ):
|
||||||
|
xml = ""
|
||||||
|
f = open( rawResultsPath, 'r' )
|
||||||
|
for line in f:
|
||||||
|
xml += line
|
||||||
|
#xml = xml.replace("<line number>", "<line number>")
|
||||||
|
#xml = xml.replace("<hex digits>", "<hex digits>")
|
||||||
|
|
||||||
|
# ClassTests.cpp:<line number>
|
||||||
|
otherResultsTestParser = re.compile( r'(.*\\)(.*\..pp).*\((.*).*\)' )
|
||||||
|
testRun = TestRunData()
|
||||||
|
testcase = None
|
||||||
|
root = etree.fromstring(xml)
|
||||||
|
for testsuites in root:
|
||||||
|
if testsuites.tag == "testsuite":
|
||||||
|
testRun = TestRunData()
|
||||||
|
testRun.appname = testsuites.get("name")
|
||||||
|
testRun.errors = testsuites.get("errors")
|
||||||
|
testRun.failures = testsuites.get("failures")
|
||||||
|
testRun.tests = testsuites.get("tests")
|
||||||
|
for tc in testsuites:
|
||||||
|
if tc.tag == "testcase":
|
||||||
|
cls = tc.get("classname")
|
||||||
|
#print "C:",cls,tc
|
||||||
|
if len(cls):
|
||||||
|
if cls.startswith("::"):
|
||||||
|
cls = cls[2:]
|
||||||
|
testcase = testRun.addClassTestCase(cls, tc.get("name"))
|
||||||
|
else:
|
||||||
|
testcase = testRun.addTestCase(tc.get("name"))
|
||||||
|
for prop in tc:
|
||||||
|
if prop.tag == "failure":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
filename = ""
|
||||||
|
lineNumber = ""
|
||||||
|
output = []
|
||||||
|
for l in lines:
|
||||||
|
m = otherResultsTestParser.match(l)
|
||||||
|
if m:
|
||||||
|
filename = m.group(2)
|
||||||
|
lineNumber = "line number"
|
||||||
|
else:
|
||||||
|
output.append(l)
|
||||||
|
testcase.addFailure(filename, lineNumber, output, prop.get("message"), prop.get("type"))
|
||||||
|
elif prop.tag == "error":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
filename = ""
|
||||||
|
lineNumber = ""
|
||||||
|
output = []
|
||||||
|
for l in lines:
|
||||||
|
m = otherResultsTestParser.match(l)
|
||||||
|
if m:
|
||||||
|
filename = m.group(2)
|
||||||
|
lineNumber = "line number"
|
||||||
|
else:
|
||||||
|
output.append(l)
|
||||||
|
testcase.addError(filename, lineNumber, output, prop.get("message"), prop.get("type"))
|
||||||
|
elif prop.tag == "system-out":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testcase.addSysout(lines)
|
||||||
|
elif prop.tag == "system-err":
|
||||||
|
text = prop.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testcase.addSyserr(lines)
|
||||||
|
elif tc.tag == "system-out":
|
||||||
|
text = tc.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testRun.addSysout(lines)
|
||||||
|
elif tc.tag == "system-err":
|
||||||
|
text = tc.text.strip()
|
||||||
|
lines = text.splitlines()
|
||||||
|
testRun.addSyserr(lines)
|
||||||
|
else:
|
||||||
|
print tc.tag
|
||||||
|
|
||||||
|
lines = testRun.generateSortedUnapprovedJunit()
|
||||||
|
|
||||||
|
rawWriteFile = open( rawSortedPath, 'wb' )
|
||||||
|
for line in lines:
|
||||||
|
#print "L:",line
|
||||||
|
rawWriteFile.write(line + "\n")
|
||||||
|
rawWriteFile.close()
|
||||||
|
|
||||||
|
def addSubSection(testcase, section, exp):
|
||||||
|
r = exp.find("OverallResults")
|
||||||
|
if r != None:
|
||||||
|
ores = []
|
||||||
|
ores.append(r.get("successes"))
|
||||||
|
ores.append(r.get("failures"))
|
||||||
|
if section == None:
|
||||||
|
section = testcase.addSection(exp.get("name"), exp.get("description"), ores)
|
||||||
|
else:
|
||||||
|
section = testcase.addSubSection(section, exp.get("name"), exp.get("description"), ores)
|
||||||
|
e1 = False
|
||||||
|
for tmp in exp:
|
||||||
|
if tmp.tag == "OverallResults":
|
||||||
|
pass
|
||||||
|
elif tmp.tag == "Exception":
|
||||||
|
filename = tmp.get("filename")
|
||||||
|
text = tmp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
testcase.addSubException(section, filename, ls)
|
||||||
|
elif tmp.tag == "Section":
|
||||||
|
addSubSection(testcase, section, tmp)
|
||||||
|
elif tmp.tag == "Failure":
|
||||||
|
text = tmp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
testcase.addSubFailure(section, ls)
|
||||||
|
elif tmp.tag == "Expression":
|
||||||
|
#print "Exp:",tmp
|
||||||
|
e1 = True
|
||||||
|
result = tmp.get("success")
|
||||||
|
filename = tmp.get("filename")
|
||||||
|
subSection = testcase.addSubExpression(section,result,filename)
|
||||||
|
subExp = []
|
||||||
|
for cond in tmp:
|
||||||
|
if cond.tag == "Original":
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Expanded" and len(subExp) == 1:
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Exception" and len(subExp) == 2:
|
||||||
|
subExp.append(cond.get("filename"))
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
else:
|
||||||
|
print "SX:",cond.tag
|
||||||
|
if len(subExp) >= 2:
|
||||||
|
testcase.addExpressionDetails(subSection, subExp)
|
||||||
|
else:
|
||||||
|
print "Z:",tmp.tag
|
||||||
|
#if e1:
|
||||||
|
# print "Section:",section
|
||||||
|
|
||||||
|
def addResultsSubSection(otherResultsTestParser, testcase, section, exp):
|
||||||
|
r = exp.find("OverallResults")
|
||||||
|
if r != None:
|
||||||
|
ores = []
|
||||||
|
ores.append(r.get("successes"))
|
||||||
|
ores.append(r.get("failures"))
|
||||||
|
if section == None:
|
||||||
|
section = testcase.addSection(exp.get("name"), exp.get("description"), ores)
|
||||||
|
else:
|
||||||
|
section = testcase.addSubSection(section, exp.get("name"), exp.get("description"), ores)
|
||||||
|
e1 = False
|
||||||
|
for tmp in exp:
|
||||||
|
if tmp.tag == "OverallResults":
|
||||||
|
pass
|
||||||
|
elif tmp.tag == "Exception":
|
||||||
|
filename = tmp.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
text = tmp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
testcase.addSubException(section, filename, ls)
|
||||||
|
elif tmp.tag == "Section":
|
||||||
|
addResultsSubSection(otherResultsTestParser, testcase, section, tmp)
|
||||||
|
elif tmp.tag == "Failure":
|
||||||
|
text = tmp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
testcase.addSubFailure(section, ls)
|
||||||
|
elif tmp.tag == "Expression":
|
||||||
|
#print "Exp:",tmp
|
||||||
|
e1 = True
|
||||||
|
result = tmp.get("success")
|
||||||
|
filename = tmp.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
subSection = testcase.addSubExpression(section,result,filename)
|
||||||
|
subExp = []
|
||||||
|
for cond in tmp:
|
||||||
|
if cond.tag == "Original":
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Expanded" and len(subExp) == 1:
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Exception" and len(subExp) == 2:
|
||||||
|
filename = cond.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
subExp.append(filename)
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
else:
|
||||||
|
print "SX:",cond.tag
|
||||||
|
if len(subExp) >= 2:
|
||||||
|
testcase.addExpressionDetails(subSection, subExp)
|
||||||
|
else:
|
||||||
|
print "Z:",tmp.tag
|
||||||
|
#if e1:
|
||||||
|
# print "Section:",section
|
||||||
|
|
||||||
|
def approveXml( baseName, args ):
|
||||||
|
global overallResult
|
||||||
|
args[0:0] = [cmdPath]
|
||||||
|
baselinesPath = os.path.join( rootPath, '{0}.approved.txt'.format( baseName ) )
|
||||||
|
baselinesSortedPath = os.path.join( rootPath, '{0}.sorted.approved.txt'.format( baseName ) )
|
||||||
|
#baselinesFixedPath = os.path.join( rootPath, '{0}.rewrite.approved.txt'.format( baseName ) )
|
||||||
|
rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) )
|
||||||
|
if os.path.exists( baselinesPath ):
|
||||||
|
xml = ""
|
||||||
|
f = open( baselinesPath, 'r' )
|
||||||
|
for line in f:
|
||||||
|
xml += line
|
||||||
|
xml = xml.replace("<hex digits>", "<hex digits>")
|
||||||
|
|
||||||
|
#otherApprovedTestParser = re.compile( r'(.*\..pp).*:<(.*).*>' )
|
||||||
|
testRun = TestRunData()
|
||||||
|
testcase = None
|
||||||
|
root = etree.fromstring(xml)
|
||||||
|
testRun.appname = root.get("name")
|
||||||
|
for ts in root:
|
||||||
|
#print ts.tag
|
||||||
|
for tc in ts:
|
||||||
|
if tc.tag == "TestCase":
|
||||||
|
testcase = testRun.addTestCase(tc.get("name"))
|
||||||
|
for exp in tc:
|
||||||
|
if exp.tag == "Expression":
|
||||||
|
result = exp.get("success")
|
||||||
|
filename = exp.get("filename")
|
||||||
|
section = testcase.addExpression(result,filename)
|
||||||
|
subExp = []
|
||||||
|
for cond in exp:
|
||||||
|
if cond.tag == "Original":
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Expanded" and len(subExp) == 1:
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Exception" and len(subExp) == 2:
|
||||||
|
subExp.append(cond.get("filename"))
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
else:
|
||||||
|
print "X:",cond.tag
|
||||||
|
if len(subExp) >= 2:
|
||||||
|
testcase.addExpressionDetails(section, subExp)
|
||||||
|
elif exp.tag == "Exception":
|
||||||
|
filename = exp.get("filename")
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addException(filename,ls)
|
||||||
|
elif exp.tag == "Section":
|
||||||
|
addSubSection(testcase, None, exp)
|
||||||
|
elif exp.tag == "Info":
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addInfo(ls)
|
||||||
|
elif exp.tag == "Warning":
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addWarning(ls)
|
||||||
|
elif exp.tag == "Failure":
|
||||||
|
ls = []
|
||||||
|
if exp.text != None:
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addSimpleFailure(ls)
|
||||||
|
elif exp.tag == "OverallResult":
|
||||||
|
testcase.addOverallResult(exp.get("success"))
|
||||||
|
else:
|
||||||
|
print "E:",exp.tag
|
||||||
|
elif tc.tag == "OverallResults":
|
||||||
|
testRun.tests = tc.get("successes")
|
||||||
|
testRun.failures = tc.get("failures")
|
||||||
|
else:
|
||||||
|
print "U:",tc.tag
|
||||||
|
|
||||||
|
lines = testRun.generateSortedUnapprovedXml()
|
||||||
|
|
||||||
|
rawWriteFile = open( baselinesSortedPath, 'wb' )
|
||||||
|
for line in lines:
|
||||||
|
#print "L:",line
|
||||||
|
rawWriteFile.write(line + "\n")
|
||||||
|
rawWriteFile.close()
|
||||||
|
|
||||||
|
if not(os.path.exists( args[0] )):
|
||||||
|
raise Exception("Executable does not exist: '" + args[0] + "'")
|
||||||
|
|
||||||
|
f = open( rawResultsPath, 'w' )
|
||||||
|
subprocess.call( args, stdout=f, stderr=f )
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
rawSortedPath = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) )
|
||||||
|
if os.path.exists( rawResultsPath ):
|
||||||
|
xml = ""
|
||||||
|
f = open( rawResultsPath, 'r' )
|
||||||
|
for line in f:
|
||||||
|
xml += line
|
||||||
|
f.close()
|
||||||
|
#xml = xml.replace("<hex digits>", "<hex digits>")
|
||||||
|
os.remove( rawResultsPath )
|
||||||
|
|
||||||
|
otherResultsTestParser = re.compile( r'(.*\\)(.*\..pp)' )
|
||||||
|
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
|
||||||
|
testRun = TestRunData()
|
||||||
|
testcase = None
|
||||||
|
root = etree.fromstring(xml)
|
||||||
|
testRun.appname = root.get("name")
|
||||||
|
if testRun.appname == "TestCatch.exe":
|
||||||
|
testRun.appname = "CatchSelfTest"
|
||||||
|
for ts in root:
|
||||||
|
#print ts.tag
|
||||||
|
for tc in ts:
|
||||||
|
if tc.tag == "TestCase":
|
||||||
|
testcase = testRun.addTestCase(tc.get("name"))
|
||||||
|
for exp in tc:
|
||||||
|
if exp.tag == "Expression":
|
||||||
|
result = exp.get("success")
|
||||||
|
filename = exp.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
section = testcase.addExpression(result,filename)
|
||||||
|
subExp = []
|
||||||
|
for cond in exp:
|
||||||
|
if cond.tag == "Original":
|
||||||
|
text = cond.text
|
||||||
|
tmp = text.splitlines()
|
||||||
|
ls = []
|
||||||
|
for li in tmp:
|
||||||
|
m = hexParser.match(li)
|
||||||
|
if m:
|
||||||
|
while m:
|
||||||
|
#print li, m.group(1), m.group(3)
|
||||||
|
li = m.group(1) + "0x<hex digits>" + m.group(3)
|
||||||
|
m = hexParser.match(li)
|
||||||
|
ls.append(li)
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Expanded" and len(subExp) == 1:
|
||||||
|
text = cond.text
|
||||||
|
tmp = text.splitlines()
|
||||||
|
ls = []
|
||||||
|
for li in tmp:
|
||||||
|
m = hexParser.match(li)
|
||||||
|
if m:
|
||||||
|
while m:
|
||||||
|
#print li, m.group(1), m.group(3)
|
||||||
|
li = m.group(1) + "0x<hex digits>" + m.group(3)
|
||||||
|
m = hexParser.match(li)
|
||||||
|
ls.append(li)
|
||||||
|
subExp.append(ls)
|
||||||
|
elif cond.tag == "Exception" and len(subExp) == 2:
|
||||||
|
filename = cond.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
subExp.append(filename)
|
||||||
|
text = cond.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
subExp.append(ls)
|
||||||
|
else:
|
||||||
|
print "X:",cond.tag
|
||||||
|
if len(subExp) >= 2:
|
||||||
|
testcase.addExpressionDetails(section, subExp)
|
||||||
|
elif exp.tag == "Exception":
|
||||||
|
filename = exp.get("filename")
|
||||||
|
m = otherResultsTestParser.match(filename)
|
||||||
|
if m:
|
||||||
|
filename = "/Users/philnash/Dev/OSS/Catch/projects/SelfTest/" + m.group(2)
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addException(filename,ls)
|
||||||
|
elif exp.tag == "Section":
|
||||||
|
addResultsSubSection(otherResultsTestParser, testcase, None, exp)
|
||||||
|
elif exp.tag == "Info":
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addInfo(ls)
|
||||||
|
elif exp.tag == "Warning":
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addWarning(ls)
|
||||||
|
elif exp.tag == "Failure":
|
||||||
|
ls = []
|
||||||
|
if exp.text != None:
|
||||||
|
text = exp.text
|
||||||
|
ls = text.splitlines()
|
||||||
|
section = testcase.addSimpleFailure(ls)
|
||||||
|
elif exp.tag == "OverallResult":
|
||||||
|
testcase.addOverallResult(exp.get("success"))
|
||||||
|
else:
|
||||||
|
print "E:",exp.tag
|
||||||
|
elif tc.tag == "OverallResults":
|
||||||
|
testRun.tests = tc.get("successes")
|
||||||
|
testRun.failures = tc.get("failures")
|
||||||
|
else:
|
||||||
|
print "U:",tc.tag
|
||||||
|
|
||||||
|
lines = testRun.generateSortedUnapprovedXml()
|
||||||
|
|
||||||
|
rawWriteFile = open( rawSortedPath, 'wb' )
|
||||||
|
for line in lines:
|
||||||
|
#print "L:",line
|
||||||
|
rawWriteFile.write(line + "\n")
|
||||||
|
rawWriteFile.close()
|
||||||
|
|
||||||
|
def parseTrxFile(baseName, trxFile):
|
||||||
|
print "TRX file:" ,trxFile
|
||||||
|
if os.path.exists( trxFile ):
|
||||||
|
xml = ""
|
||||||
|
f = open( trxFile, 'r' )
|
||||||
|
for line in f:
|
||||||
|
xml += line
|
||||||
|
|
||||||
|
#otherResultsTestParser = re.compile( r'(.*\\)(.*\..pp)' )
|
||||||
|
#hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
|
||||||
|
testRun = TestRunData()
|
||||||
|
testRun.appname = "CatchSelfTest"
|
||||||
|
root = etree.fromstring(xml)
|
||||||
|
if testRun.appname == "TestCatch.exe":
|
||||||
|
testRun.appname = "CatchSelfTest"
|
||||||
|
qname=re.compile("{(?P<ns>.*)}(?P<element>.*)")
|
||||||
|
ids = []
|
||||||
|
for ts in root:
|
||||||
|
m = qname.match(ts.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
print tag
|
||||||
|
if tag != None:
|
||||||
|
if tag == "TestDefinitions":
|
||||||
|
for tc in ts:
|
||||||
|
m = qname.match(tc.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
if tag != None and tag == "UnitTest":
|
||||||
|
name = tc.get("name")
|
||||||
|
id = tc.get("id")
|
||||||
|
for item in tc:
|
||||||
|
m = qname.match(item.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
if tag != None and tag == "Description":
|
||||||
|
desc = item.text
|
||||||
|
#print desc, id
|
||||||
|
ids.append([id,desc])
|
||||||
|
elif tag == "Results":
|
||||||
|
#print ids
|
||||||
|
ids = dict(ids)
|
||||||
|
#print ids["87ec526a-e414-1a3f-ba0f-e210b204bb42"]
|
||||||
|
|
||||||
|
lineNumber = 0
|
||||||
|
resultParser = TestCaseResultParser()
|
||||||
|
for tc in ts:
|
||||||
|
m = qname.match(tc.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
if tag != None and tag == "UnitTestResult":
|
||||||
|
outcome = tc.get("outcome")
|
||||||
|
id = tc.get("testId")
|
||||||
|
if len(id) > 0:
|
||||||
|
for item in tc:
|
||||||
|
m = qname.match(item.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
if tag != None and tag == "Output":
|
||||||
|
for sub in item:
|
||||||
|
m = qname.match(sub.tag)
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
if tag != None and tag == "StdOut":
|
||||||
|
desc = sub.text
|
||||||
|
lines = desc.splitlines()
|
||||||
|
found = False
|
||||||
|
index = 0
|
||||||
|
for tmp in lines:
|
||||||
|
if (len(lines) >= (index + 2) and
|
||||||
|
lines[index].startswith("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") and
|
||||||
|
lines[index + 1].startswith("Batch run using") ):
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
index += 1
|
||||||
|
lines = lines[index + 3:]
|
||||||
|
#print "*******",desc
|
||||||
|
#print lines
|
||||||
|
if found:
|
||||||
|
endOfRun = False
|
||||||
|
for line in lines:
|
||||||
|
if endOfRun:
|
||||||
|
testRun.results = line.strip()
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
testcase = resultParser.parseResultLine(line)
|
||||||
|
except RandomOutput as e:
|
||||||
|
#print "E:", self.lineNumber, ", ",e.output
|
||||||
|
testRun.output = e.output
|
||||||
|
testRun.outputLine = lineNumber - len(e.output)
|
||||||
|
if isinstance(testcase, TestCaseData):
|
||||||
|
testRun.testcases.append(testcase)
|
||||||
|
if line.startswith("==============================================================================="):
|
||||||
|
endOfRun = True
|
||||||
|
lineNumber += 1
|
||||||
|
lines = testRun.generateSortedUnapprovedLines(testRun.outputLine)
|
||||||
|
|
||||||
|
rawSortedPath = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) )
|
||||||
|
rawWriteFile = open( rawSortedPath, 'wb' )
|
||||||
|
for line in lines:
|
||||||
|
#print "L:",line
|
||||||
|
rawWriteFile.write(line + "\n")
|
||||||
|
rawWriteFile.close()
|
||||||
|
|
||||||
|
|
||||||
|
def approveMsTest( baseName, filter ):
|
||||||
|
rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) )
|
||||||
|
if not(os.path.exists( dllPath )):
|
||||||
|
raise Exception("Managed DLL does not exist: '" + dllPath + "'")
|
||||||
|
|
||||||
|
args = []
|
||||||
|
# Options for VS2010
|
||||||
|
args.append("MSTest.exe")
|
||||||
|
args.append("/testcontainer:" + dllPath)
|
||||||
|
args.append("/category:\"" + filter + "\"")
|
||||||
|
|
||||||
|
# Options for VS2012 managed
|
||||||
|
#args.append("vstest.console.exe")
|
||||||
|
#args.append("/Logger:Trx")
|
||||||
|
#args.append(dllPath)
|
||||||
|
#args.append("/TestCaseFilter:TestCategory=" + filter)
|
||||||
|
|
||||||
|
# Options for VS2012 native
|
||||||
|
#args.append("vstest.console.exe")
|
||||||
|
#args.append("/Logger:Trx")
|
||||||
|
#args.append(dllPath)
|
||||||
|
#args.append("/TestCaseFilter:Owner=" + filter)
|
||||||
|
|
||||||
|
#print args
|
||||||
|
f = open( rawResultsPath, 'w' )
|
||||||
|
subprocess.call( args, stdout=f, stderr=f )
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if os.path.exists( rawResultsPath ):
|
||||||
|
f = open( rawResultsPath, 'r' )
|
||||||
|
for line in f:
|
||||||
|
if line.startswith("Results file:") or line.startswith("Results File:"):
|
||||||
|
trxFile = line[13:].strip()
|
||||||
|
parseTrxFile(baseName, trxFile)
|
||||||
|
f.close()
|
||||||
|
os.remove( rawResultsPath )
|
||||||
|
|
||||||
|
# Standard console reporter
|
||||||
|
approve( "console.std", ["~_"] )
|
||||||
|
# console reporter, include passes, warn about No Assertions
|
||||||
|
approve( "console.sw", ["~_", "-s", "-w", "NoAssertions"] )
|
||||||
|
# console reporter, include passes, warn about No Assertions, limit failures to first 4
|
||||||
|
approve( "console.swa4", ["~_", "-s", "-w", "NoAssertions", "-x", "4"] )
|
||||||
|
# junit reporter, include passes, warn about No Assertions
|
||||||
|
approveJunit( "junit.sw", ["~_", "-s", "-w", "NoAssertions", "-r", "junit"] )
|
||||||
|
# xml reporter, include passes, warn about No Assertions
|
||||||
|
approveXml( "xml.sw", ["~_", "-s", "-w", "NoAssertions", "-r", "xml"] )
|
||||||
|
# mstest runner, xml output
|
||||||
|
approveMsTest( "mstest.std", "all")
|
||||||
|
approveMsTest( "mstest.sw", "allSucceeding")
|
||||||
|
approveMsTest( "mstest.swa4", "allSucceedingAborting")
|
||||||
|
|
||||||
|
if overallResult <> 0:
|
||||||
|
print "run approve.py to approve new baselines"
|
||||||
|
exit( overallResult)
|
39
single_include_projects/CMake/CMakeLists.txt
Normal file
39
single_include_projects/CMake/CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(Catch)
|
||||||
|
|
||||||
|
# define some folders
|
||||||
|
get_filename_component(CATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
|
||||||
|
get_filename_component(CATCH_DIR "${CATCH_DIR}" PATH)
|
||||||
|
set(SELF_TEST_DIR ${CATCH_DIR}/single_include_projects/SelfTest)
|
||||||
|
|
||||||
|
# define the sources of the self test
|
||||||
|
set(SOURCES
|
||||||
|
${SELF_TEST_DIR}/ApproxTests.cpp
|
||||||
|
${SELF_TEST_DIR}/BDDTests.cpp
|
||||||
|
${SELF_TEST_DIR}/ClassTests.cpp
|
||||||
|
${SELF_TEST_DIR}/CmdLineTests.cpp
|
||||||
|
${SELF_TEST_DIR}/ConditionTests.cpp
|
||||||
|
${SELF_TEST_DIR}/ExceptionTests.cpp
|
||||||
|
${SELF_TEST_DIR}/GeneratorTests.cpp
|
||||||
|
${SELF_TEST_DIR}/MessageTests.cpp
|
||||||
|
${SELF_TEST_DIR}/MiscTests.cpp
|
||||||
|
${SELF_TEST_DIR}/SectionTrackerTests.cpp
|
||||||
|
${SELF_TEST_DIR}/TestMain.cpp
|
||||||
|
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||||
|
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# configure the executable
|
||||||
|
include_directories(${CATCH_DIR}/single_include)
|
||||||
|
add_executable(SelfTest ${SOURCES})
|
||||||
|
|
||||||
|
# configure unit tests via CTest
|
||||||
|
enable_testing()
|
||||||
|
add_test(NAME RunTests COMMAND SelfTest)
|
||||||
|
|
||||||
|
add_test(NAME ListTests COMMAND SelfTest --list-tests)
|
||||||
|
set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases")
|
||||||
|
|
||||||
|
add_test(NAME ListTags COMMAND SelfTest --list-tags)
|
||||||
|
set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")
|
112
single_include_projects/SelfTest/ApproxTests.cpp
Normal file
112
single_include_projects/SelfTest/ApproxTests.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 28/04/2011.
|
||||||
|
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Some simple comparisons between doubles",
|
||||||
|
"[Approx]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
double d = 1.23;
|
||||||
|
|
||||||
|
REQUIRE( d == Approx( 1.23 ) );
|
||||||
|
REQUIRE( d != Approx( 1.22 ) );
|
||||||
|
REQUIRE( d != Approx( 1.24 ) );
|
||||||
|
|
||||||
|
REQUIRE( Approx( d ) == 1.23 );
|
||||||
|
REQUIRE( Approx( d ) != 1.22 );
|
||||||
|
REQUIRE( Approx( d ) != 1.24 );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Approximate comparisons with different epsilons",
|
||||||
|
"[Approx]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
double d = 1.23;
|
||||||
|
|
||||||
|
REQUIRE( d != Approx( 1.231 ) );
|
||||||
|
REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Approximate comparisons with floats",
|
||||||
|
"[Approx]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
REQUIRE( 1.23f == Approx( 1.23f ) );
|
||||||
|
REQUIRE( 0.0f == Approx( 0.0f ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Approximate comparisons with ints",
|
||||||
|
"[Approx]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
REQUIRE( 1 == Approx( 1 ) );
|
||||||
|
REQUIRE( 0 == Approx( 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Approximate comparisons with mixed numeric types",
|
||||||
|
"[Approx]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const double dZero = 0;
|
||||||
|
const double dSmall = 0.00001;
|
||||||
|
const double dMedium = 1.234;
|
||||||
|
|
||||||
|
REQUIRE( 1.0f == Approx( 1 ) );
|
||||||
|
REQUIRE( 0 == Approx( dZero) );
|
||||||
|
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) );
|
||||||
|
REQUIRE( 1.234f == Approx( dMedium ) );
|
||||||
|
REQUIRE( dMedium == Approx( 1.234f ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Use a custom approx",
|
||||||
|
"[Approx][custom]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
double d = 1.23;
|
||||||
|
|
||||||
|
Approx approx = Approx::custom().epsilon( 0.005 );
|
||||||
|
|
||||||
|
REQUIRE( d == approx( 1.23 ) );
|
||||||
|
REQUIRE( d == approx( 1.22 ) );
|
||||||
|
REQUIRE( d == approx( 1.24 ) );
|
||||||
|
REQUIRE( d != approx( 1.25 ) );
|
||||||
|
|
||||||
|
REQUIRE( approx( d ) == 1.23 );
|
||||||
|
REQUIRE( approx( d ) == 1.22 );
|
||||||
|
REQUIRE( approx( d ) == 1.24 );
|
||||||
|
REQUIRE( approx( d ) != 1.25 );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double divide( double a, double b ) {
|
||||||
|
return a/b;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Approximate PI", "[Approx][PI]" )
|
||||||
|
{
|
||||||
|
REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) );
|
||||||
|
REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) );
|
||||||
|
}
|
68
single_include_projects/SelfTest/BDDTests.cpp
Normal file
68
single_include_projects/SelfTest/BDDTests.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 29/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
inline bool itDoesThis(){ return true; }
|
||||||
|
inline bool itDoesThat(){ return true; }
|
||||||
|
|
||||||
|
SCENARIO( "Do that thing with the thing", "[Tags]" ) {
|
||||||
|
GIVEN( "This stuff exists" ) {
|
||||||
|
// make stuff exist
|
||||||
|
WHEN( "I do this" ) {
|
||||||
|
// do this
|
||||||
|
THEN( "it should do this")
|
||||||
|
{
|
||||||
|
REQUIRE( itDoesThis() );
|
||||||
|
AND_THEN( "do that")
|
||||||
|
REQUIRE( itDoesThat() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCENARIO( "Vector resizing affects size and capacity", "[vector][bdd][size][capacity]" ) {
|
||||||
|
GIVEN( "an empty vector" ) {
|
||||||
|
std::vector<int> v;
|
||||||
|
REQUIRE( v.size() == 0 );
|
||||||
|
|
||||||
|
WHEN( "it is made larger" ) {
|
||||||
|
v.resize( 10 );
|
||||||
|
THEN( "the size and capacity go up" ) {
|
||||||
|
REQUIRE( v.size() == 10 );
|
||||||
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
|
||||||
|
AND_WHEN( "it is made smaller again" ) {
|
||||||
|
v.resize( 5 );
|
||||||
|
THEN( "the size goes down but the capacity stays the same" ) {
|
||||||
|
REQUIRE( v.size() == 5 );
|
||||||
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN( "we reserve more space" ) {
|
||||||
|
v.reserve( 10 );
|
||||||
|
THEN( "The capacity is increased but the size remains the same" ) {
|
||||||
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
REQUIRE( v.size() == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCENARIO( "This is a really long scenario name to see how the list command deals with wrapping",
|
||||||
|
"[very long tags][lots][long][tags][verbose]"
|
||||||
|
"[one very long tag name that should cause line wrapping writing out using the list command]"
|
||||||
|
"[anotherReallyLongTagNameButThisOneHasNoObviousWrapPointsSoShouldSplitWithinAWordUsingADashCharacter]" ) {
|
||||||
|
GIVEN( "A section name that is so long that it cannot fit in a single console width" )
|
||||||
|
WHEN( "The test headers are printed as part of the normal running of the scenario" )
|
||||||
|
THEN( "The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" )
|
||||||
|
SUCCEED("boo!");
|
||||||
|
}
|
@ -0,0 +1,754 @@
|
|||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
CatchSelfTest is a <version> host application.
|
||||||
|
Run with -? for options
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A METHOD_AS_TEST_CASE based test run that fails
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( s == "world" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "world"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A TEST_CASE_METHOD based test run that fails
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( m_a == 2 )
|
||||||
|
with expansion:
|
||||||
|
1 == 2
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Equality checks that should fail]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven == 6 )
|
||||||
|
with expansion:
|
||||||
|
7 == 6
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven == 8 )
|
||||||
|
with expansion:
|
||||||
|
7 == 8
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven == 0 )
|
||||||
|
with expansion:
|
||||||
|
7 == 0
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 9.11f ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 == Approx( 9.1099996567 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 9.0f ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 == Approx( 9.0 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 1 ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 == Approx( 1.0 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 0 ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 == Approx( 0.0 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.double_pi == Approx( 3.1415 ) )
|
||||||
|
with expansion:
|
||||||
|
3.1415926535 == Approx( 3.1415 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello == "goodbye" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "goodbye"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello == "hell" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "hell"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello == "hello1" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "hello1"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello.size() == 6 )
|
||||||
|
with expansion:
|
||||||
|
5 == 6
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( x == Approx( 1.301 ) )
|
||||||
|
with expansion:
|
||||||
|
1.3 == Approx( 1.301 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Inequality checks that should fails
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven != 7 )
|
||||||
|
with expansion:
|
||||||
|
7 != 7
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one != Approx( 9.1f ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 != Approx( 9.1000003815 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.double_pi != Approx( 3.1415926535 ) )
|
||||||
|
with expansion:
|
||||||
|
3.1415926535 != Approx( 3.1415926535 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello != "hello" )
|
||||||
|
with expansion:
|
||||||
|
"hello" != "hello"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello.size() != 5 )
|
||||||
|
with expansion:
|
||||||
|
5 != 5
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Ordering comparison checks that should fail
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven > 7 )
|
||||||
|
with expansion:
|
||||||
|
7 > 7
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven < 7 )
|
||||||
|
with expansion:
|
||||||
|
7 < 7
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven > 8 )
|
||||||
|
with expansion:
|
||||||
|
7 > 8
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven < 6 )
|
||||||
|
with expansion:
|
||||||
|
7 < 6
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven < 0 )
|
||||||
|
with expansion:
|
||||||
|
7 < 0
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven < -1 )
|
||||||
|
with expansion:
|
||||||
|
7 < -1
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven >= 8 )
|
||||||
|
with expansion:
|
||||||
|
7 >= 8
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven <= 6 )
|
||||||
|
with expansion:
|
||||||
|
7 <= 6
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one < 9 )
|
||||||
|
with expansion:
|
||||||
|
9.1 < 9
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one > 10 )
|
||||||
|
with expansion:
|
||||||
|
9.1 > 10
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.float_nine_point_one > 9.2 )
|
||||||
|
with expansion:
|
||||||
|
9.1 > 9.2
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello > "hello" )
|
||||||
|
with expansion:
|
||||||
|
"hello" > "hello"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello < "hello" )
|
||||||
|
with expansion:
|
||||||
|
"hello" < "hello"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello > "hellp" )
|
||||||
|
with expansion:
|
||||||
|
"hello" > "hellp"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello > "z" )
|
||||||
|
with expansion:
|
||||||
|
"hello" > "z"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello < "hellm" )
|
||||||
|
with expansion:
|
||||||
|
"hello" < "hellm"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello < "a" )
|
||||||
|
with expansion:
|
||||||
|
"hello" < "a"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello >= "z" )
|
||||||
|
with expansion:
|
||||||
|
"hello" >= "z"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.str_hello <= "a" )
|
||||||
|
with expansion:
|
||||||
|
"hello" <= "a"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
'Not' checks that should fail
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( false != false )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( true != true )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( !true )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_FALSE( true )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( !trueValue )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_FALSE( trueValue )
|
||||||
|
with expansion:
|
||||||
|
!true
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( !(1 == 1) )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_FALSE( 1 == 1 )
|
||||||
|
with expansion:
|
||||||
|
!(1 == 1)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Expected exceptions that don't throw or unexpected exceptions fail the test
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THROWS_AS( thisThrows() )
|
||||||
|
due to unexpected exception with message:
|
||||||
|
expected exception
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THROWS_AS( thisDoesntThrow() )
|
||||||
|
because no exception was thrown where one was expected:
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_NOTHROW( thisThrows() )
|
||||||
|
due to unexpected exception with message:
|
||||||
|
expected exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
When unchecked exceptions are thrown directly they are always failures
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
unexpected exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
An unchecked exception reports the line of the last assertion
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
{Unknown expression after the reported line}
|
||||||
|
due to unexpected exception with message:
|
||||||
|
unexpected exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
When unchecked exceptions are thrown from sections they are always failures
|
||||||
|
section name
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
unexpected exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
When unchecked exceptions are thrown from functions they are always failures
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( thisThrows() == 0 )
|
||||||
|
due to unexpected exception with message:
|
||||||
|
expected exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Unexpected custom exceptions can be translated
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
custom exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Custom exceptions can be translated when testing for nothrow
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE_NOTHROW( throwCustom() )
|
||||||
|
due to unexpected exception with message:
|
||||||
|
custom exception - not std
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Custom exceptions can be translated when testing for throwing as something else
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE_THROWS_AS( throwCustom() )
|
||||||
|
due to unexpected exception with message:
|
||||||
|
custom exception - not std
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Unexpected exceptions can be translated
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
3.14
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
INFO and WARN do not abort tests
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>:
|
||||||
|
warning:
|
||||||
|
this is a warning
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
INFO gets logged on failure
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( a == 1 )
|
||||||
|
with expansion:
|
||||||
|
2 == 1
|
||||||
|
with messages:
|
||||||
|
this message should be logged
|
||||||
|
so should this
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
INFO gets logged on failure, even if captured before successful assertions
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( a == 1 )
|
||||||
|
with expansion:
|
||||||
|
2 == 1
|
||||||
|
with messages:
|
||||||
|
this message may be logged later
|
||||||
|
this message should be logged
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( a == 0 )
|
||||||
|
with expansion:
|
||||||
|
2 == 0
|
||||||
|
with message:
|
||||||
|
and this, but later
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
FAIL aborts the test
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
This is a failure
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
FAIL does not require an argument
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Output from all sections is reported
|
||||||
|
one
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
Message from section one
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Output from all sections is reported
|
||||||
|
two
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
Message from section two
|
||||||
|
|
||||||
|
Message from section one
|
||||||
|
Message from section two
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
SCOPED_INFO is reset for each loop
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( i < 10 )
|
||||||
|
with expansion:
|
||||||
|
10 < 10
|
||||||
|
with messages:
|
||||||
|
current counter 10
|
||||||
|
i := 10
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
just failure
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
Previous info should not be seen
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
sends information to INFO
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MessageTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( false )
|
||||||
|
with messages:
|
||||||
|
hi
|
||||||
|
i := 7
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
more nested SECTION tests
|
||||||
|
s1
|
||||||
|
s2
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( a == b )
|
||||||
|
with expansion:
|
||||||
|
1 == 2
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
looped SECTION tests
|
||||||
|
s1
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( b > a )
|
||||||
|
with expansion:
|
||||||
|
0 > 1
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
looped tests
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[0] (1) is even
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[1] (1) is even
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[3] (3) is even
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[4] (5) is even
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[6] (13) is even
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 )
|
||||||
|
with expansion:
|
||||||
|
1 == 0
|
||||||
|
with message:
|
||||||
|
Testing if fib[7] (21) is even
|
||||||
|
|
||||||
|
A string sent directly to stdout
|
||||||
|
A string sent directly to stderr
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
checkedIf, failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECKED_IF( flag )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( testCheckedIf( false ) )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
checkedElse, failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECKED_ELSE( flag )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( testCheckedElse( false ) )
|
||||||
|
with expansion:
|
||||||
|
false
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
send a single char to INFO
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( false )
|
||||||
|
with message:
|
||||||
|
3
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Contains string matcher
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching() Contains( "not there" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" contains: "not there"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
StartsWith string matcher
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching() StartsWith( "string" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
EndsWith string matcher
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching() EndsWith( "this" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" ends with: "this"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Equals string matcher
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching() Equals( "something else" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" equals: "something else"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Nice descriptive name
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
warning:
|
||||||
|
This one ran
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A couple of nested sections followed by a failure
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
to infinity and beyond
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A couple of nested sections followed by a failure
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
to infinity and beyond
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A couple of nested sections followed by a failure
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
explicitly with message:
|
||||||
|
to infinity and beyond
|
||||||
|
|
||||||
|
hello
|
||||||
|
hello
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Where the is more to the expression after the RHS[failing]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
TrickyTests.cpp:<line number>:
|
||||||
|
warning:
|
||||||
|
Uncomment the code in this test to check that it gives a sensible compiler
|
||||||
|
error
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Where the LHS is not a simple value[failing]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
TrickyTests.cpp:<line number>:
|
||||||
|
warning:
|
||||||
|
Uncomment the code in this test to check that it gives a sensible compiler
|
||||||
|
error
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A failing expression with a non streamable type is still captured[failing]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
TrickyTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( &o1 == &o2 )
|
||||||
|
with expansion:
|
||||||
|
0x<hex digits> == 0x<hex digits>
|
||||||
|
|
||||||
|
TrickyTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( o1 == o2 )
|
||||||
|
with expansion:
|
||||||
|
{?} == {?}
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
string literals of different sizes can be compared[failing]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
TrickyTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( std::string( "first" ) == "second" )
|
||||||
|
with expansion:
|
||||||
|
"first" == "second"
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
123 test cases - 36 failed (676 assertions - 91 failed)
|
||||||
|
|
7162
single_include_projects/SelfTest/Baselines/console.sw.approved.txt
Normal file
7162
single_include_projects/SelfTest/Baselines/console.sw.approved.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,322 @@
|
|||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
CatchSelfTest is a <version> host application.
|
||||||
|
Run with -? for options
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Some simple comparisons between doubles
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d == Approx( 1.23 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.23 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d != Approx( 1.22 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 != Approx( 1.22 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d != Approx( 1.24 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 != Approx( 1.24 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( Approx( d ) == 1.23 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) == 1.23
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( Approx( d ) != 1.22 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) != 1.22
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( Approx( d ) != 1.24 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) != 1.24
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approximate comparisons with different epsilons
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d != Approx( 1.231 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 != Approx( 1.231 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.231 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approximate comparisons with floats
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 1.23f == Approx( 1.23f ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.2300000191 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 0.0f == Approx( 0.0f ) )
|
||||||
|
with expansion:
|
||||||
|
0 == Approx( 0.0 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approximate comparisons with ints
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 1 == Approx( 1 ) )
|
||||||
|
with expansion:
|
||||||
|
1 == Approx( 1.0 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 0 == Approx( 0 ) )
|
||||||
|
with expansion:
|
||||||
|
0 == Approx( 0.0 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approximate comparisons with mixed numeric types
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 1.0f == Approx( 1 ) )
|
||||||
|
with expansion:
|
||||||
|
1 == Approx( 1.0 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 0 == Approx( dZero) )
|
||||||
|
with expansion:
|
||||||
|
0 == Approx( 0.0 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) )
|
||||||
|
with expansion:
|
||||||
|
0 == Approx( 0.00001 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 1.234f == Approx( dMedium ) )
|
||||||
|
with expansion:
|
||||||
|
1.234 == Approx( 1.234 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( dMedium == Approx( 1.234f ) )
|
||||||
|
with expansion:
|
||||||
|
1.234 == Approx( 1.2339999676 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Use a custom approx
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d == approx( 1.23 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.23 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d == approx( 1.22 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.22 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d == approx( 1.24 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 == Approx( 1.24 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( d != approx( 1.25 ) )
|
||||||
|
with expansion:
|
||||||
|
1.23 != Approx( 1.25 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( approx( d ) == 1.23 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) == 1.23
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( approx( d ) == 1.22 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) == 1.22
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( approx( d ) == 1.24 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) == 1.24
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( approx( d ) != 1.25 )
|
||||||
|
with expansion:
|
||||||
|
Approx( 1.23 ) != 1.25
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approximate PI
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) )
|
||||||
|
with expansion:
|
||||||
|
3.1428571429 == Approx( 3.141 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) )
|
||||||
|
with expansion:
|
||||||
|
3.1428571429 != Approx( 3.141 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A METHOD_AS_TEST_CASE based test run that succeeds
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( s == "hello" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "hello"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A METHOD_AS_TEST_CASE based test run that fails
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( s == "world" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "world"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A TEST_CASE_METHOD based test run that succeeds
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( m_a == 1 )
|
||||||
|
with expansion:
|
||||||
|
1 == 1
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
A TEST_CASE_METHOD based test run that fails
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ClassTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE( m_a == 2 )
|
||||||
|
with expansion:
|
||||||
|
1 == 2
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Equality checks that should succeed
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( data.int_seven == 7 )
|
||||||
|
with expansion:
|
||||||
|
7 == 7
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) )
|
||||||
|
with expansion:
|
||||||
|
9.1 == Approx( 9.1000003815 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( data.double_pi == Approx( 3.1415926535 ) )
|
||||||
|
with expansion:
|
||||||
|
3.1415926535 == Approx( 3.1415926535 )
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( data.str_hello == "hello" )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "hello"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( "hello" == data.str_hello )
|
||||||
|
with expansion:
|
||||||
|
"hello" == "hello"
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( data.str_hello.size() == 5 )
|
||||||
|
with expansion:
|
||||||
|
5 == 5
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( x == Approx( 1.3 ) )
|
||||||
|
with expansion:
|
||||||
|
1.3 == Approx( 1.3 )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Equality checks that should fail]
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven == 6 )
|
||||||
|
with expansion:
|
||||||
|
7 == 6
|
||||||
|
|
||||||
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK( data.int_seven == 8 )
|
||||||
|
with expansion:
|
||||||
|
7 == 8
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
13 test cases - 3 failed (40 assertions - 4 failed)
|
||||||
|
|
562
single_include_projects/SelfTest/Baselines/junit.sw.approved.txt
Normal file
562
single_include_projects/SelfTest/Baselines/junit.sw.approved.txt
Normal file
@ -0,0 +1,562 @@
|
|||||||
|
<testsuites>
|
||||||
|
<testsuite name="~_" errors="10" failures="100" tests="695" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
|
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approximate comparisons with ints" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approximate comparisons with mixed numeric types" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Use a custom approx" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approximate PI" time="{duration}"/>
|
||||||
|
<testcase classname="TestClass" name="A METHOD_AS_TEST_CASE based test run that succeeds" time="{duration}"/>
|
||||||
|
<testcase classname="TestClass" name="A METHOD_AS_TEST_CASE based test run that fails" time="{duration}">
|
||||||
|
<failure message=""hello" == "world"" type="REQUIRE">
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="Fixture" name="A TEST_CASE_METHOD based test run that succeeds" time="{duration}"/>
|
||||||
|
<testcase classname="Fixture" name="A TEST_CASE_METHOD based test run that fails" time="{duration}">
|
||||||
|
<failure message="1 == 2" type="REQUIRE">
|
||||||
|
ClassTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Equality checks that should succeed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Equality checks that should fail]" time="{duration}">
|
||||||
|
<failure message="7 == 6" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 == 8" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 == 0" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 == Approx( 9.1099996567 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 == Approx( 9.0 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 == Approx( 1.0 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 == Approx( 0.0 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="3.1415926535 == Approx( 3.1415 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" == "goodbye"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" == "hell"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" == "hello1"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="5 == 6" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1.3 == Approx( 1.301 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Inequality checks that should succeed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Inequality checks that should fails" time="{duration}">
|
||||||
|
<failure message="7 != 7" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 != Approx( 9.1000003815 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="3.1415926535 != Approx( 3.1415926535 )" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" != "hello"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="5 != 5" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Ordering comparison checks that should succeed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Ordering comparison checks that should fail" time="{duration}">
|
||||||
|
<failure message="7 > 7" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 < 7" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 > 8" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 < 6" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 < 0" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 < -1" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 >= 8" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="7 <= 6" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 < 9" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 > 10" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="9.1 > 9.2" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" > "hello"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" < "hello"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" > "hellp"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" > "z"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" < "hellm"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" < "a"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" >= "z"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message=""hello" <= "a"" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="comparisons between int variables" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="comparisons between const int variables" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Comparisons between ints where one side is computed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Pointers can be compared to null" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="'Not' checks that should succeed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
||||||
|
<failure message="false != false" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="true != true" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="false" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="!true" type="CHECK_FALSE">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="false" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="!true" type="CHECK_FALSE">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="false" type="CHECK">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="!(1 == 1)" type="CHECK_FALSE">
|
||||||
|
ConditionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="When checked exceptions are thrown they can be expected or unexpected" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Expected exceptions that don't throw or unexpected exceptions fail the test" time="{duration}">
|
||||||
|
<error message="thisThrows()" type="CHECK_THROWS_AS">
|
||||||
|
expected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
<failure message="thisDoesntThrow()" type="CHECK_THROWS_AS">
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<error message="thisThrows()" type="CHECK_NOTHROW">
|
||||||
|
expected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="When unchecked exceptions are thrown directly they are always failures" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
unexpected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="An unchecked exception reports the line of the last assertion" time="{duration}">
|
||||||
|
<error message="{Unknown expression after the reported line}">
|
||||||
|
unexpected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="When unchecked exceptions are thrown from sections they are always failures" name="section name" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
unexpected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="When unchecked exceptions are thrown from functions they are always failures" time="{duration}">
|
||||||
|
<error message="thisThrows() == 0" type="CHECK">
|
||||||
|
expected exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Unexpected custom exceptions can be translated" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
custom exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
|
||||||
|
<error message="throwCustom()" type="REQUIRE_NOTHROW">
|
||||||
|
custom exception - not std
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Custom exceptions can be translated when testing for throwing as something else" time="{duration}">
|
||||||
|
<error message="throwCustom()" type="REQUIRE_THROWS_AS">
|
||||||
|
custom exception - not std
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Unexpected exceptions can be translated" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
3.14
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Generators over two ranges" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
|
||||||
|
<failure message="2 == 1" type="REQUIRE">
|
||||||
|
this message should be logged
|
||||||
|
so should this
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="INFO gets logged on failure, even if captured before successful assertions" time="{duration}">
|
||||||
|
<failure message="2 == 1" type="CHECK">
|
||||||
|
this message should be logged
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="2 == 0" type="CHECK">
|
||||||
|
and this, but later
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="FAIL aborts the test" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
This is a failure
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="FAIL does not require an argument" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="SUCCESS does not require an argument" time="{duration}"/>
|
||||||
|
<testcase classname="Output from all sections is reported" name="one" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
Message from section one
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="Output from all sections is reported" name="two" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
Message from section two
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="Standard output from all sections is reported" name="two" time="{duration}">
|
||||||
|
<system-out>
|
||||||
|
Message from section one
|
||||||
|
Message from section two
|
||||||
|
</system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="SCOPED_INFO is reset for each loop" time="{duration}">
|
||||||
|
<failure message="10 < 10" type="REQUIRE">
|
||||||
|
current counter 10
|
||||||
|
i := 10
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="just failure" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
Previous info should not be seen
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="sends information to INFO" time="{duration}">
|
||||||
|
<failure message="false" type="REQUIRE">
|
||||||
|
hi
|
||||||
|
i := 7
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="random SECTION tests" name="s1" time="{duration}"/>
|
||||||
|
<testcase classname="random SECTION tests" name="s2" time="{duration}"/>
|
||||||
|
<testcase classname="nested SECTION tests" name="s1" time="{duration}"/>
|
||||||
|
<testcase classname="nested SECTION tests" name="s1/s2" time="{duration}"/>
|
||||||
|
<testcase classname="more nested SECTION tests" name="s1/s2" time="{duration}">
|
||||||
|
<failure message="1 == 2" type="REQUIRE">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="more nested SECTION tests" name="s1/s3" time="{duration}"/>
|
||||||
|
<testcase classname="more nested SECTION tests" name="s1/s4" time="{duration}"/>
|
||||||
|
<testcase classname="looped SECTION tests" name="s1" time="{duration}">
|
||||||
|
<failure message="0 > 1" type="CHECK">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="looped tests" time="{duration}">
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[0] (1) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[1] (1) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[3] (3) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[4] (5) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[6] (13) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="1 == 0" type="CHECK">
|
||||||
|
Testing if fib[7] (21) is even
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Sends stuff to stdout and stderr" time="{duration}">
|
||||||
|
<system-out>
|
||||||
|
A string sent directly to stdout
|
||||||
|
</system-out>
|
||||||
|
<system-err>
|
||||||
|
A string sent directly to stderr
|
||||||
|
</system-err>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="null strings" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="checkedIf" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="checkedIf, failing" time="{duration}">
|
||||||
|
<failure message="false" type="CHECKED_IF">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="false" type="REQUIRE">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="checkedElse" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="checkedElse, failing" time="{duration}">
|
||||||
|
<failure message="false" type="CHECKED_ELSE">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="false" type="REQUIRE">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="send a single char to INFO" time="{duration}">
|
||||||
|
<failure message="false" type="REQUIRE">
|
||||||
|
3
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="atomic if" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="String matchers" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Contains string matcher" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" contains: "not there"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="StartsWith string matcher" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" starts with: "string"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="EndsWith string matcher" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" ends with: "this"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Equals string matcher" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" equals: "something else"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Equals string matcher, with NULL" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Equals" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="resizing bigger changes size and capacity" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="resizing smaller changes size but not capacity" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="resizing smaller changes size but not capacity/We can use the 'swap trick' to reset the capacity" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="reserving bigger changes capacity but not size" time="{duration}"/>
|
||||||
|
<testcase classname="vectors can be sized and resized" name="reserving smaller does not change size or capacity" time="{duration}"/>
|
||||||
|
<testcase classname="A couple of nested sections followed by a failure" name="root" time="{duration}">
|
||||||
|
<failure type="FAIL">
|
||||||
|
to infinity and beyond
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure type="FAIL">
|
||||||
|
to infinity and beyond
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure type="FAIL">
|
||||||
|
to infinity and beyond
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="A couple of nested sections followed by a failure" name="Outer/Inner" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="test lists/Specify two test cases using -t" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="abort/-a aborts after first failure" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="abort/-x 2 aborts after two failures" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="abort/-x must be greater than zero" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="abort/-x must be numeric" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="nothrow/-e" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="nothrow/--nothrow" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="output filename/-o filename" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="output filename/--out" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="combinations/Single character flags can be combined" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="selftest/test filter" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="selftest/test filters" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="selftest/filter/prefix wildcard" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="selftest/filter/wildcard at both ends" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="single [one] tag" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="single [two] tag" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="two tags" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="complex" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="one tag with characters either side" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="start of a tag, but not closed" time="{duration}"/>
|
||||||
|
<testcase classname="selftest/tags" name="hidden" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/No wrapping" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped once" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped twice" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped three times" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/Short wrap" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/As container" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="plain string/Indent first line differently" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="With newlines/No wrapping" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="With newlines/Trailing newline" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped once" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped twice" time="{duration}"/>
|
||||||
|
<testcase classname="Long strings can be wrapped" name="With tabs" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Strings can be rendered with colour" time="{duration}">
|
||||||
|
<system-out>
|
||||||
|
hello
|
||||||
|
hello
|
||||||
|
</system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Where the is more to the expression after the RHS[failing]" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Where the LHS is not a simple value[failing]" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="A failing expression with a non streamable type is still captured[failing]" time="{duration}">
|
||||||
|
<failure message="0x<hex digits> == 0x<hex digits>" type="CHECK">
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
<failure message="{?} == {?}" type="CHECK">
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="string literals of different sizes can be compared[failing]" time="{duration}">
|
||||||
|
<failure message=""first" == "second"" type="REQUIRE">
|
||||||
|
TrickyTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="An expression with side-effects should only be evaluated once" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Operators at different namespace levels not hijacked by Koenig lookup" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Demonstrate that a non-const == is not used" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Test enum bit values" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="boolean member" time="{duration}"/>
|
||||||
|
<testcase classname="(unimplemented) static bools can be evaluated" name="compare to true" time="{duration}"/>
|
||||||
|
<testcase classname="(unimplemented) static bools can be evaluated" name="compare to false" time="{duration}"/>
|
||||||
|
<testcase classname="(unimplemented) static bools can be evaluated" name="negation" time="{duration}"/>
|
||||||
|
<testcase classname="(unimplemented) static bools can be evaluated" name="double negation" time="{duration}"/>
|
||||||
|
<testcase classname="(unimplemented) static bools can be evaluated" name="direct" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Objects that evaluated in boolean contexts can be checked" time="{duration}"/>
|
||||||
|
<testcase classname="Assertions then sections" name="root" time="{duration}"/>
|
||||||
|
<testcase classname="Assertions then sections" name="A section" time="{duration}"/>
|
||||||
|
<testcase classname="Assertions then sections" name="A section/Another section" time="{duration}"/>
|
||||||
|
<testcase classname="Assertions then sections" name="A section/Another other section" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="non streamable - with conv. op" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Comparing function pointers" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Comparing member function pointers" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="pointer to class" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="X/level/0/a" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="X/level/0/b" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="X/level/1/a" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="X/level/1/b" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Anonymous test case 1" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Test case with one argument" time="{duration}"/>
|
||||||
|
<testcase classname="Variadic macros" name="Section with one argument" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Do that thing with the thing" name="Given: This stuff exists/When: I do this/Then: it should do this" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Do that thing with the thing" name="Given: This stuff exists/When: I do this/Then: it should do this/And: do that" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up/And when: it is made smaller again/Then: the size goes down but the capacity stays the same" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: we reserve more space/Then: The capacity is increased but the size remains the same" time="{duration}"/>
|
||||||
|
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="process name" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="arg separated by spaces" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="arg separated by colon" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="arg separated by =" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="long opt" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="a number" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="not a number" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="two parsers" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="methods/in range" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="methods/out of range" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="flags/set" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="flags/not set" time="{duration}"/>
|
||||||
|
<testcase classname="cmdline" name="positional" time="{duration}"/>
|
||||||
|
<testcase classname="section tracking" name="root" time="{duration}"/>
|
||||||
|
<testcase classname="section tracking" name="test case with no sections" time="{duration}"/>
|
||||||
|
<testcase classname="section tracking" name="test case with one section" time="{duration}"/>
|
||||||
|
<testcase classname="section tracking" name="test case with two consecutive sections" time="{duration}"/>
|
||||||
|
<testcase classname="section tracking" name="test case with one section within another" time="{duration}"/>
|
||||||
|
<system-out>
|
||||||
|
Message from section one
|
||||||
|
Message from section two
|
||||||
|
A string sent directly to stdout
|
||||||
|
hello
|
||||||
|
hello
|
||||||
|
</system-out>
|
||||||
|
<system-err>
|
||||||
|
A string sent directly to stderr
|
||||||
|
</system-err>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
7424
single_include_projects/SelfTest/Baselines/xml.sw.approved.txt
Normal file
7424
single_include_projects/SelfTest/Baselines/xml.sw.approved.txt
Normal file
File diff suppressed because it is too large
Load Diff
53
single_include_projects/SelfTest/ClassTests.cpp
Normal file
53
single_include_projects/SelfTest/ClassTests.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
class TestClass
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TestClass()
|
||||||
|
: s( "hello" )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void succeedingCase()
|
||||||
|
{
|
||||||
|
REQUIRE( s == "hello" );
|
||||||
|
}
|
||||||
|
void failingCase()
|
||||||
|
{
|
||||||
|
REQUIRE( s == "world" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Note: TestClass conflicts with template class with same name in VS2012 native tests
|
||||||
|
METHOD_AS_TEST_CASE( ::TestClass::succeedingCase, "A METHOD_AS_TEST_CASE based test run that succeeds", "[class]" )
|
||||||
|
METHOD_AS_TEST_CASE( ::TestClass::failingCase, "A METHOD_AS_TEST_CASE based test run that fails", "[.][class][failing]" )
|
||||||
|
|
||||||
|
struct Fixture
|
||||||
|
{
|
||||||
|
Fixture() : m_a( 1 ) {}
|
||||||
|
|
||||||
|
int m_a;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" )
|
||||||
|
{
|
||||||
|
REQUIRE( m_a == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// We should be able to write our tests within a different namespace
|
||||||
|
namespace Inner
|
||||||
|
{
|
||||||
|
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" )
|
||||||
|
{
|
||||||
|
REQUIRE( m_a == 2 );
|
||||||
|
}
|
||||||
|
}
|
192
single_include_projects/SelfTest/CmdLineTests.cpp
Normal file
192
single_include_projects/SelfTest/CmdLineTests.cpp
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "internal/clara.h" // This will does not declare Clara within the Catch namespace
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
// Helper to deduce size from array literals and pass on to parser
|
||||||
|
template<size_t size, typename ConfigT>
|
||||||
|
std::vector<Clara::Parser::Token> parseInto( Clara::CommandLine<ConfigT>& cli, char const * (&argv)[size], ConfigT& config ) {
|
||||||
|
return cli.parseInto( size, argv, config );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct TestOpt {
|
||||||
|
TestOpt() : number( 0 ), index( 0 ), flag( false ) {}
|
||||||
|
|
||||||
|
std::string processName;
|
||||||
|
std::string fileName;
|
||||||
|
int number;
|
||||||
|
int index;
|
||||||
|
bool flag;
|
||||||
|
std::string firstPos;
|
||||||
|
std::string secondPos;
|
||||||
|
std::string unpositional;
|
||||||
|
|
||||||
|
void setValidIndex( int i ) {
|
||||||
|
if( i < 0 || i > 10 )
|
||||||
|
throw std::domain_error( "index must be between 0 and 10" );
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TestOpt2 {
|
||||||
|
std::string description;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
|
|
||||||
|
TEST_CASE( "cmdline" ) {
|
||||||
|
|
||||||
|
TestOpt config;
|
||||||
|
Clara::CommandLine<TestOpt> cli;
|
||||||
|
cli.bindProcessName( &TestOpt::processName );
|
||||||
|
cli.bind( &TestOpt::fileName )
|
||||||
|
.describe( "specifies output file" )
|
||||||
|
.shortOpt( "o" )
|
||||||
|
.longOpt( "output" )
|
||||||
|
.hint( "filename" );
|
||||||
|
|
||||||
|
SECTION( "process name" ) {
|
||||||
|
char const * argv[] = { "test", "-o filename.ext" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.processName == "test" );
|
||||||
|
}
|
||||||
|
SECTION( "arg separated by spaces" ) {
|
||||||
|
char const * argv[] = { "test", "-o filename.ext" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.fileName == "filename.ext" );
|
||||||
|
}
|
||||||
|
SECTION( "arg separated by colon" ) {
|
||||||
|
const char* argv[] = { "test", "-o:filename.ext" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.fileName == "filename.ext" );
|
||||||
|
}
|
||||||
|
SECTION( "arg separated by =" ) {
|
||||||
|
const char* argv[] = { "test", "-o=filename.ext" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.fileName == "filename.ext" );
|
||||||
|
}
|
||||||
|
SECTION( "long opt" ) {
|
||||||
|
const char* argv[] = { "test", "--output %stdout" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.fileName == "%stdout" );
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.bind( &TestOpt::number )
|
||||||
|
.shortOpt( "n" )
|
||||||
|
.hint( "an integral value" );
|
||||||
|
|
||||||
|
SECTION( "a number" ) {
|
||||||
|
const char* argv[] = { "test", "-n 42" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
CHECK( config.number == 42 );
|
||||||
|
}
|
||||||
|
SECTION( "not a number" ) {
|
||||||
|
const char* argv[] = { "test", "-n forty-two" };
|
||||||
|
CHECK_THROWS( parseInto( cli, argv, config ) );
|
||||||
|
|
||||||
|
CHECK( config.number == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "two parsers" ) {
|
||||||
|
|
||||||
|
TestOpt config1;
|
||||||
|
TestOpt2 config2;
|
||||||
|
Clara::CommandLine<TestOpt2> cli2;
|
||||||
|
|
||||||
|
cli2.bind( &TestOpt2::description )
|
||||||
|
.describe( "description" )
|
||||||
|
.shortOpt( "d" )
|
||||||
|
.longOpt( "description" )
|
||||||
|
.hint( "some text" );
|
||||||
|
|
||||||
|
const char* argv[] = { "test", "-n 42", "-d some text" };
|
||||||
|
std::vector<Clara::Parser::Token> unusedTokens = parseInto( cli, argv, config1 );
|
||||||
|
|
||||||
|
CHECK( config1.number == 42 );
|
||||||
|
|
||||||
|
REQUIRE_FALSE( unusedTokens.empty() );
|
||||||
|
cli2.populate( unusedTokens, config2 );
|
||||||
|
CHECK( config2.description == "some text" );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "methods" ) {
|
||||||
|
cli.bind( &TestOpt::setValidIndex )
|
||||||
|
.describe( "An index, which is an integer between 0 and 10, inclusive" )
|
||||||
|
.shortOpt( "i" )
|
||||||
|
.hint( "index" );
|
||||||
|
|
||||||
|
SECTION( "in range" ) {
|
||||||
|
const char* argv[] = { "test", "-i 3" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
REQUIRE( config.index == 3 );
|
||||||
|
}
|
||||||
|
SECTION( "out of range" ) {
|
||||||
|
const char* argv[] = { "test", "-i 42" };
|
||||||
|
|
||||||
|
REQUIRE_THROWS( parseInto( cli, argv, config ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "flags" ) {
|
||||||
|
cli.bind( &TestOpt::flag )
|
||||||
|
.describe( "A flag" )
|
||||||
|
.shortOpt( "f" );
|
||||||
|
|
||||||
|
SECTION( "set" ) {
|
||||||
|
const char* argv[] = { "test", "-f" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
REQUIRE( config.flag );
|
||||||
|
}
|
||||||
|
SECTION( "not set" ) {
|
||||||
|
const char* argv[] = { "test" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
REQUIRE( config.flag == false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SECTION( "positional" ) {
|
||||||
|
cli.bind( &TestOpt::secondPos )
|
||||||
|
.describe( "Second position" )
|
||||||
|
.hint( "second arg" )
|
||||||
|
.position( 2 );
|
||||||
|
cli.bind( &TestOpt::unpositional )
|
||||||
|
.hint( "any arg" )
|
||||||
|
.describe( "Unpositional" );
|
||||||
|
cli.bind( &TestOpt::firstPos )
|
||||||
|
.describe( "First position" )
|
||||||
|
.hint( "first arg" )
|
||||||
|
.position( 1 );
|
||||||
|
|
||||||
|
// std::cout << cli.usage( "testApp" ) << std::endl;
|
||||||
|
|
||||||
|
const char* argv[] = { "test", "-f", "1st", "-o", "filename", "2nd", "3rd" };
|
||||||
|
parseInto( cli, argv, config );
|
||||||
|
|
||||||
|
REQUIRE( config.firstPos == "1st" );
|
||||||
|
REQUIRE( config.secondPos == "2nd" );
|
||||||
|
REQUIRE( config.unpositional == "3rd" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
337
single_include_projects/SelfTest/ConditionTests.cpp
Normal file
337
single_include_projects/SelfTest/ConditionTests.cpp
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 08/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
namespace ConditionTests
|
||||||
|
{
|
||||||
|
|
||||||
|
struct TestData {
|
||||||
|
TestData()
|
||||||
|
: int_seven( 7 ),
|
||||||
|
str_hello( "hello" ),
|
||||||
|
float_nine_point_one( 9.1f ),
|
||||||
|
double_pi( 3.1415926535 )
|
||||||
|
{}
|
||||||
|
|
||||||
|
int int_seven;
|
||||||
|
std::string str_hello;
|
||||||
|
float float_nine_point_one;
|
||||||
|
double double_pi;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TestDef {
|
||||||
|
TestDef& operator + ( const std::string& ) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
TestDef& operator[]( const std::string& ) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// The "failing" tests all use the CHECK macro, which continues if the specific test fails.
|
||||||
|
// This allows us to see all results, even if an earlier check fails
|
||||||
|
|
||||||
|
// Equality tests
|
||||||
|
TEST_CASE( "Equality checks that should succeed", "" )
|
||||||
|
{
|
||||||
|
|
||||||
|
TestDef td;
|
||||||
|
td + "hello" + "hello";
|
||||||
|
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
REQUIRE( data.int_seven == 7 );
|
||||||
|
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) );
|
||||||
|
REQUIRE( data.double_pi == Approx( 3.1415926535 ) );
|
||||||
|
REQUIRE( data.str_hello == "hello" );
|
||||||
|
REQUIRE( "hello" == data.str_hello );
|
||||||
|
REQUIRE( data.str_hello.size() == 5 );
|
||||||
|
|
||||||
|
double x = 1.1 + 0.1 + 0.1;
|
||||||
|
REQUIRE( x == Approx( 1.3 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Equality checks that should fail]", "[.][failing]" )
|
||||||
|
{
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
CHECK( data.int_seven == 6 );
|
||||||
|
CHECK( data.int_seven == 8 );
|
||||||
|
CHECK( data.int_seven == 0 );
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 9.11f ) );
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 9.0f ) );
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 1 ) );
|
||||||
|
CHECK( data.float_nine_point_one == Approx( 0 ) );
|
||||||
|
CHECK( data.double_pi == Approx( 3.1415 ) );
|
||||||
|
CHECK( data.str_hello == "goodbye" );
|
||||||
|
CHECK( data.str_hello == "hell" );
|
||||||
|
CHECK( data.str_hello == "hello1" );
|
||||||
|
CHECK( data.str_hello.size() == 6 );
|
||||||
|
|
||||||
|
double x = 1.1 + 0.1 + 0.1;
|
||||||
|
CHECK( x == Approx( 1.301 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Inequality checks that should succeed", "" )
|
||||||
|
{
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
REQUIRE( data.int_seven != 6 );
|
||||||
|
REQUIRE( data.int_seven != 8 );
|
||||||
|
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) );
|
||||||
|
REQUIRE( data.float_nine_point_one != Approx( 9.0f ) );
|
||||||
|
REQUIRE( data.float_nine_point_one != Approx( 1 ) );
|
||||||
|
REQUIRE( data.float_nine_point_one != Approx( 0 ) );
|
||||||
|
REQUIRE( data.double_pi != Approx( 3.1415 ) );
|
||||||
|
REQUIRE( data.str_hello != "goodbye" );
|
||||||
|
REQUIRE( data.str_hello != "hell" );
|
||||||
|
REQUIRE( data.str_hello != "hello1" );
|
||||||
|
REQUIRE( data.str_hello.size() != 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Inequality checks that should fails", "[.][failing]" )
|
||||||
|
{
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
CHECK( data.int_seven != 7 );
|
||||||
|
CHECK( data.float_nine_point_one != Approx( 9.1f ) );
|
||||||
|
CHECK( data.double_pi != Approx( 3.1415926535 ) );
|
||||||
|
CHECK( data.str_hello != "hello" );
|
||||||
|
CHECK( data.str_hello.size() != 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ordering comparison tests
|
||||||
|
TEST_CASE( "Ordering comparison checks that should succeed", "" )
|
||||||
|
{
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
REQUIRE( data.int_seven < 8 );
|
||||||
|
REQUIRE( data.int_seven > 6 );
|
||||||
|
REQUIRE( data.int_seven > 0 );
|
||||||
|
REQUIRE( data.int_seven > -1 );
|
||||||
|
|
||||||
|
REQUIRE( data.int_seven >= 7 );
|
||||||
|
REQUIRE( data.int_seven >= 6 );
|
||||||
|
REQUIRE( data.int_seven <= 7 );
|
||||||
|
REQUIRE( data.int_seven <= 8 );
|
||||||
|
|
||||||
|
REQUIRE( data.float_nine_point_one > 9 );
|
||||||
|
REQUIRE( data.float_nine_point_one < 10 );
|
||||||
|
REQUIRE( data.float_nine_point_one < 9.2 );
|
||||||
|
|
||||||
|
REQUIRE( data.str_hello <= "hello" );
|
||||||
|
REQUIRE( data.str_hello >= "hello" );
|
||||||
|
|
||||||
|
REQUIRE( data.str_hello < "hellp" );
|
||||||
|
REQUIRE( data.str_hello < "zebra" );
|
||||||
|
REQUIRE( data.str_hello > "hellm" );
|
||||||
|
REQUIRE( data.str_hello > "a" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
|
||||||
|
{
|
||||||
|
TestData data;
|
||||||
|
|
||||||
|
CHECK( data.int_seven > 7 );
|
||||||
|
CHECK( data.int_seven < 7 );
|
||||||
|
CHECK( data.int_seven > 8 );
|
||||||
|
CHECK( data.int_seven < 6 );
|
||||||
|
CHECK( data.int_seven < 0 );
|
||||||
|
CHECK( data.int_seven < -1 );
|
||||||
|
|
||||||
|
CHECK( data.int_seven >= 8 );
|
||||||
|
CHECK( data.int_seven <= 6 );
|
||||||
|
|
||||||
|
CHECK( data.float_nine_point_one < 9 );
|
||||||
|
CHECK( data.float_nine_point_one > 10 );
|
||||||
|
CHECK( data.float_nine_point_one > 9.2 );
|
||||||
|
|
||||||
|
CHECK( data.str_hello > "hello" );
|
||||||
|
CHECK( data.str_hello < "hello" );
|
||||||
|
CHECK( data.str_hello > "hellp" );
|
||||||
|
CHECK( data.str_hello > "z" );
|
||||||
|
CHECK( data.str_hello < "hellm" );
|
||||||
|
CHECK( data.str_hello < "a" );
|
||||||
|
|
||||||
|
CHECK( data.str_hello >= "z" );
|
||||||
|
CHECK( data.str_hello <= "a" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comparisons with int literals
|
||||||
|
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned", "" )
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
unsigned int ui = 2;
|
||||||
|
long l = 3;
|
||||||
|
unsigned long ul = 4;
|
||||||
|
char c = 5;
|
||||||
|
unsigned char uc = 6;
|
||||||
|
|
||||||
|
REQUIRE( i == 1 );
|
||||||
|
REQUIRE( ui == 2 );
|
||||||
|
REQUIRE( l == 3 );
|
||||||
|
REQUIRE( ul == 4 );
|
||||||
|
REQUIRE( c == 5 );
|
||||||
|
REQUIRE( uc == 6 );
|
||||||
|
|
||||||
|
REQUIRE( 1 == i );
|
||||||
|
REQUIRE( 2 == ui );
|
||||||
|
REQUIRE( 3 == l );
|
||||||
|
REQUIRE( 4 == ul );
|
||||||
|
REQUIRE( 5 == c );
|
||||||
|
REQUIRE( 6 == uc );
|
||||||
|
|
||||||
|
REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable warnings about sign conversions for the next two tests
|
||||||
|
// (as we are deliberately invoking them)
|
||||||
|
// - Currently only disabled for GCC/ LLVM. Should add VC++ too
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE( "comparisons between int variables", "" )
|
||||||
|
{
|
||||||
|
long long_var = 1L;
|
||||||
|
unsigned char unsigned_char_var = 1;
|
||||||
|
unsigned short unsigned_short_var = 1;
|
||||||
|
unsigned int unsigned_int_var = 1;
|
||||||
|
unsigned long unsigned_long_var = 1L;
|
||||||
|
|
||||||
|
REQUIRE( long_var == unsigned_char_var );
|
||||||
|
REQUIRE( long_var == unsigned_short_var );
|
||||||
|
REQUIRE( long_var == unsigned_int_var );
|
||||||
|
REQUIRE( long_var == unsigned_long_var );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "comparisons between const int variables", "" )
|
||||||
|
{
|
||||||
|
const unsigned char unsigned_char_var = 1;
|
||||||
|
const unsigned short unsigned_short_var = 1;
|
||||||
|
const unsigned int unsigned_int_var = 1;
|
||||||
|
const unsigned long unsigned_long_var = 1L;
|
||||||
|
|
||||||
|
REQUIRE( unsigned_char_var == 1 );
|
||||||
|
REQUIRE( unsigned_short_var == 1 );
|
||||||
|
REQUIRE( unsigned_int_var == 1 );
|
||||||
|
REQUIRE( unsigned_long_var == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour", "" )
|
||||||
|
{
|
||||||
|
CHECK( ( -1 > 2u ) );
|
||||||
|
CHECK( -1 > 2u );
|
||||||
|
|
||||||
|
CHECK( ( 2u < -1 ) );
|
||||||
|
CHECK( 2u < -1 );
|
||||||
|
|
||||||
|
const int minInt = (std::numeric_limits<int>::min)();
|
||||||
|
CHECK( ( minInt > 2u ) );
|
||||||
|
CHECK( minInt > 2u );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct Ex
|
||||||
|
{
|
||||||
|
Ex( T ){}
|
||||||
|
|
||||||
|
bool operator == ( const T& ) const { return true; }
|
||||||
|
T operator * ( const T& ) const { return T(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE( "Comparisons between ints where one side is computed", "" )
|
||||||
|
{
|
||||||
|
CHECK( 54 == 6*9 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline const char* returnsConstNull(){ return NULL; }
|
||||||
|
inline char* returnsNull(){ return NULL; }
|
||||||
|
|
||||||
|
TEST_CASE( "Pointers can be compared to null", "" )
|
||||||
|
{
|
||||||
|
TestData* p = NULL;
|
||||||
|
TestData* pNULL = NULL;
|
||||||
|
|
||||||
|
REQUIRE( p == NULL );
|
||||||
|
REQUIRE( p == pNULL );
|
||||||
|
|
||||||
|
TestData data;
|
||||||
|
p = &data;
|
||||||
|
|
||||||
|
REQUIRE( p != NULL );
|
||||||
|
|
||||||
|
const TestData* cp = p;
|
||||||
|
REQUIRE( cp != NULL );
|
||||||
|
|
||||||
|
const TestData* const cpc = p;
|
||||||
|
REQUIRE( cpc != NULL );
|
||||||
|
|
||||||
|
REQUIRE( returnsNull() == NULL );
|
||||||
|
REQUIRE( returnsConstNull() == NULL );
|
||||||
|
|
||||||
|
REQUIRE( NULL != p );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not (!) tests
|
||||||
|
// The problem with the ! operator is that it has right-to-left associativity.
|
||||||
|
// This means we can't isolate it when we decompose. The simple REQUIRE( !false ) form, therefore,
|
||||||
|
// cannot have the operand value extracted. The test will work correctly, and the situation
|
||||||
|
// is detected and a warning issued.
|
||||||
|
// An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture
|
||||||
|
// the operand value.
|
||||||
|
TEST_CASE( "'Not' checks that should succeed", "" )
|
||||||
|
{
|
||||||
|
bool falseValue = false;
|
||||||
|
|
||||||
|
REQUIRE( false == false );
|
||||||
|
REQUIRE( true == true );
|
||||||
|
REQUIRE( !false );
|
||||||
|
REQUIRE_FALSE( false );
|
||||||
|
|
||||||
|
REQUIRE( !falseValue );
|
||||||
|
REQUIRE_FALSE( falseValue );
|
||||||
|
|
||||||
|
REQUIRE( !(1 == 2) );
|
||||||
|
REQUIRE_FALSE( 1 == 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "'Not' checks that should fail", "[.][failing]" )
|
||||||
|
{
|
||||||
|
bool trueValue = true;
|
||||||
|
|
||||||
|
CHECK( false != false );
|
||||||
|
CHECK( true != true );
|
||||||
|
CHECK( !true );
|
||||||
|
CHECK_FALSE( true );
|
||||||
|
|
||||||
|
CHECK( !trueValue );
|
||||||
|
CHECK_FALSE( trueValue );
|
||||||
|
|
||||||
|
CHECK( !(1 == 1) );
|
||||||
|
CHECK_FALSE( 1 == 1 );
|
||||||
|
}
|
||||||
|
}
|
144
single_include_projects/SelfTest/ExceptionTests.cpp
Normal file
144
single_include_projects/SelfTest/ExceptionTests.cpp
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
inline int thisThrows()
|
||||||
|
{
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw std::domain_error( "expected exception" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int thisDoesntThrow()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ExceptionTests
|
||||||
|
{
|
||||||
|
TEST_CASE( "When checked exceptions are thrown they can be expected or unexpected", "" )
|
||||||
|
{
|
||||||
|
REQUIRE_THROWS_AS( thisThrows(), std::domain_error );
|
||||||
|
REQUIRE_NOTHROW( thisDoesntThrow() );
|
||||||
|
REQUIRE_THROWS( thisThrows() );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail the test", "[.][failing]" )
|
||||||
|
{
|
||||||
|
CHECK_THROWS_AS( thisThrows(), std::string );
|
||||||
|
CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error );
|
||||||
|
CHECK_NOTHROW( thisThrows() );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing]" )
|
||||||
|
{
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw std::domain_error( "unexpected exception" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing]" )
|
||||||
|
{
|
||||||
|
CHECK( 1 == 1 );
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw std::domain_error( "unexpected exception" );
|
||||||
|
}
|
||||||
|
TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing]" )
|
||||||
|
{
|
||||||
|
SECTION( "section name", "" )
|
||||||
|
{
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw std::domain_error( "unexpected exception" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "When unchecked exceptions are thrown from functions they are always failures", "[.][failing]" )
|
||||||
|
{
|
||||||
|
CHECK( thisThrows() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw std::domain_error( "unexpected exception" );
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CustomException( const std::string& msg )
|
||||||
|
: m_msg( msg )
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string getMessage() const
|
||||||
|
{
|
||||||
|
return m_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
|
||||||
|
{
|
||||||
|
return ex.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( double& ex )
|
||||||
|
{
|
||||||
|
return Catch::toString( ex );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" )
|
||||||
|
{
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw CustomException( "custom exception" );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void throwCustom() {
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw CustomException( "custom exception - not std" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Custom exceptions can be translated when testing for nothrow", "[.][failing]" )
|
||||||
|
{
|
||||||
|
REQUIRE_NOTHROW( throwCustom() );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Custom exceptions can be translated when testing for throwing as something else", "[.][failing]" )
|
||||||
|
{
|
||||||
|
REQUIRE_THROWS_AS( throwCustom(), std::exception );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE( "Unexpected exceptions can be translated", "[.][failing]" )
|
||||||
|
{
|
||||||
|
if( Catch::isTrue( true ) )
|
||||||
|
throw double( 3.14 );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int thisFunctionNotImplemented( int ) {
|
||||||
|
CATCH_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "NotImplemented exception", "" )
|
||||||
|
{
|
||||||
|
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
|
||||||
|
}
|
||||||
|
}
|
45
single_include_projects/SelfTest/GeneratorTests.cpp
Normal file
45
single_include_projects/SelfTest/GeneratorTests.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 28/01/2011.
|
||||||
|
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This define means we have to prefix all the CATCH macros with CATCH_
|
||||||
|
// We're using it here to test it out
|
||||||
|
#define CATCH_CONFIG_PREFIX_ALL
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
namespace GeneratorTests
|
||||||
|
{
|
||||||
|
inline int multiply( int a, int b )
|
||||||
|
{
|
||||||
|
return a*b;
|
||||||
|
}
|
||||||
|
|
||||||
|
CATCH_TEST_CASE( "Generators over two ranges", "[generators]" )
|
||||||
|
{
|
||||||
|
using namespace Catch::Generators;
|
||||||
|
|
||||||
|
int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
|
||||||
|
int j = CATCH_GENERATE( between( 100, 107 ) );
|
||||||
|
|
||||||
|
CATCH_REQUIRE( multiply( i, 2 ) == i*2 );
|
||||||
|
CATCH_REQUIRE( multiply( j, 2 ) == j*2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IntPair { int first, second; };
|
||||||
|
|
||||||
|
CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" )
|
||||||
|
{
|
||||||
|
using namespace Catch::Generators;
|
||||||
|
|
||||||
|
IntPair p[] = { { 0, 1 }, { 2, 3 } };
|
||||||
|
|
||||||
|
IntPair* i = CATCH_GENERATE( between( p, &p[1] ) );
|
||||||
|
|
||||||
|
CATCH_REQUIRE( i->first == i->second-1 );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
#undef INTERNAL_CATCH_INLINE
|
||||||
|
#define INTERNAL_CATCH_INLINE inline
|
||||||
|
#include "../../include/internal/catch_message.hpp"
|
||||||
|
|
||||||
|
namespace Counter {
|
||||||
|
int g_haveCountedMessages = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MI1
|
||||||
|
{
|
||||||
|
// This test works with the equivalent in MessageInstantiationTests2.cpp
|
||||||
|
// The first test to reach this point will increment the MessageInfo counter. Subsequent tests
|
||||||
|
// just check the value. The purpose of this test is to verify that the compiler's
|
||||||
|
// greedy instantiation (or whatever process it uses) eliminate all other
|
||||||
|
// references to the globalCount
|
||||||
|
|
||||||
|
TEST_CASE("message counting1","[vs]")
|
||||||
|
{
|
||||||
|
if( Counter::g_haveCountedMessages > 0 ) {
|
||||||
|
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++Catch::MessageInfoCounter<unsigned int>::globalCount;
|
||||||
|
Counter::g_haveCountedMessages = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace LongCounter {
|
||||||
|
int g_haveCountedMessagesLong = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MI1
|
||||||
|
{
|
||||||
|
TEST_CASE("long message counting1","[vs]")
|
||||||
|
{
|
||||||
|
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
|
||||||
|
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++Catch::MessageInfoCounter<long>::globalCount;
|
||||||
|
LongCounter::g_haveCountedMessagesLong = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
#define INTERNAL_CATCH_INLINE inline
|
||||||
|
#include "../../include/internal/catch_message.hpp"
|
||||||
|
|
||||||
|
namespace Counter {
|
||||||
|
extern int g_haveCountedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MI2
|
||||||
|
{
|
||||||
|
// This test works with the equivalent in MessageInstantiationTests1.cpp
|
||||||
|
// The first test to reach this point will increment the MessageInfo counter. Subsequent tests
|
||||||
|
// just check the value. The purpose of this test is to verify that the compiler's
|
||||||
|
// greedy instantiation (or whatever process it uses) eliminate all other
|
||||||
|
// references to the globalCount
|
||||||
|
|
||||||
|
TEST_CASE("message counting2","[vs]")
|
||||||
|
{
|
||||||
|
if( Counter::g_haveCountedMessages > 0 ) {
|
||||||
|
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++Catch::MessageInfoCounter<unsigned int>::globalCount;
|
||||||
|
Counter::g_haveCountedMessages = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace LongCounter {
|
||||||
|
extern int g_haveCountedMessagesLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MI2
|
||||||
|
{
|
||||||
|
TEST_CASE("long message counting2","[vs]")
|
||||||
|
{
|
||||||
|
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
|
||||||
|
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++Catch::MessageInfoCounter<long>::globalCount;
|
||||||
|
LongCounter::g_haveCountedMessagesLong = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
125
single_include_projects/SelfTest/MessageTests.cpp
Normal file
125
single_include_projects/SelfTest/MessageTests.cpp
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
namespace MessageTests
|
||||||
|
{
|
||||||
|
|
||||||
|
TEST_CASE( "INFO and WARN do not abort tests", "[messages]" )
|
||||||
|
{
|
||||||
|
INFO( "this is a " << "message" ); // This should output the message if a failure occurs
|
||||||
|
WARN( "this is a " << "warning" ); // This should always output the message but then continue
|
||||||
|
}
|
||||||
|
TEST_CASE( "SUCCEED counts as a test pass", "[messages]" )
|
||||||
|
{
|
||||||
|
SUCCEED( "this is a " << "success" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "INFO gets logged on failure", "[failing][messages][.]" )
|
||||||
|
{
|
||||||
|
INFO( "this message should be logged" );
|
||||||
|
INFO( "so should this" );
|
||||||
|
int a = 2;
|
||||||
|
REQUIRE( a == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "INFO gets logged on failure, even if captured before successful assertions", "[failing][messages][.]" )
|
||||||
|
{
|
||||||
|
INFO( "this message may be logged later" );
|
||||||
|
int a = 2;
|
||||||
|
CHECK( a == 2 );
|
||||||
|
|
||||||
|
INFO( "this message should be logged" );
|
||||||
|
|
||||||
|
CHECK( a == 1 );
|
||||||
|
|
||||||
|
INFO( "and this, but later" );
|
||||||
|
|
||||||
|
CHECK( a == 0 );
|
||||||
|
|
||||||
|
INFO( "but not this" );
|
||||||
|
|
||||||
|
CHECK( a == 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" )
|
||||||
|
{
|
||||||
|
FAIL( "This is a " << "failure" ); // This should output the message and abort
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
|
TEST_CASE( "FAIL does not require an argument", "[failing][messages][.]" )
|
||||||
|
{
|
||||||
|
FAIL();
|
||||||
|
}
|
||||||
|
TEST_CASE( "SUCCESS does not require an argument", "[messages][.]" )
|
||||||
|
{
|
||||||
|
SUCCEED();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" )
|
||||||
|
{
|
||||||
|
SECTION( "one", "" )
|
||||||
|
{
|
||||||
|
FAIL( "Message from section one" );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "two", "" )
|
||||||
|
{
|
||||||
|
FAIL( "Message from section two" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Standard output from all sections is reported", "[messages]" )
|
||||||
|
{
|
||||||
|
SECTION( "one", "" )
|
||||||
|
{
|
||||||
|
std::cout << "Message from section one" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "two", "" )
|
||||||
|
{
|
||||||
|
std::cout << "Message from section two" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
|
||||||
|
{
|
||||||
|
for( int i=0; i<100; i++ )
|
||||||
|
{
|
||||||
|
SCOPED_INFO( "current counter " << i );
|
||||||
|
SCOPED_CAPTURE( i );
|
||||||
|
REQUIRE( i < 10 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "The NO_FAIL macro reports a failure but does not fail the test", "[messages]" )
|
||||||
|
{
|
||||||
|
CHECK_NOFAIL( 1 == 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "just info", "[info][isolated info][messages]" )
|
||||||
|
{
|
||||||
|
INFO( "this should never be seen" );
|
||||||
|
}
|
||||||
|
TEST_CASE( "just failure", "[fail][isolated info][.][messages]" )
|
||||||
|
{
|
||||||
|
FAIL( "Previous info should not be seen" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE( "sends information to INFO", "[.][failing]" )
|
||||||
|
{
|
||||||
|
INFO( "hi" );
|
||||||
|
int i = 7;
|
||||||
|
CAPTURE( i );
|
||||||
|
REQUIRE( false );
|
||||||
|
}
|
||||||
|
}
|
339
single_include_projects/SelfTest/MiscTests.cpp
Normal file
339
single_include_projects/SelfTest/MiscTests.cpp
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 29/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace MiscTests
|
||||||
|
{
|
||||||
|
|
||||||
|
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
int b = 2;
|
||||||
|
|
||||||
|
SECTION( "s1", "doesn't equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a != b );
|
||||||
|
REQUIRE( b != a );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "s2", "not equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a != b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "nested SECTION tests", "[.][sections][failing]" )
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
int b = 2;
|
||||||
|
|
||||||
|
SECTION( "s1", "doesn't equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a != b );
|
||||||
|
REQUIRE( b != a );
|
||||||
|
|
||||||
|
SECTION( "s2", "not equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a != b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" )
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
int b = 2;
|
||||||
|
|
||||||
|
SECTION( "s1", "doesn't equal" )
|
||||||
|
{
|
||||||
|
SECTION( "s2", "equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a == b );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "s3", "not equal" )
|
||||||
|
{
|
||||||
|
REQUIRE( a != b );
|
||||||
|
}
|
||||||
|
SECTION( "s4", "less than" )
|
||||||
|
{
|
||||||
|
REQUIRE( a < b );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "even more nested SECTION tests", "[sections]" )
|
||||||
|
{
|
||||||
|
SECTION( "c", "" )
|
||||||
|
{
|
||||||
|
SECTION( "d (leaf)", "" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "e (leaf)", "" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "f (leaf)", "" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "looped SECTION tests", "[.][failing][sections]" )
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
|
||||||
|
for( int b = 0; b < 10; ++b )
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "b is currently: " << b;
|
||||||
|
SECTION( "s1", oss.str() )
|
||||||
|
{
|
||||||
|
CHECK( b > a );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "looped tests", "[.][failing]" )
|
||||||
|
{
|
||||||
|
static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
|
||||||
|
|
||||||
|
for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i )
|
||||||
|
{
|
||||||
|
INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" );
|
||||||
|
CHECK( ( fib[i] % 2 ) == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Sends stuff to stdout and stderr", "" )
|
||||||
|
{
|
||||||
|
std::cout << "A string sent directly to stdout" << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "A string sent directly to stderr" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* makeString( bool makeNull )
|
||||||
|
{
|
||||||
|
return makeNull ? NULL : "valid string";
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "null strings", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( makeString( false ) != static_cast<char*>(NULL));
|
||||||
|
REQUIRE( makeString( true ) == static_cast<char*>(NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool testCheckedIf( bool flag )
|
||||||
|
{
|
||||||
|
CHECKED_IF( flag )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "checkedIf", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( testCheckedIf( true ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "checkedIf, failing", "[failing][.]" )
|
||||||
|
{
|
||||||
|
REQUIRE( testCheckedIf( false ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool testCheckedElse( bool flag )
|
||||||
|
{
|
||||||
|
CHECKED_ELSE( flag )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "checkedElse", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( testCheckedElse( true ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "checkedElse, failing", "[failing][.]" )
|
||||||
|
{
|
||||||
|
REQUIRE( testCheckedElse( false ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "xmlentitycheck", "" )
|
||||||
|
{
|
||||||
|
SECTION( "embedded xml", "<test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" )
|
||||||
|
{
|
||||||
|
// No test
|
||||||
|
}
|
||||||
|
SECTION( "encoded chars", "these should all be encoded: &&&\"\"\"<<<&\"<<&\"" )
|
||||||
|
{
|
||||||
|
// No test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "send a single char to INFO", "[failing][.]" )
|
||||||
|
{
|
||||||
|
INFO(3);
|
||||||
|
REQUIRE(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "atomic if", "[failing][0]")
|
||||||
|
{
|
||||||
|
size_t x = 0;
|
||||||
|
|
||||||
|
if( x )
|
||||||
|
REQUIRE(x > 0);
|
||||||
|
else
|
||||||
|
REQUIRE(x == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* testStringForMatching()
|
||||||
|
{
|
||||||
|
return "this string contains 'abc' as a substring";
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("String matchers", "[matchers]" )
|
||||||
|
{
|
||||||
|
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );
|
||||||
|
CHECK_THAT( testStringForMatching(), Contains( "abc" ) );
|
||||||
|
|
||||||
|
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) );
|
||||||
|
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Contains string matcher", "[.][failing][matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), Contains( "not there" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("StartsWith string matcher", "[.][failing][matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("EndsWith string matcher", "[.][failing][matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
||||||
|
}
|
||||||
|
TEST_CASE("Equals string matcher, with NULL", "[matchers]")
|
||||||
|
{
|
||||||
|
REQUIRE_THAT("", Equals(NULL));
|
||||||
|
}
|
||||||
|
TEST_CASE("AllOf matcher", "[matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
|
||||||
|
}
|
||||||
|
TEST_CASE("AnyOf matcher", "[matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) );
|
||||||
|
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Equals", "[matchers]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned int Factorial( unsigned int number )
|
||||||
|
{
|
||||||
|
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||||
|
return number > 1 ? Factorial(number-1)*number : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
||||||
|
REQUIRE( Factorial(0) == 1 );
|
||||||
|
REQUIRE( Factorial(1) == 1 );
|
||||||
|
REQUIRE( Factorial(2) == 2 );
|
||||||
|
REQUIRE( Factorial(3) == 6 );
|
||||||
|
REQUIRE( Factorial(10) == 3628800 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "An empty test with no assertions", "[empty]" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Nice descriptive name", "[tag1][tag2][tag3][.]" )
|
||||||
|
{
|
||||||
|
WARN( "This one ran" );
|
||||||
|
}
|
||||||
|
TEST_CASE( "first tag", "[tag1]" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TEST_CASE( "second tag", "[tag2]" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//TEST_CASE( "spawn a new process", "[.]" )
|
||||||
|
//{
|
||||||
|
// // !TBD Work in progress
|
||||||
|
// char line[200];
|
||||||
|
// FILE* output = popen("./CatchSelfTest ./failing/matchers/StartsWith", "r");
|
||||||
|
// while ( fgets(line, 199, output) )
|
||||||
|
// std::cout << line;
|
||||||
|
//}
|
||||||
|
|
||||||
|
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
||||||
|
|
||||||
|
std::vector<int> v( 5 );
|
||||||
|
|
||||||
|
REQUIRE( v.size() == 5 );
|
||||||
|
REQUIRE( v.capacity() >= 5 );
|
||||||
|
|
||||||
|
SECTION( "resizing bigger changes size and capacity", "" ) {
|
||||||
|
v.resize( 10 );
|
||||||
|
|
||||||
|
REQUIRE( v.size() == 10 );
|
||||||
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
}
|
||||||
|
SECTION( "resizing smaller changes size but not capacity", "" ) {
|
||||||
|
v.resize( 0 );
|
||||||
|
|
||||||
|
REQUIRE( v.size() == 0 );
|
||||||
|
REQUIRE( v.capacity() >= 5 );
|
||||||
|
|
||||||
|
SECTION( "We can use the 'swap trick' to reset the capacity", "" ) {
|
||||||
|
std::vector<int> empty;
|
||||||
|
empty.swap( v );
|
||||||
|
|
||||||
|
REQUIRE( v.capacity() == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SECTION( "reserving bigger changes capacity but not size", "" ) {
|
||||||
|
v.reserve( 10 );
|
||||||
|
|
||||||
|
REQUIRE( v.size() == 5 );
|
||||||
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
}
|
||||||
|
SECTION( "reserving smaller does not change size or capacity", "" ) {
|
||||||
|
v.reserve( 0 );
|
||||||
|
|
||||||
|
REQUIRE( v.size() == 5 );
|
||||||
|
REQUIRE( v.capacity() >= 5 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/philsquared/Catch/issues/166
|
||||||
|
TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]")
|
||||||
|
{
|
||||||
|
SECTION("Outer", "")
|
||||||
|
SECTION("Inner", "")
|
||||||
|
SUCCEED("that's not flying - that's failing in style");
|
||||||
|
|
||||||
|
FAIL("to infinity and beyond");
|
||||||
|
}
|
||||||
|
}
|
53
single_include_projects/SelfTest/RunAllTests.cpp
Normal file
53
single_include_projects/SelfTest/RunAllTests.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
#include "../../include/internal/catch_text.h"
|
||||||
|
#include "../../include/internal/catch_console_colour.hpp"
|
||||||
|
|
||||||
|
namespace AllTestsRunner {
|
||||||
|
|
||||||
|
// VS2010
|
||||||
|
// mstest /TestContainer:Debug\ManagedTestCatch.dll /category:"all"
|
||||||
|
//
|
||||||
|
// VS2012 managed
|
||||||
|
// vstest.console.exe /Logger:Trx Debug\ManagedTestCatch.dll /TestCaseFilter:"TestCategory=all"
|
||||||
|
//
|
||||||
|
// VS2012 native
|
||||||
|
// vstest.console.exe /Logger:Trx Debug\NativeTestCatch.dll /TestCaseFilter:"Owner=all"
|
||||||
|
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||||
|
CATCH_MAP_CATEGORY_TO_TAG(all, "~[vs]");
|
||||||
|
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
|
||||||
|
CATCH_MAP_CATEGORY_TO_TAG(allSucceeding, "~[vs]");
|
||||||
|
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
|
||||||
|
CATCH_CONFIG_ABORT_AFTER(4)
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Some simple comparisons between doubles")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with different epsilons")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with floats")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with ints")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with mixed numeric types")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Use a custom approx")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate PI")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("A METHOD_AS_TEST_CASE based test run that succeeds")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("A METHOD_AS_TEST_CASE based test run that fails")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("A TEST_CASE_METHOD based test run that succeeds")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("A TEST_CASE_METHOD based test run that fails")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Equality checks that should succeed")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Equality checks that should fail]")
|
||||||
|
INTERNAL_CATCH_MAP_CATEGORY_TO_LIST(allSucceedingAborting);
|
||||||
|
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Output from all sections is reported")
|
||||||
|
CATCH_INTERNAL_CONFIG_ADD_TEST("Standard output from all sections is reported")
|
||||||
|
INTERNAL_CATCH_MAP_CATEGORY_TO_LIST(OutputFromAllSectionsIsReported);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
164
single_include_projects/SelfTest/SectionTrackerTests.cpp
Normal file
164
single_include_projects/SelfTest/SectionTrackerTests.cpp
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 20/07/2013.
|
||||||
|
* Copyright 2013 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
#include "../../include/internal/catch_test_case_tracker.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE( "section tracking" ) {
|
||||||
|
|
||||||
|
using namespace Catch;
|
||||||
|
TestCaseTracker testCaseTracker( "test case" );
|
||||||
|
|
||||||
|
const std::string section1Name = "section 1";
|
||||||
|
const std::string section2Name = "section 2";
|
||||||
|
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
SECTION( "test case with no sections" ) {
|
||||||
|
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
}
|
||||||
|
CHECK( testCaseTracker.isCompleted() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "test case with one section" ) {
|
||||||
|
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// Leave test case - incomplete (still need to visit section)
|
||||||
|
}
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Enter test case again
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section? - yes
|
||||||
|
CHECK( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Leave section and test case - now complete
|
||||||
|
testCaseTracker.leaveSection();
|
||||||
|
}
|
||||||
|
CHECK( testCaseTracker.isCompleted() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "test case with two consecutive sections" ) {
|
||||||
|
|
||||||
|
// Enter test case
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Enter section 2? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section2Name ) );
|
||||||
|
|
||||||
|
// Leave test case - incomplete (still need to visit sections)
|
||||||
|
}
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Enter test case again
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - yes
|
||||||
|
CHECK( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
testCaseTracker.leaveSection();
|
||||||
|
|
||||||
|
// Enter section 2? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section2Name ) );
|
||||||
|
|
||||||
|
// Leave test case - incomplete (still need to visit section 2)
|
||||||
|
}
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Enter test case again
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - no, already done now
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Enter section 2? - yes - finally
|
||||||
|
CHECK( testCaseTracker.enterSection( section2Name ) );
|
||||||
|
testCaseTracker.leaveSection();
|
||||||
|
|
||||||
|
// Leave test case - now complete
|
||||||
|
}
|
||||||
|
CHECK( testCaseTracker.isCompleted() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "test case with one section within another" ) {
|
||||||
|
|
||||||
|
// Enter test case
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Leave test case - incomplete (still need to visit sections)
|
||||||
|
}
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Enter test case again
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - yes
|
||||||
|
CHECK( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Enter section 2? - no, not yet
|
||||||
|
CHECK_FALSE( testCaseTracker.enterSection( section2Name ) );
|
||||||
|
|
||||||
|
testCaseTracker.leaveSection(); // section 1 - incomplete (section 2)
|
||||||
|
|
||||||
|
// Leave test case - incomplete
|
||||||
|
}
|
||||||
|
CHECK_FALSE( testCaseTracker.isCompleted() );
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Enter test case again
|
||||||
|
{
|
||||||
|
TestCaseTracker::Guard guard( testCaseTracker );
|
||||||
|
|
||||||
|
// Enter section 1? - yes - so we can execute section 2
|
||||||
|
CHECK( testCaseTracker.enterSection( section1Name ) );
|
||||||
|
|
||||||
|
// Enter section 2? - yes - finally
|
||||||
|
CHECK( testCaseTracker.enterSection( section2Name ) );
|
||||||
|
testCaseTracker.leaveSection(); // section 2
|
||||||
|
testCaseTracker.leaveSection(); // section 1
|
||||||
|
|
||||||
|
// Leave test case - now complete
|
||||||
|
}
|
||||||
|
CHECK( testCaseTracker.isCompleted() );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_common.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_console_colour.hpp"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_debugger.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_interfaces_capture.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_config.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_exception.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_generators.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_interfaces_registry_hub.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_reporter.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_runner.h"
|
@ -0,0 +1 @@
|
|||||||
|
#include "catch_interfaces_testcase.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_message.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_option.hpp"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_ptr.hpp"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_stream.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_streambuf.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_tags.h"
|
@ -0,0 +1,2 @@
|
|||||||
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_xmlwriter.hpp"
|
543
single_include_projects/SelfTest/TestMain.cpp
Normal file
543
single_include_projects/SelfTest/TestMain.cpp
Normal file
@ -0,0 +1,543 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(_WINDLL)
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#endif
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<size_t size>
|
||||||
|
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||||
|
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
|
||||||
|
parser.parseInto( size, argv, config );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t size>
|
||||||
|
std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||||
|
try {
|
||||||
|
parseIntoConfig( argv, config );
|
||||||
|
FAIL( "expected exception" );
|
||||||
|
}
|
||||||
|
catch( std::exception& ex ) {
|
||||||
|
return ex.what();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
|
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||||
|
|
||||||
|
Catch::ConfigData config;
|
||||||
|
|
||||||
|
SECTION( "default - no arguments", "" ) {
|
||||||
|
const char* argv[] = { "test" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
CHECK( config.shouldDebugBreak == false );
|
||||||
|
CHECK( config.abortAfter == -1 );
|
||||||
|
CHECK( config.noThrow == false );
|
||||||
|
CHECK( config.reporterName.empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "test lists", "" ) {
|
||||||
|
SECTION( "1 test", "Specify one test case using" ) {
|
||||||
|
const char* argv[] = { "test", "test1" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
Catch::Config cfg( config );
|
||||||
|
REQUIRE( cfg.filters().size() == 1 );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||||
|
}
|
||||||
|
SECTION( "Specify one test case exclusion using exclude:", "" ) {
|
||||||
|
const char* argv[] = { "test", "exclude:test1" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
Catch::Config cfg( config );
|
||||||
|
REQUIRE( cfg.filters().size() == 1 );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "Specify one test case exclusion using ~", "" ) {
|
||||||
|
const char* argv[] = { "test", "~test1" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
Catch::Config cfg( config );
|
||||||
|
REQUIRE( cfg.filters().size() == 1 );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "Specify two test cases using -t", "" ) {
|
||||||
|
const char* argv[] = { "test", "-t", "test1", "test2" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
Catch::Config cfg( config );
|
||||||
|
REQUIRE( cfg.filters().size() == 1 );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||||
|
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test2" ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "reporter", "" ) {
|
||||||
|
SECTION( "-r/console", "" ) {
|
||||||
|
const char* argv[] = { "test", "-r", "console" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.reporterName == "console" );
|
||||||
|
}
|
||||||
|
SECTION( "-r/xml", "" ) {
|
||||||
|
const char* argv[] = { "test", "-r", "xml" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.reporterName == "xml" );
|
||||||
|
}
|
||||||
|
SECTION( "--reporter/junit", "" ) {
|
||||||
|
const char* argv[] = { "test", "--reporter", "junit" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.reporterName == "junit" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "debugger", "" ) {
|
||||||
|
SECTION( "-b", "" ) {
|
||||||
|
const char* argv[] = { "test", "-b" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.shouldDebugBreak == true );
|
||||||
|
}
|
||||||
|
SECTION( "--break", "" ) {
|
||||||
|
const char* argv[] = { "test", "--break" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.shouldDebugBreak );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "abort", "" ) {
|
||||||
|
SECTION( "-a aborts after first failure", "" ) {
|
||||||
|
const char* argv[] = { "test", "-a" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.abortAfter == 1 );
|
||||||
|
}
|
||||||
|
SECTION( "-x 2 aborts after two failures", "" ) {
|
||||||
|
const char* argv[] = { "test", "-x", "2" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.abortAfter == 2 );
|
||||||
|
}
|
||||||
|
SECTION( "-x must be greater than zero", "" ) {
|
||||||
|
const char* argv[] = { "test", "-x", "0" };
|
||||||
|
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" ) );
|
||||||
|
}
|
||||||
|
SECTION( "-x must be numeric", "" ) {
|
||||||
|
const char* argv[] = { "test", "-x", "oops" };
|
||||||
|
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "nothrow", "" ) {
|
||||||
|
SECTION( "-e", "" ) {
|
||||||
|
const char* argv[] = { "test", "-e" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.noThrow == true );
|
||||||
|
}
|
||||||
|
SECTION( "--nothrow", "" ) {
|
||||||
|
const char* argv[] = { "test", "--nothrow" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.noThrow == true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "output filename", "" ) {
|
||||||
|
SECTION( "-o filename", "" ) {
|
||||||
|
const char* argv[] = { "test", "-o", "filename.ext" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.outputFilename == "filename.ext" );
|
||||||
|
}
|
||||||
|
SECTION( "--out", "" ) {
|
||||||
|
const char* argv[] = { "test", "--out", "filename.ext" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.outputFilename == "filename.ext" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "combinations", "" ) {
|
||||||
|
SECTION( "Single character flags can be combined", "" ) {
|
||||||
|
const char* argv[] = { "test", "-abe" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
CHECK( config.abortAfter == 1 );
|
||||||
|
CHECK( config.shouldDebugBreak );
|
||||||
|
CHECK( config.noThrow == true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "selftest/test filter", "Individual filters" ) {
|
||||||
|
|
||||||
|
Catch::TestCaseFilter matchAny( "*" );
|
||||||
|
Catch::TestCaseFilter matchNone( "*", Catch::IfFilterMatches::ExcludeTests );
|
||||||
|
CHECK( matchAny.shouldInclude( fakeTestCase( "any" ) ));
|
||||||
|
CHECK( matchNone.shouldInclude( fakeTestCase( "any" ) ) == false );
|
||||||
|
|
||||||
|
Catch::TestCaseFilter matchHidden( "./*" );
|
||||||
|
Catch::TestCaseFilter matchNonHidden( "./*", Catch::IfFilterMatches::ExcludeTests );
|
||||||
|
|
||||||
|
CHECK( matchHidden.shouldInclude( fakeTestCase( "any" ) ) == false );
|
||||||
|
CHECK( matchNonHidden.shouldInclude( fakeTestCase( "any" ) ) );
|
||||||
|
|
||||||
|
CHECK( matchHidden.shouldInclude( fakeTestCase( "./any" ) ) );
|
||||||
|
CHECK( matchNonHidden.shouldInclude( fakeTestCase( "./any" ) ) == false );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "selftest/test filters", "Sets of filters" ) {
|
||||||
|
|
||||||
|
Catch::TestCaseFilter matchHidden( "./*" );
|
||||||
|
Catch::TestCaseFilter dontMatchA( "./a*", Catch::IfFilterMatches::ExcludeTests );
|
||||||
|
Catch::TestCaseFilters filters( "" );
|
||||||
|
filters.addFilter( matchHidden );
|
||||||
|
filters.addFilter( dontMatchA );
|
||||||
|
|
||||||
|
CHECK( matchHidden.shouldInclude( fakeTestCase( "./something" ) ) );
|
||||||
|
|
||||||
|
CHECK( filters.shouldInclude( fakeTestCase( "any" ) ) == false );
|
||||||
|
CHECK( filters.shouldInclude( fakeTestCase( "./something" ) ) );
|
||||||
|
CHECK( filters.shouldInclude( fakeTestCase( "./anything" ) ) == false );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "selftest/filter/prefix wildcard", "Individual filters with wildcards at the start" ) {
|
||||||
|
Catch::TestCaseFilter matchBadgers( "*badger" );
|
||||||
|
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "big badger" ) ));
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "little badgers" ) ) == false );
|
||||||
|
}
|
||||||
|
TEST_CASE( "selftest/filter/wildcard at both ends", "Individual filters with wildcards at both ends" ) {
|
||||||
|
Catch::TestCaseFilter matchBadgers( "*badger*" );
|
||||||
|
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "big badger" ) ));
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "little badgers" ) ) );
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "badgers are big" ) ) );
|
||||||
|
CHECK( matchBadgers.shouldInclude( fakeTestCase( "hedgehogs" ) ) == false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<size_t size>
|
||||||
|
int getArgc( const char * (&)[size] ) {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "selftest/tags", "[tags]" ) {
|
||||||
|
|
||||||
|
std::string p1 = "[one]";
|
||||||
|
std::string p2 = "[one],[two]";
|
||||||
|
std::string p3 = "[one][two]";
|
||||||
|
std::string p4 = "[one][two],[three]";
|
||||||
|
std::string p5 = "[one][two]~[.],[three]";
|
||||||
|
|
||||||
|
SECTION( "single [one] tag", "" ) {
|
||||||
|
Catch::TestCase oneTag = makeTestCase( NULL, "", "test", "[one]", CATCH_INTERNAL_LINEINFO );
|
||||||
|
|
||||||
|
CHECK( oneTag.getTestCaseInfo().description == "" );
|
||||||
|
CHECK( oneTag.hasTag( "one" ) );
|
||||||
|
CHECK( oneTag.getTags().size() == 1 );
|
||||||
|
|
||||||
|
CHECK( oneTag.matchesTags( p1 ) == true );
|
||||||
|
CHECK( oneTag.matchesTags( p2 ) == true );
|
||||||
|
CHECK( oneTag.matchesTags( p3 ) == false );
|
||||||
|
CHECK( oneTag.matchesTags( p4 ) == false );
|
||||||
|
CHECK( oneTag.matchesTags( p5 ) == false );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "single [two] tag", "" ) {
|
||||||
|
Catch::TestCase oneTag = makeTestCase( NULL, "", "test", "[two]", CATCH_INTERNAL_LINEINFO );
|
||||||
|
|
||||||
|
CHECK( oneTag.getTestCaseInfo().description == "" );
|
||||||
|
CHECK( oneTag.hasTag( "two" ) );
|
||||||
|
CHECK( oneTag.getTags().size() == 1 );
|
||||||
|
|
||||||
|
CHECK( oneTag.matchesTags( p1 ) == false );
|
||||||
|
CHECK( oneTag.matchesTags( p2 ) == true );
|
||||||
|
CHECK( oneTag.matchesTags( p3 ) == false );
|
||||||
|
CHECK( oneTag.matchesTags( p4 ) == false );
|
||||||
|
CHECK( oneTag.matchesTags( p5 ) == false );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "two tags", "" ) {
|
||||||
|
Catch::TestCase twoTags= makeTestCase( NULL, "", "test", "[one][two]", CATCH_INTERNAL_LINEINFO );
|
||||||
|
|
||||||
|
CHECK( twoTags.getTestCaseInfo().description == "" );
|
||||||
|
CHECK( twoTags.hasTag( "one" ) );
|
||||||
|
CHECK( twoTags.hasTag( "two" ) );
|
||||||
|
CHECK( twoTags.hasTag( "Two" ) );
|
||||||
|
CHECK( twoTags.hasTag( "three" ) == false );
|
||||||
|
CHECK( twoTags.getTags().size() == 2 );
|
||||||
|
|
||||||
|
CHECK( twoTags.matchesTags( p1 ) == true );
|
||||||
|
CHECK( twoTags.matchesTags( p2 ) == true );
|
||||||
|
CHECK( twoTags.matchesTags( p3 ) == true );
|
||||||
|
CHECK( twoTags.matchesTags( p4 ) == true );
|
||||||
|
CHECK( twoTags.matchesTags( p5 ) == true );
|
||||||
|
}
|
||||||
|
SECTION( "complex", "" ) {
|
||||||
|
CHECK( fakeTestCase( "test", "[one][.]" ).matchesTags( p1 ) );
|
||||||
|
CHECK_FALSE( fakeTestCase( "test", "[one][.]" ).matchesTags( p5 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( p4 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( p5 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( "[three]~[one]" ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[unit][not_apple]" ).matchesTags( "[unit]" ) );
|
||||||
|
CHECK_FALSE( fakeTestCase( "test", "[unit][not_apple]" ).matchesTags( "[unit]~[not_apple]" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "one tag with characters either side", "" ) {
|
||||||
|
|
||||||
|
Catch::TestCase oneTagWithExtras = makeTestCase( NULL, "", "test", "12[one]34", CATCH_INTERNAL_LINEINFO );
|
||||||
|
CHECK( oneTagWithExtras.getTestCaseInfo().description == "1234" );
|
||||||
|
CHECK( oneTagWithExtras.hasTag( "one" ) );
|
||||||
|
CHECK( oneTagWithExtras.hasTag( "two" ) == false );
|
||||||
|
CHECK( oneTagWithExtras.getTags().size() == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "start of a tag, but not closed", "" ) {
|
||||||
|
|
||||||
|
Catch::TestCase oneTagOpen = makeTestCase( NULL, "", "test", "[one", CATCH_INTERNAL_LINEINFO );
|
||||||
|
|
||||||
|
CHECK( oneTagOpen.getTestCaseInfo().description == "[one" );
|
||||||
|
CHECK( oneTagOpen.hasTag( "one" ) == false );
|
||||||
|
CHECK( oneTagOpen.getTags().size() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "hidden", "" ) {
|
||||||
|
Catch::TestCase oneTag = makeTestCase( NULL, "", "test", "[.]", CATCH_INTERNAL_LINEINFO );
|
||||||
|
|
||||||
|
CHECK( oneTag.getTestCaseInfo().description == "" );
|
||||||
|
CHECK( oneTag.hasTag( "." ) );
|
||||||
|
CHECK( oneTag.isHidden() );
|
||||||
|
|
||||||
|
CHECK( oneTag.matchesTags( "~[.]" ) == false );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Long strings can be wrapped", "[wrap]" ) {
|
||||||
|
|
||||||
|
using namespace Catch;
|
||||||
|
SECTION( "plain string", "" ) {
|
||||||
|
// guide: 123456789012345678
|
||||||
|
std::string testString = "one two three four";
|
||||||
|
|
||||||
|
SECTION( "No wrapping", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
||||||
|
}
|
||||||
|
SECTION( "Wrapped once", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" );
|
||||||
|
}
|
||||||
|
SECTION( "Wrapped twice", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
}
|
||||||
|
SECTION( "Wrapped three times", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" );
|
||||||
|
}
|
||||||
|
SECTION( "Short wrap", "" ) {
|
||||||
|
CHECK( Catch::Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" );
|
||||||
|
CHECK( Catch::Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" );
|
||||||
|
CHECK( Catch::Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" );
|
||||||
|
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" );
|
||||||
|
}
|
||||||
|
SECTION( "As container", "" ) {
|
||||||
|
Catch::Text text( testString, TextAttributes().setWidth( 6 ) );
|
||||||
|
REQUIRE( text.size() == 4 );
|
||||||
|
CHECK( text[0] == "one" );
|
||||||
|
CHECK( text[1] == "two" );
|
||||||
|
CHECK( text[2] == "three" );
|
||||||
|
CHECK( text[3] == "four" );
|
||||||
|
}
|
||||||
|
SECTION( "Indent first line differently", "" ) {
|
||||||
|
Catch::Text text( testString, TextAttributes()
|
||||||
|
.setWidth( 10 )
|
||||||
|
.setIndent( 4 )
|
||||||
|
.setInitialIndent( 1 ) );
|
||||||
|
CHECK( text.toString() == " one two\n three\n four" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "With newlines", "" ) {
|
||||||
|
|
||||||
|
// guide: 1234567890123456789
|
||||||
|
std::string testString = "one two\nthree four";
|
||||||
|
|
||||||
|
SECTION( "No wrapping" , "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString );
|
||||||
|
}
|
||||||
|
SECTION( "Trailing newline" , "" ) {
|
||||||
|
CHECK( Catch::Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef\n" );
|
||||||
|
CHECK( Catch::Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" );
|
||||||
|
CHECK( Catch::Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef\n" );
|
||||||
|
}
|
||||||
|
SECTION( "Wrapped once", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" );
|
||||||
|
}
|
||||||
|
SECTION( "Wrapped twice", "" ) {
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "With tabs", "" ) {
|
||||||
|
|
||||||
|
// guide: 1234567890123456789
|
||||||
|
std::string testString = "one two \tthree four five six";
|
||||||
|
|
||||||
|
CHECK( Catch::Text( testString, TextAttributes().setWidth( 15 ) ).toString()
|
||||||
|
== "one two three\n four\n five\n six" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Catch;
|
||||||
|
|
||||||
|
class ColourString {
|
||||||
|
public:
|
||||||
|
|
||||||
|
struct ColourIndex {
|
||||||
|
ColourIndex( Colour::Code _colour, std::size_t _fromIndex, std::size_t _toIndex )
|
||||||
|
: colour( _colour ),
|
||||||
|
fromIndex( _fromIndex ),
|
||||||
|
toIndex( _toIndex )
|
||||||
|
{}
|
||||||
|
|
||||||
|
Colour::Code colour;
|
||||||
|
std::size_t fromIndex;
|
||||||
|
std::size_t toIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
ColourString( std::string const& _string )
|
||||||
|
: string( _string )
|
||||||
|
{}
|
||||||
|
ColourString( std::string const& _string, std::vector<ColourIndex> const& _colours )
|
||||||
|
: string( _string ), colours( _colours )
|
||||||
|
{}
|
||||||
|
|
||||||
|
ColourString& addColour( Colour::Code colour, int _index ) {
|
||||||
|
colours.push_back( ColourIndex( colour,
|
||||||
|
resolveRelativeIndex( _index ),
|
||||||
|
resolveRelativeIndex( _index )+1 ) );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ColourString& addColour( Colour::Code colour, int _fromIndex, int _toIndex ) {
|
||||||
|
colours.push_back( ColourIndex( colour,
|
||||||
|
resolveRelativeIndex(_fromIndex),
|
||||||
|
resolveLastRelativeIndex( _toIndex ) ) );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeToStream( std::ostream& _stream ) const {
|
||||||
|
std::size_t last = 0;
|
||||||
|
for( std::size_t i = 0; i < colours.size(); ++i ) {
|
||||||
|
ColourIndex const& index = colours[i];
|
||||||
|
if( index.fromIndex > last )
|
||||||
|
_stream << string.substr( last, index.fromIndex-last );
|
||||||
|
{
|
||||||
|
Colour colourGuard( index.colour );
|
||||||
|
_stream << string.substr( index.fromIndex, index.toIndex-index.fromIndex );
|
||||||
|
}
|
||||||
|
last = index.toIndex;
|
||||||
|
}
|
||||||
|
if( last < string.size() )
|
||||||
|
_stream << string.substr( last );
|
||||||
|
}
|
||||||
|
friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) {
|
||||||
|
_colourString.writeToStream( _stream );
|
||||||
|
return _stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::size_t resolveLastRelativeIndex( int _index ) {
|
||||||
|
std::size_t index = resolveRelativeIndex( _index );
|
||||||
|
return index == 0 ? string.size() : index;
|
||||||
|
}
|
||||||
|
std::size_t resolveRelativeIndex( int _index ) {
|
||||||
|
return static_cast<std::size_t>( _index >= 0
|
||||||
|
? _index
|
||||||
|
: static_cast<int>( string.size() )+_index );
|
||||||
|
}
|
||||||
|
std::string string;
|
||||||
|
std::vector<ColourIndex> colours;
|
||||||
|
};
|
||||||
|
|
||||||
|
// !TBD: This will be folded into Text class
|
||||||
|
TEST_CASE( "Strings can be rendered with colour", "[colour]" ) {
|
||||||
|
|
||||||
|
{
|
||||||
|
ColourString cs( "hello" );
|
||||||
|
cs .addColour( Colour::Red, 0 )
|
||||||
|
.addColour( Colour::Green, -1 );
|
||||||
|
|
||||||
|
std::cout << cs << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ColourString cs( "hello" );
|
||||||
|
cs .addColour( Colour::Blue, 1, -2 );
|
||||||
|
|
||||||
|
std::cout << cs << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Text can be formatted using the Text class", "" ) {
|
||||||
|
|
||||||
|
CHECK( Catch::Text( "hi there" ).toString() == "hi there" );
|
||||||
|
|
||||||
|
TextAttributes narrow;
|
||||||
|
narrow.setWidth( 6 );
|
||||||
|
|
||||||
|
CHECK( Catch::Text( "hi there", narrow ).toString() == "hi\nthere" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Long text is truncted", "[Text][Truncated]" ) {
|
||||||
|
|
||||||
|
std::string longLine( 90, '*' );
|
||||||
|
|
||||||
|
std::ostringstream oss;
|
||||||
|
for(int i = 0; i < 600; ++i )
|
||||||
|
oss << longLine << longLine << "\n";
|
||||||
|
Catch::Text t( oss.str() );
|
||||||
|
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
|
||||||
|
|
||||||
|
}
|
402
single_include_projects/SelfTest/TrickyTests.cpp
Normal file
402
single_include_projects/SelfTest/TrickyTests.cpp
Normal file
@ -0,0 +1,402 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 09/11/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
namespace Catch
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
std::string toString<std::pair<int, int> >( const std::pair<int, int>& value )
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "std::pair( " << value.first << ", " << value.second << " )";
|
||||||
|
return oss.str();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace TrickyTests
|
||||||
|
{
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Parsing a std::pair",
|
||||||
|
"[Tricky][std::pair]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::pair<int, int> aNicePair( 1, 2 );
|
||||||
|
|
||||||
|
REQUIRE( (std::pair<int, int>( 1, 2 )) == aNicePair );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Where the is more to the expression after the RHS[failing]",
|
||||||
|
"[Tricky][failing][.]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// int a = 1, b = 2;
|
||||||
|
// REQUIRE( a == 2 || b == 2 );
|
||||||
|
WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" );
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Where the LHS is not a simple value[failing]",
|
||||||
|
"[Tricky][failing][.]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
int a = 1;
|
||||||
|
int b = 2;
|
||||||
|
|
||||||
|
// This only captures part of the expression, but issues a warning about the rest
|
||||||
|
REQUIRE( a+1 == b-1 );
|
||||||
|
*/
|
||||||
|
WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Opaque
|
||||||
|
{
|
||||||
|
int val;
|
||||||
|
bool operator ==( const Opaque& o ) const
|
||||||
|
{
|
||||||
|
return val == o.val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"A failing expression with a non streamable type is still captured[failing]",
|
||||||
|
"[Tricky][failing][.]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
Opaque o1, o2;
|
||||||
|
o1.val = 7;
|
||||||
|
o2.val = 8;
|
||||||
|
|
||||||
|
CHECK( &o1 == &o2 );
|
||||||
|
CHECK( o1 == o2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"string literals of different sizes can be compared[failing]",
|
||||||
|
"[Tricky][failing][.]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
REQUIRE( std::string( "first" ) == "second" );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"An expression with side-effects should only be evaluated once",
|
||||||
|
"[Tricky]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i = 7;
|
||||||
|
|
||||||
|
REQUIRE( i++ == 7 );
|
||||||
|
REQUIRE( i++ == 8 );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace A {
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
X() : a(4), b(2), c(7) {}
|
||||||
|
X(int v) : a(v), b(2), c(7) {}
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int c;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace B {
|
||||||
|
struct Y
|
||||||
|
{
|
||||||
|
Y() : a(4), b(2), c(7) {}
|
||||||
|
Y(int v) : a(v), b(2), c(7) {}
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int c;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const A::X& lhs, const B::Y& rhs)
|
||||||
|
{
|
||||||
|
return (lhs.a == rhs.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const B::Y& lhs, const A::X& rhs)
|
||||||
|
{
|
||||||
|
return (lhs.a == rhs.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/* This, currently, does not compile with LLVM
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Operators at different namespace levels not hijacked by Koenig lookup"
|
||||||
|
"[Tricky]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
A::X x;
|
||||||
|
B::Y y;
|
||||||
|
REQUIRE( x == y );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ObjectWithConversions
|
||||||
|
{
|
||||||
|
struct Object
|
||||||
|
{
|
||||||
|
operator unsigned int() {return 0xc0000000;}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
TEST_CASE
|
||||||
|
(
|
||||||
|
"Operators at different namespace levels not hijacked by Koenig lookup",
|
||||||
|
"[Tricky]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Object o;
|
||||||
|
REQUIRE(0xc0000000 == o );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ObjectWithNonConstEqualityOperator
|
||||||
|
{
|
||||||
|
struct Test
|
||||||
|
{
|
||||||
|
Test( unsigned int v )
|
||||||
|
: m_value(v)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool operator==( const Test&rhs )
|
||||||
|
{
|
||||||
|
return (m_value == rhs.m_value);
|
||||||
|
}
|
||||||
|
bool operator==( const Test&rhs ) const
|
||||||
|
{
|
||||||
|
return (m_value != rhs.m_value);
|
||||||
|
}
|
||||||
|
unsigned int m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" )
|
||||||
|
{
|
||||||
|
Test t( 1 );
|
||||||
|
REQUIRE( t == 1u );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace TrickyTests
|
||||||
|
{
|
||||||
|
namespace EnumBitFieldTests
|
||||||
|
{
|
||||||
|
enum Bits {bit0 = 0x0001, bit1 = 0x0002, bit2 = 0x0004, bit3 = 0x0008, bit1and2 = 0x0006,
|
||||||
|
bit30 = 0x40000000, bit31 = 0x80000000,
|
||||||
|
bit30and31 = 0xc0000000};
|
||||||
|
|
||||||
|
TEST_CASE( "Test enum bit values", "[Tricky]" )
|
||||||
|
{
|
||||||
|
REQUIRE( 0xc0000000 == bit30and31 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Obj
|
||||||
|
{
|
||||||
|
Obj():prop(&p){}
|
||||||
|
|
||||||
|
int p;
|
||||||
|
int* prop;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("boolean member", "[Tricky]")
|
||||||
|
{
|
||||||
|
Obj obj;
|
||||||
|
REQUIRE( obj.prop != NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests for a problem submitted by Ralph McArdell
|
||||||
|
//
|
||||||
|
// The static bool value should not need to be defined outside the
|
||||||
|
// struct it is declared in - but when evaluating it in a deduced
|
||||||
|
// context it appears to require the extra definition.
|
||||||
|
// The issue was fixed by adding bool overloads to bypass the
|
||||||
|
// templates that were there to deduce it.
|
||||||
|
template <bool B>
|
||||||
|
struct is_true
|
||||||
|
{
|
||||||
|
static const bool value = B;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE( "(unimplemented) static bools can be evaluated", "[Tricky]" )
|
||||||
|
{
|
||||||
|
SECTION("compare to true","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<true>::value == true );
|
||||||
|
REQUIRE( true == is_true<true>::value );
|
||||||
|
}
|
||||||
|
SECTION("compare to false","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<false>::value == false );
|
||||||
|
REQUIRE( false == is_true<false>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("negation", "")
|
||||||
|
{
|
||||||
|
REQUIRE( !is_true<false>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("double negation","")
|
||||||
|
{
|
||||||
|
REQUIRE( !!is_true<true>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("direct","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<true>::value );
|
||||||
|
REQUIRE_FALSE( is_true<false>::value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncomment these tests to produce an error at test registration time
|
||||||
|
/*
|
||||||
|
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct Boolable
|
||||||
|
{
|
||||||
|
explicit Boolable( bool value ) : m_value( value ) {}
|
||||||
|
|
||||||
|
operator Catch::SafeBool::type() const {
|
||||||
|
return Catch::SafeBool::makeSafe( m_value );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE( "Objects that evaluated in boolean contexts can be checked", "[Tricky][SafeBool]" )
|
||||||
|
{
|
||||||
|
Boolable True( true );
|
||||||
|
Boolable False( false );
|
||||||
|
|
||||||
|
CHECK( True );
|
||||||
|
CHECK( !False );
|
||||||
|
CHECK_FALSE( False );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Assertions then sections", "[Tricky]" )
|
||||||
|
{
|
||||||
|
// This was causing a failure due to the way the console reporter was handling
|
||||||
|
// the current section
|
||||||
|
|
||||||
|
REQUIRE( Catch::isTrue( true ) );
|
||||||
|
|
||||||
|
SECTION( "A section", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( Catch::isTrue( true ) );
|
||||||
|
|
||||||
|
SECTION( "Another section", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( Catch::isTrue( true ) );
|
||||||
|
}
|
||||||
|
SECTION( "Another other section", "" )
|
||||||
|
{
|
||||||
|
REQUIRE( Catch::isTrue( true ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Awkward
|
||||||
|
{
|
||||||
|
operator int() const { return 7; }
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE( "non streamable - with conv. op", "[Tricky]" )
|
||||||
|
{
|
||||||
|
Awkward awkward;
|
||||||
|
std::string s = Catch::toString( awkward );
|
||||||
|
REQUIRE( s == "7" );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void foo() {}
|
||||||
|
|
||||||
|
typedef void (*fooptr_t)();
|
||||||
|
|
||||||
|
TEST_CASE( "Comparing function pointers", "[Tricky][function pointer]" )
|
||||||
|
{
|
||||||
|
// This was giving a warning in VS2010
|
||||||
|
// #179
|
||||||
|
fooptr_t a = foo;
|
||||||
|
|
||||||
|
REQUIRE( a );
|
||||||
|
REQUIRE( a == &foo );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
void f() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE( "Comparing member function pointers", "[Tricky][member function pointer]" )
|
||||||
|
{
|
||||||
|
typedef void (S::*MF)();
|
||||||
|
MF m = &S::f;
|
||||||
|
|
||||||
|
CHECK( m == &S::f );
|
||||||
|
}
|
||||||
|
|
||||||
|
class ClassName {};
|
||||||
|
|
||||||
|
TEST_CASE( "pointer to class", "[Tricky]" )
|
||||||
|
{
|
||||||
|
ClassName *p = 0;
|
||||||
|
REQUIRE( p == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
TEST_CASE( "null_ptr", "[Tricky]" )
|
||||||
|
{
|
||||||
|
std::unique_ptr<int> ptr;
|
||||||
|
REQUIRE(ptr.get() == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE( "X/level/0/a", "[Tricky]" ) { SUCCEED(""); }
|
||||||
|
TEST_CASE( "X/level/0/b", "[Tricky][fizz]" ){ SUCCEED(""); }
|
||||||
|
TEST_CASE( "X/level/1/a", "[Tricky]" ) { SUCCEED(""); }
|
||||||
|
TEST_CASE( "X/level/1/b", "[Tricky]" ) { SUCCEED(""); }
|
||||||
|
}
|
34
single_include_projects/SelfTest/VariadicMacrosTests.cpp
Normal file
34
single_include_projects/SelfTest/VariadicMacrosTests.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 15/03/2013.
|
||||||
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
|
|
||||||
|
namespace VariadicMacroTests
|
||||||
|
{
|
||||||
|
TEST_CASE()
|
||||||
|
{
|
||||||
|
SUCCEED( "anonymous test case" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Test case with one argument" )
|
||||||
|
{
|
||||||
|
SUCCEED( "no assertions" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Variadic macros", "[variadic][sections]" )
|
||||||
|
{
|
||||||
|
SECTION( "Section with one argument" )
|
||||||
|
{
|
||||||
|
SUCCEED( "no assertions" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
107
single_include_projects/SelfTest/VisualStudioConfigTests.cpp
Normal file
107
single_include_projects/SelfTest/VisualStudioConfigTests.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||||
|
|
||||||
|
namespace VisualStudioConfigTests
|
||||||
|
{
|
||||||
|
struct Z1 {};
|
||||||
|
TEST_CASE("VSRequire 1, initial config defaults are set", "[vs]")
|
||||||
|
{
|
||||||
|
CatchOverrides::ConfigReset<Z1> guard("VisualStudioConfigTests.cpp",0, 1);
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z1>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z1>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z1>::instance().abortAfter("VisualStudioConfigTests.cpp",0) == 1);
|
||||||
|
std::vector<std::string> tests = CatchOverrides::Config<Z1>::instance().listOfTests("VisualStudioConfigTests.cpp",0);
|
||||||
|
REQUIRE(tests.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Z2 {};
|
||||||
|
TEST_CASE("VSRequire 2, initial config defaults are overridden", "[vs]")
|
||||||
|
{
|
||||||
|
CatchOverrides::ConfigShowSuccessfulTests<Z2> isr1("VisualStudioConfigTests.cpp",0, true);
|
||||||
|
CatchOverrides::ConfigWarnMissingAssertions<Z2> wma1("VisualStudioConfigTests.cpp",0, true);
|
||||||
|
CatchOverrides::ConfigAbortAfter<Z2> aa1("VisualStudioConfigTests.cpp",0, 42);
|
||||||
|
CatchOverrides::ConfigAddTest<Z2> at1("VisualStudioConfigTests.cpp",0,"T1");
|
||||||
|
CatchOverrides::ConfigReset<Z2> guard("VisualStudioConfigTests.cpp",0, 1);
|
||||||
|
REQUIRE(CatchOverrides::Config<Z2>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z2>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z2>::instance().abortAfter("VisualStudioConfigTests.cpp",0) == 42);
|
||||||
|
std::vector<std::string> tests = CatchOverrides::Config<Z2>::instance().listOfTests("VisualStudioConfigTests.cpp",0);
|
||||||
|
REQUIRE(tests.size() == 1);
|
||||||
|
REQUIRE(tests[0] == "T1");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Z3 {};
|
||||||
|
TEST_CASE("VSRequire 3, initial config defaults are reset", "[vs]")
|
||||||
|
{
|
||||||
|
CatchOverrides::ConfigShowSuccessfulTests<Z3> isr1("VisualStudioConfigTests.cpp",0, true);
|
||||||
|
CatchOverrides::ConfigWarnMissingAssertions<Z3> wma1("VisualStudioConfigTests.cpp",0, true);
|
||||||
|
CatchOverrides::ConfigAbortAfter<Z3> aa1("VisualStudioConfigTests.cpp",0, 42);
|
||||||
|
CatchOverrides::ConfigAddTest<Z3> at1("VisualStudioConfigTests.cpp",0,"T1");
|
||||||
|
CatchOverrides::ConfigReset<Z3> guard0("VisualStudioConfigTests.cpp",0, 1);
|
||||||
|
CatchOverrides::ConfigReset<Z3> guard1("VisualStudioConfigTests.cpp",1, 1);
|
||||||
|
REQUIRE(CatchOverrides::Config<Z3>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z3>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",0));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z3>::instance().abortAfter("VisualStudioConfigTests.cpp",0) == 42);
|
||||||
|
std::vector<std::string> tests = CatchOverrides::Config<Z3>::instance().listOfTests("VisualStudioConfigTests.cpp",0);
|
||||||
|
REQUIRE(tests.size() == 1);
|
||||||
|
REQUIRE(tests[0] == "T1");
|
||||||
|
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z3>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",1));
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z3>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",1));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z3>::instance().abortAfter("VisualStudioConfigTests.cpp",1) == 1);
|
||||||
|
tests = CatchOverrides::Config<Z3>::instance().listOfTests("VisualStudioConfigTests.cpp",1);
|
||||||
|
REQUIRE(tests.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Z7 {};
|
||||||
|
TEST_CASE("VSRequire 7, initial multi-line list config gets all values", "[vs]")
|
||||||
|
{
|
||||||
|
CatchOverrides::ConfigAddTest<Z7> a1("VisualStudioConfigTests.cpp",0,"T1");
|
||||||
|
CatchOverrides::ConfigAddTest<Z7> a2("VisualStudioConfigTests.cpp",0,"T2");
|
||||||
|
CatchOverrides::ConfigAddTest<Z7> a3("VisualStudioConfigTests.cpp",0,"T3");
|
||||||
|
CatchOverrides::ConfigReset<Z7> guard0("VisualStudioConfigTests.cpp",0, 1);
|
||||||
|
CatchOverrides::ConfigReset<Z7> guard1("VisualStudioConfigTests.cpp",1, 1);
|
||||||
|
|
||||||
|
std::vector<std::string> tests = CatchOverrides::Config<Z7>::instance().listOfTests("VisualStudioConfigTests.cpp",0);
|
||||||
|
REQUIRE(tests.size() == 3);
|
||||||
|
REQUIRE(tests[0] == "T1");
|
||||||
|
REQUIRE(tests[1] == "T2");
|
||||||
|
REQUIRE(tests[2] == "T3");
|
||||||
|
tests = CatchOverrides::Config<Z7>::instance().listOfTests("VisualStudioConfigTests.cpp",1);
|
||||||
|
REQUIRE(tests.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Z8 {};
|
||||||
|
TEST_CASE("VSRequire 8, initial incrementing 'line' sets values", "[vs]")
|
||||||
|
{
|
||||||
|
CatchOverrides::ConfigShowSuccessfulTests<Z8> isr1("VisualStudioConfigTests.cpp",0, true);
|
||||||
|
CatchOverrides::ConfigWarnMissingAssertions<Z8> wma1("VisualStudioConfigTests.cpp",1, true);
|
||||||
|
CatchOverrides::ConfigAbortAfter<Z8> aa1("VisualStudioConfigTests.cpp",2, 42);
|
||||||
|
CatchOverrides::ConfigAddTest<Z8> at1("VisualStudioConfigTests.cpp",3,"T1");
|
||||||
|
CatchOverrides::ConfigReset<Z8> guard0("VisualStudioConfigTests.cpp",4, 1);
|
||||||
|
CatchOverrides::ConfigReset<Z8> guard1("VisualStudioConfigTests.cpp",5, 1);
|
||||||
|
REQUIRE(CatchOverrides::Config<Z8>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",4));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z8>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",4));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z8>::instance().abortAfter("VisualStudioConfigTests.cpp",4) == 42);
|
||||||
|
std::vector<std::string> tests = CatchOverrides::Config<Z8>::instance().listOfTests("VisualStudioConfigTests.cpp",4);
|
||||||
|
REQUIRE(tests.size() == 1);
|
||||||
|
REQUIRE(tests[0] == "T1");
|
||||||
|
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z8>::instance().includeSuccessfulResults("VisualStudioConfigTests.cpp",5));
|
||||||
|
REQUIRE(!CatchOverrides::Config<Z8>::instance().warnAboutMissingAssertions("VisualStudioConfigTests.cpp",5));
|
||||||
|
REQUIRE(CatchOverrides::Config<Z8>::instance().abortAfter("VisualStudioConfigTests.cpp",5) == 1);
|
||||||
|
tests = CatchOverrides::Config<Z8>::instance().listOfTests("VisualStudioConfigTests.cpp",5);
|
||||||
|
REQUIRE(tests.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
112
single_include_projects/SelfTest/VisualStudioTests.cpp
Normal file
112
single_include_projects/SelfTest/VisualStudioTests.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||||
|
|
||||||
|
namespace VisualStudioTests
|
||||||
|
{
|
||||||
|
class UniqueTestsFixture {
|
||||||
|
private:
|
||||||
|
static int uniqueID;
|
||||||
|
public:
|
||||||
|
UniqueTestsFixture() { }
|
||||||
|
protected:
|
||||||
|
int getID() {
|
||||||
|
return ++uniqueID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int UniqueTestsFixture::uniqueID = 0;
|
||||||
|
TEST_CASE("M00", "[m_off][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
int abortAfter = Catch::getCurrentContext().getConfig()->abortAfter();
|
||||||
|
REQUIRE(abortAfter == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
TEST_CASE("M01", "[m_on][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("M02", "[m_off][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(UniqueTestsFixture, "M10", "[m_off][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
TEST_CASE_METHOD(UniqueTestsFixture, "M11", "[m_on][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(show);
|
||||||
|
getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
TEST_CASE_METHOD(UniqueTestsFixture, "M99", "[m_on][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(show);
|
||||||
|
WARN("Warning message");
|
||||||
|
getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(UniqueTestsFixture, "M12", "[m_off][vs]")
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfigTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void run1()
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
}
|
||||||
|
void run2()
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(show);
|
||||||
|
}
|
||||||
|
void run3()
|
||||||
|
{
|
||||||
|
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
|
||||||
|
REQUIRE(!show);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
METHOD_AS_TEST_CASE(ConfigTest::run1,"M20", "[m_off][vs]");
|
||||||
|
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
METHOD_AS_TEST_CASE(ConfigTest::run2,"M21", "[m_on][vs]");
|
||||||
|
|
||||||
|
METHOD_AS_TEST_CASE(ConfigTest::run3,"M22", "[m_off][vs]");
|
||||||
|
|
||||||
|
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff, "[m_off][vs]");
|
||||||
|
CATCH_CONFIG_SHOW_SUCCESS(true)
|
||||||
|
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOn, "[m_on][vs]");
|
||||||
|
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff2, "[m_off][vs]");
|
||||||
|
}
|
||||||
|
#endif
|
625
single_include_projects/SelfTest/internal/clara.h
Normal file
625
single_include_projects/SelfTest/internal/clara.h
Normal file
@ -0,0 +1,625 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 25/05/2013.
|
||||||
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Only use header guard if we are not using an outer namespace
|
||||||
|
#ifndef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
# ifdef TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
# ifndef TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
# define TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Clara
|
||||||
|
#include "tbc_text_format.h"
|
||||||
|
#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// Use optional outer namespace
|
||||||
|
#ifdef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
namespace CLICHE_CLARA_OUTER_NAMESPACE {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Clara {
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
#ifdef CLARA_CONSOLE_WIDTH
|
||||||
|
const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH;
|
||||||
|
#else
|
||||||
|
const unsigned int consoleWidth = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Tbc;
|
||||||
|
|
||||||
|
template<typename T> struct RemoveConstRef{ typedef T type; };
|
||||||
|
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
||||||
|
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
||||||
|
template<typename T> struct RemoveConstRef<T const>{ typedef T type; };
|
||||||
|
|
||||||
|
template<typename T> struct IsBool { static const bool value = false; };
|
||||||
|
template<> struct IsBool<bool> { static const bool value = true; };
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void convertInto( std::string const& _source, T& _dest ) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << _source;
|
||||||
|
ss >> _dest;
|
||||||
|
if( ss.fail() )
|
||||||
|
throw std::runtime_error( "Unable to convert " + _source + " to destination type" );
|
||||||
|
}
|
||||||
|
inline void convertInto( std::string const& _source, std::string& _dest ) {
|
||||||
|
_dest = _source;
|
||||||
|
}
|
||||||
|
inline void convertInto( std::string const& _source, bool& _dest ) {
|
||||||
|
std::string sourceLC = _source;
|
||||||
|
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
|
||||||
|
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
|
||||||
|
_dest = true;
|
||||||
|
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
|
||||||
|
_dest = false;
|
||||||
|
else
|
||||||
|
throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" );
|
||||||
|
}
|
||||||
|
inline void convertInto( bool _source, bool& _dest ) {
|
||||||
|
_dest = _source;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline void convertInto( bool, T& ) {
|
||||||
|
throw std::runtime_error( "Invalid conversion" );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ConfigT>
|
||||||
|
struct IArgFunction {
|
||||||
|
virtual ~IArgFunction() {}
|
||||||
|
virtual void set( ConfigT& config, std::string const& value ) const = 0;
|
||||||
|
virtual void setFlag( ConfigT& config ) const = 0;
|
||||||
|
virtual bool takesArg() const = 0;
|
||||||
|
virtual IArgFunction* clone() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ConfigT>
|
||||||
|
class BoundArgFunction {
|
||||||
|
public:
|
||||||
|
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
||||||
|
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj->clone() ) {}
|
||||||
|
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||||
|
IArgFunction<ConfigT>* newFunctionObj = other.functionObj->clone();
|
||||||
|
delete functionObj;
|
||||||
|
functionObj = newFunctionObj;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~BoundArgFunction() { delete functionObj; }
|
||||||
|
|
||||||
|
void set( ConfigT& config, std::string const& value ) const {
|
||||||
|
functionObj->set( config, value );
|
||||||
|
}
|
||||||
|
void setFlag( ConfigT& config ) const {
|
||||||
|
functionObj->setFlag( config );
|
||||||
|
}
|
||||||
|
bool takesArg() const { return functionObj->takesArg(); }
|
||||||
|
private:
|
||||||
|
IArgFunction<ConfigT>* functionObj;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
struct NullBinder : IArgFunction<C>{
|
||||||
|
virtual void set( C&, std::string const& ) const {}
|
||||||
|
virtual void setFlag( C& ) const {}
|
||||||
|
virtual bool takesArg() const { return true; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new NullBinder( *this ); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename C, typename M>
|
||||||
|
struct BoundDataMember : IArgFunction<C>{
|
||||||
|
BoundDataMember( M C::* _member ) : member( _member ) {}
|
||||||
|
virtual void set( C& p, std::string const& stringValue ) const {
|
||||||
|
convertInto( stringValue, p.*member );
|
||||||
|
}
|
||||||
|
virtual void setFlag( C& p ) const {
|
||||||
|
convertInto( true, p.*member );
|
||||||
|
}
|
||||||
|
virtual bool takesArg() const { return !IsBool<M>::value; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new BoundDataMember( *this ); }
|
||||||
|
M C::* member;
|
||||||
|
};
|
||||||
|
template<typename C, typename M>
|
||||||
|
struct BoundUnaryMethod : IArgFunction<C>{
|
||||||
|
BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {}
|
||||||
|
virtual void set( C& p, std::string const& stringValue ) const {
|
||||||
|
typename RemoveConstRef<M>::type value;
|
||||||
|
convertInto( stringValue, value );
|
||||||
|
(p.*member)( value );
|
||||||
|
}
|
||||||
|
virtual void setFlag( C& p ) const {
|
||||||
|
typename RemoveConstRef<M>::type value;
|
||||||
|
convertInto( true, value );
|
||||||
|
(p.*member)( value );
|
||||||
|
}
|
||||||
|
virtual bool takesArg() const { return !IsBool<M>::value; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new BoundUnaryMethod( *this ); }
|
||||||
|
void (C::*member)( M );
|
||||||
|
};
|
||||||
|
template<typename C>
|
||||||
|
struct BoundNullaryMethod : IArgFunction<C>{
|
||||||
|
BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {}
|
||||||
|
virtual void set( C& p, std::string const& stringValue ) const {
|
||||||
|
bool value;
|
||||||
|
convertInto( stringValue, value );
|
||||||
|
if( value )
|
||||||
|
(p.*member)();
|
||||||
|
}
|
||||||
|
virtual void setFlag( C& p ) const {
|
||||||
|
(p.*member)();
|
||||||
|
}
|
||||||
|
virtual bool takesArg() const { return false; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new BoundNullaryMethod( *this ); }
|
||||||
|
void (C::*member)();
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
struct BoundUnaryFunction : IArgFunction<C>{
|
||||||
|
BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {}
|
||||||
|
virtual void set( C& obj, std::string const& stringValue ) const {
|
||||||
|
bool value;
|
||||||
|
convertInto( stringValue, value );
|
||||||
|
if( value )
|
||||||
|
function( obj );
|
||||||
|
}
|
||||||
|
virtual void setFlag( C& p ) const {
|
||||||
|
function( p );
|
||||||
|
}
|
||||||
|
virtual bool takesArg() const { return false; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new BoundUnaryFunction( *this ); }
|
||||||
|
void (*function)( C& );
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename C, typename T>
|
||||||
|
struct BoundBinaryFunction : IArgFunction<C>{
|
||||||
|
BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {}
|
||||||
|
virtual void set( C& obj, std::string const& stringValue ) const {
|
||||||
|
typename RemoveConstRef<T>::type value;
|
||||||
|
convertInto( stringValue, value );
|
||||||
|
function( obj, value );
|
||||||
|
}
|
||||||
|
virtual void setFlag( C& obj ) const {
|
||||||
|
typename RemoveConstRef<T>::type value;
|
||||||
|
convertInto( true, value );
|
||||||
|
function( obj, value );
|
||||||
|
}
|
||||||
|
virtual bool takesArg() const { return !IsBool<T>::value; }
|
||||||
|
virtual IArgFunction<C>* clone() const { return new BoundBinaryFunction( *this ); }
|
||||||
|
void (*function)( C&, T );
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename C, typename M>
|
||||||
|
BoundArgFunction<C> makeBoundField( M C::* _member ) {
|
||||||
|
return BoundArgFunction<C>( new BoundDataMember<C,M>( _member ) );
|
||||||
|
}
|
||||||
|
template<typename C, typename M>
|
||||||
|
BoundArgFunction<C> makeBoundField( void (C::*_member)( M ) ) {
|
||||||
|
return BoundArgFunction<C>( new BoundUnaryMethod<C,M>( _member ) );
|
||||||
|
}
|
||||||
|
template<typename C>
|
||||||
|
BoundArgFunction<C> makeBoundField( void (C::*_member)() ) {
|
||||||
|
return BoundArgFunction<C>( new BoundNullaryMethod<C>( _member ) );
|
||||||
|
}
|
||||||
|
template<typename C>
|
||||||
|
BoundArgFunction<C> makeBoundField( void (*_function)( C& ) ) {
|
||||||
|
return BoundArgFunction<C>( new BoundUnaryFunction<C>( _function ) );
|
||||||
|
}
|
||||||
|
template<typename C, typename T>
|
||||||
|
BoundArgFunction<C> makeBoundField( void (*_function)( C&, T ) ) {
|
||||||
|
return BoundArgFunction<C>( new BoundBinaryFunction<C, T>( _function ) );
|
||||||
|
}
|
||||||
|
} // namespace Detail
|
||||||
|
|
||||||
|
struct Parser {
|
||||||
|
Parser() : separators( " \t=:" ) {}
|
||||||
|
|
||||||
|
struct Token {
|
||||||
|
enum Type { Positional, ShortOpt, LongOpt };
|
||||||
|
Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {}
|
||||||
|
Type type;
|
||||||
|
std::string data;
|
||||||
|
};
|
||||||
|
|
||||||
|
void parseIntoTokens( int argc, char const * const * argv, std::vector<Parser::Token>& tokens ) const {
|
||||||
|
const std::string doubleDash = "--";
|
||||||
|
for( int i = 1; i < argc && argv[i] != doubleDash; ++i )
|
||||||
|
parseIntoTokens( argv[i] , tokens);
|
||||||
|
}
|
||||||
|
void parseIntoTokens( std::string arg, std::vector<Parser::Token>& tokens ) const {
|
||||||
|
while( !arg.empty() ) {
|
||||||
|
Parser::Token token( Parser::Token::Positional, arg );
|
||||||
|
arg = "";
|
||||||
|
if( token.data[0] == '-' ) {
|
||||||
|
if( token.data.size() > 1 && token.data[1] == '-' ) {
|
||||||
|
token = Parser::Token( Parser::Token::LongOpt, token.data.substr( 2 ) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
token = Parser::Token( Parser::Token::ShortOpt, token.data.substr( 1 ) );
|
||||||
|
if( token.data.size() > 1 && separators.find( token.data[1] ) == std::string::npos ) {
|
||||||
|
arg = "-" + token.data.substr( 1 );
|
||||||
|
token.data = token.data.substr( 0, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( token.type != Parser::Token::Positional ) {
|
||||||
|
std::size_t pos = token.data.find_first_of( separators );
|
||||||
|
if( pos != std::string::npos ) {
|
||||||
|
arg = token.data.substr( pos+1 );
|
||||||
|
token.data = token.data.substr( 0, pos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tokens.push_back( token );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string separators;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ConfigT>
|
||||||
|
class CommandLine {
|
||||||
|
|
||||||
|
struct Arg {
|
||||||
|
Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ), position( -1 ) {}
|
||||||
|
|
||||||
|
bool hasShortName( std::string const& shortName ) const {
|
||||||
|
for( std::vector<std::string>::const_iterator
|
||||||
|
it = shortNames.begin(), itEnd = shortNames.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
if( *it == shortName )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool hasLongName( std::string const& _longName ) const {
|
||||||
|
return _longName == longName;
|
||||||
|
}
|
||||||
|
bool takesArg() const {
|
||||||
|
return !hint.empty();
|
||||||
|
}
|
||||||
|
bool isFixedPositional() const {
|
||||||
|
return position != -1;
|
||||||
|
}
|
||||||
|
bool isAnyPositional() const {
|
||||||
|
return position == -1 && shortNames.empty() && longName.empty();
|
||||||
|
}
|
||||||
|
std::string dbgName() const {
|
||||||
|
if( !longName.empty() )
|
||||||
|
return "--" + longName;
|
||||||
|
if( !shortNames.empty() )
|
||||||
|
return "-" + shortNames[0];
|
||||||
|
return "positional args";
|
||||||
|
}
|
||||||
|
void validate() const {
|
||||||
|
if( boundField.takesArg() && !takesArg() )
|
||||||
|
throw std::logic_error( dbgName() + " must specify an arg name" );
|
||||||
|
}
|
||||||
|
std::string commands() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
bool first = true;
|
||||||
|
std::vector<std::string>::const_iterator it = shortNames.begin(), itEnd = shortNames.end();
|
||||||
|
for(; it != itEnd; ++it ) {
|
||||||
|
if( first )
|
||||||
|
first = false;
|
||||||
|
else
|
||||||
|
oss << ", ";
|
||||||
|
oss << "-" << *it;
|
||||||
|
}
|
||||||
|
if( !longName.empty() ) {
|
||||||
|
if( !first )
|
||||||
|
oss << ", ";
|
||||||
|
oss << "--" << longName;
|
||||||
|
}
|
||||||
|
if( !hint.empty() )
|
||||||
|
oss << " <" << hint << ">";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
Detail::BoundArgFunction<ConfigT> boundField;
|
||||||
|
std::vector<std::string> shortNames;
|
||||||
|
std::string longName;
|
||||||
|
std::string description;
|
||||||
|
std::string hint;
|
||||||
|
int position;
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOTE: std::auto_ptr is deprecated in c++11/c++0x
|
||||||
|
#if defined(__cplusplus) && __cplusplus > 199711L
|
||||||
|
typedef std::unique_ptr<Arg> ArgAutoPtr;
|
||||||
|
#else
|
||||||
|
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class ArgBinder {
|
||||||
|
public:
|
||||||
|
template<typename F>
|
||||||
|
ArgBinder( CommandLine* cl, F f )
|
||||||
|
: m_cl( cl ),
|
||||||
|
m_arg( Detail::makeBoundField( f ) )
|
||||||
|
{}
|
||||||
|
ArgBinder( ArgBinder& other )
|
||||||
|
: m_cl( other.m_cl ),
|
||||||
|
m_arg( other.m_arg )
|
||||||
|
{
|
||||||
|
other.m_cl = NULL;
|
||||||
|
}
|
||||||
|
~ArgBinder() {
|
||||||
|
if( m_cl ) {
|
||||||
|
m_arg.validate();
|
||||||
|
if( m_arg.isFixedPositional() ) {
|
||||||
|
m_cl->m_positionalArgs.insert( std::make_pair( m_arg.position, m_arg ) );
|
||||||
|
if( m_arg.position > m_cl->m_highestSpecifiedArgPosition )
|
||||||
|
m_cl->m_highestSpecifiedArgPosition = m_arg.position;
|
||||||
|
}
|
||||||
|
else if( m_arg.isAnyPositional() ) {
|
||||||
|
if( m_cl->m_arg.get() )
|
||||||
|
throw std::logic_error( "Only one unpositional argument can be added" );
|
||||||
|
m_cl->m_arg = ArgAutoPtr( new Arg( m_arg ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_cl->m_options.push_back( m_arg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArgBinder& shortOpt( std::string const& name ) {
|
||||||
|
m_arg.shortNames.push_back( name );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ArgBinder& longOpt( std::string const& name ) {
|
||||||
|
m_arg.longName = name;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ArgBinder& describe( std::string const& description ) {
|
||||||
|
m_arg.description = description;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ArgBinder& hint( std::string const& hint ) {
|
||||||
|
m_arg.hint = hint;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ArgBinder& position( int position ) {
|
||||||
|
m_arg.position = position;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
CommandLine* m_cl;
|
||||||
|
Arg m_arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
CommandLine()
|
||||||
|
: m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
|
||||||
|
m_highestSpecifiedArgPosition( 0 ),
|
||||||
|
m_throwOnUnrecognisedTokens( false )
|
||||||
|
{}
|
||||||
|
CommandLine( CommandLine const& other )
|
||||||
|
: m_boundProcessName( other.m_boundProcessName ),
|
||||||
|
m_options ( other.m_options ),
|
||||||
|
m_positionalArgs( other.m_positionalArgs ),
|
||||||
|
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
|
||||||
|
m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
|
||||||
|
{
|
||||||
|
if( other.m_arg.get() )
|
||||||
|
m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
|
||||||
|
m_throwOnUnrecognisedTokens = shouldThrow;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
ArgBinder bind( F f ) {
|
||||||
|
ArgBinder binder( this, f );
|
||||||
|
return binder;
|
||||||
|
}
|
||||||
|
template<typename F>
|
||||||
|
void bindProcessName( F f ) {
|
||||||
|
m_boundProcessName = Detail::makeBoundField( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
|
||||||
|
typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
|
||||||
|
std::size_t maxWidth = 0;
|
||||||
|
for( it = itBegin; it != itEnd; ++it )
|
||||||
|
maxWidth = (std::max)( maxWidth, it->commands().size() );
|
||||||
|
|
||||||
|
for( it = itBegin; it != itEnd; ++it ) {
|
||||||
|
Detail::Text usage( it->commands(), Detail::TextAttributes()
|
||||||
|
.setWidth( maxWidth+indent )
|
||||||
|
.setIndent( indent ) );
|
||||||
|
// !TBD handle longer usage strings
|
||||||
|
Detail::Text desc( it->description, Detail::TextAttributes()
|
||||||
|
.setWidth( width - maxWidth -3 ) );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
|
||||||
|
std::string usageCol = i < usage.size() ? usage[i] : "";
|
||||||
|
os << usageCol;
|
||||||
|
|
||||||
|
if( i < desc.size() && !desc[i].empty() )
|
||||||
|
os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
|
||||||
|
<< desc[i];
|
||||||
|
os << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string optUsage() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
optUsage( oss );
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void argSynopsis( std::ostream& os ) const {
|
||||||
|
for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) {
|
||||||
|
if( i > 1 )
|
||||||
|
os << " ";
|
||||||
|
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
|
||||||
|
if( it != m_positionalArgs.end() )
|
||||||
|
os << "<" << it->second.hint << ">";
|
||||||
|
else if( m_arg.get() )
|
||||||
|
os << "<" << m_arg->hint << ">";
|
||||||
|
else
|
||||||
|
throw std::logic_error( "non consecutive positional arguments with no floating args" );
|
||||||
|
}
|
||||||
|
// !TBD No indication of mandatory args
|
||||||
|
if( m_arg.get() ) {
|
||||||
|
if( m_highestSpecifiedArgPosition > 1 )
|
||||||
|
os << " ";
|
||||||
|
os << "[<" << m_arg->hint << "> ...]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string argSynopsis() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
argSynopsis( oss );
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage( std::ostream& os, std::string const& procName ) const {
|
||||||
|
os << "usage:\n " << procName << " ";
|
||||||
|
argSynopsis( os );
|
||||||
|
if( !m_options.empty() ) {
|
||||||
|
os << " [options]\n\nwhere options are: \n";
|
||||||
|
optUsage( os, 2 );
|
||||||
|
}
|
||||||
|
os << "\n";
|
||||||
|
}
|
||||||
|
std::string usage( std::string const& procName ) const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
usage( oss, procName );
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Parser::Token> parseInto( int argc, char const * const * argv, ConfigT& config ) const {
|
||||||
|
std::string processName = argv[0];
|
||||||
|
std::size_t lastSlash = processName.find_last_of( "/\\" );
|
||||||
|
if( lastSlash != std::string::npos )
|
||||||
|
processName = processName.substr( lastSlash+1 );
|
||||||
|
m_boundProcessName.set( config, processName );
|
||||||
|
std::vector<Parser::Token> tokens;
|
||||||
|
Parser parser;
|
||||||
|
parser.parseIntoTokens( argc, argv, tokens );
|
||||||
|
return populate( tokens, config );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Parser::Token> populate( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
||||||
|
if( m_options.empty() && m_positionalArgs.empty() )
|
||||||
|
throw std::logic_error( "No options or arguments specified" );
|
||||||
|
|
||||||
|
std::vector<Parser::Token> unusedTokens = populateOptions( tokens, config );
|
||||||
|
unusedTokens = populateFixedArgs( unusedTokens, config );
|
||||||
|
unusedTokens = populateFloatingArgs( unusedTokens, config );
|
||||||
|
return unusedTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
||||||
|
std::vector<Parser::Token> unusedTokens;
|
||||||
|
std::vector<std::string> errors;
|
||||||
|
for( std::size_t i = 0; i < tokens.size(); ++i ) {
|
||||||
|
Parser::Token const& token = tokens[i];
|
||||||
|
typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
|
||||||
|
for(; it != itEnd; ++it ) {
|
||||||
|
Arg const& arg = *it;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) ||
|
||||||
|
( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
|
||||||
|
if( arg.takesArg() ) {
|
||||||
|
if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
|
||||||
|
errors.push_back( "Expected argument to option: " + token.data );
|
||||||
|
else
|
||||||
|
arg.boundField.set( config, tokens[++i].data );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
arg.boundField.setFlag( config );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( std::exception& ex ) {
|
||||||
|
errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( it == itEnd ) {
|
||||||
|
if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
|
||||||
|
unusedTokens.push_back( token );
|
||||||
|
else if( m_throwOnUnrecognisedTokens )
|
||||||
|
errors.push_back( "unrecognised option: " + token.data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !errors.empty() ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
|
if( it != errors.begin() )
|
||||||
|
oss << "\n";
|
||||||
|
oss << *it;
|
||||||
|
}
|
||||||
|
throw std::runtime_error( oss.str() );
|
||||||
|
}
|
||||||
|
return unusedTokens;
|
||||||
|
}
|
||||||
|
std::vector<Parser::Token> populateFixedArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
||||||
|
std::vector<Parser::Token> unusedTokens;
|
||||||
|
int position = 1;
|
||||||
|
for( std::size_t i = 0; i < tokens.size(); ++i ) {
|
||||||
|
Parser::Token const& token = tokens[i];
|
||||||
|
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( position );
|
||||||
|
if( it != m_positionalArgs.end() )
|
||||||
|
it->second.boundField.set( config, token.data );
|
||||||
|
else
|
||||||
|
unusedTokens.push_back( token );
|
||||||
|
if( token.type == Parser::Token::Positional )
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
return unusedTokens;
|
||||||
|
}
|
||||||
|
std::vector<Parser::Token> populateFloatingArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
||||||
|
if( !m_arg.get() )
|
||||||
|
return tokens;
|
||||||
|
std::vector<Parser::Token> unusedTokens;
|
||||||
|
for( std::size_t i = 0; i < tokens.size(); ++i ) {
|
||||||
|
Parser::Token const& token = tokens[i];
|
||||||
|
if( token.type == Parser::Token::Positional )
|
||||||
|
m_arg->boundField.set( config, token.data );
|
||||||
|
else
|
||||||
|
unusedTokens.push_back( token );
|
||||||
|
}
|
||||||
|
return unusedTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Detail::BoundArgFunction<ConfigT> m_boundProcessName;
|
||||||
|
std::vector<Arg> m_options;
|
||||||
|
std::map<int, Arg> m_positionalArgs;
|
||||||
|
ArgAutoPtr m_arg;
|
||||||
|
int m_highestSpecifiedArgPosition;
|
||||||
|
bool m_throwOnUnrecognisedTokens;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace Clara
|
||||||
|
|
||||||
|
#ifdef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
} // end outer namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
|
153
single_include_projects/SelfTest/internal/tbc_text_format.h
Normal file
153
single_include_projects/SelfTest/internal/tbc_text_format.h
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 18/4/2013.
|
||||||
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
// Only use header guard if we are not using an outer namespace
|
||||||
|
#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
|
||||||
|
# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// Use optional outer namespace
|
||||||
|
#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Tbc {
|
||||||
|
|
||||||
|
#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
|
||||||
|
const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
|
||||||
|
#else
|
||||||
|
const unsigned int consoleWidth = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct TextAttributes {
|
||||||
|
TextAttributes()
|
||||||
|
: initialIndent( std::string::npos ),
|
||||||
|
indent( 0 ),
|
||||||
|
width( consoleWidth-1 ),
|
||||||
|
tabChar( '\t' )
|
||||||
|
{}
|
||||||
|
|
||||||
|
TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
|
||||||
|
TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
|
||||||
|
TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
|
||||||
|
TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
|
||||||
|
|
||||||
|
std::size_t initialIndent; // indent of first line, or npos
|
||||||
|
std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
|
||||||
|
std::size_t width; // maximum width of text, including indent. Longer text will wrap
|
||||||
|
char tabChar; // If this char is seen the indent is changed to current pos
|
||||||
|
};
|
||||||
|
|
||||||
|
class Text {
|
||||||
|
public:
|
||||||
|
Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
|
||||||
|
: attr( _attr )
|
||||||
|
{
|
||||||
|
std::string wrappableChars = " [({.,/|\\-";
|
||||||
|
std::size_t indent = _attr.initialIndent != std::string::npos
|
||||||
|
? _attr.initialIndent
|
||||||
|
: _attr.indent;
|
||||||
|
std::string remainder = _str;
|
||||||
|
|
||||||
|
while( !remainder.empty() ) {
|
||||||
|
if( lines.size() >= 1000 ) {
|
||||||
|
lines.push_back( "... message truncated due to excessive size" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::size_t tabPos = std::string::npos;
|
||||||
|
std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
|
||||||
|
std::size_t pos = remainder.find_first_of( '\n' );
|
||||||
|
if( pos <= width ) {
|
||||||
|
width = pos;
|
||||||
|
}
|
||||||
|
pos = remainder.find_last_of( _attr.tabChar, width );
|
||||||
|
if( pos != std::string::npos ) {
|
||||||
|
tabPos = pos;
|
||||||
|
if( remainder[width] == '\n' )
|
||||||
|
width--;
|
||||||
|
remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( width == remainder.size() ) {
|
||||||
|
spliceLine( indent, remainder, width );
|
||||||
|
}
|
||||||
|
else if( remainder[width] == '\n' ) {
|
||||||
|
spliceLine( indent, remainder, width );
|
||||||
|
if( width <= 1 || remainder.size() != 1 )
|
||||||
|
remainder = remainder.substr( 1 );
|
||||||
|
indent = _attr.indent;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pos = remainder.find_last_of( wrappableChars, width );
|
||||||
|
if( pos != std::string::npos && pos > 0 ) {
|
||||||
|
spliceLine( indent, remainder, pos );
|
||||||
|
if( remainder[0] == ' ' )
|
||||||
|
remainder = remainder.substr( 1 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
spliceLine( indent, remainder, width-1 );
|
||||||
|
lines.back() += "-";
|
||||||
|
}
|
||||||
|
if( lines.size() == 1 )
|
||||||
|
indent = _attr.indent;
|
||||||
|
if( tabPos != std::string::npos )
|
||||||
|
indent += tabPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
|
||||||
|
lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
|
||||||
|
_remainder = _remainder.substr( _pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::vector<std::string>::const_iterator const_iterator;
|
||||||
|
|
||||||
|
const_iterator begin() const { return lines.begin(); }
|
||||||
|
const_iterator end() const { return lines.end(); }
|
||||||
|
std::string const& last() const { return lines.back(); }
|
||||||
|
std::size_t size() const { return lines.size(); }
|
||||||
|
std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
|
||||||
|
std::string toString() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << *this;
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
||||||
|
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
||||||
|
it != itEnd; ++it ) {
|
||||||
|
if( it != _text.begin() )
|
||||||
|
_stream << "\n";
|
||||||
|
_stream << *it;
|
||||||
|
}
|
||||||
|
return _stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string str;
|
||||||
|
TextAttributes attr;
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace Tbc
|
||||||
|
|
||||||
|
#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
} // end outer namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
21
single_include_projects/SelfTest/makefile
Normal file
21
single_include_projects/SelfTest/makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
SOURCES = ApproxTests.cpp \
|
||||||
|
BDDTests.cpp \
|
||||||
|
ClassTests.cpp \
|
||||||
|
CmdLineTests.cpp \
|
||||||
|
ConditionTests.cpp \
|
||||||
|
ExceptionTests.cpp \
|
||||||
|
GeneratorTests.cpp \
|
||||||
|
MessageTests.cpp \
|
||||||
|
MiscTests.cpp \
|
||||||
|
TestMain.cpp \
|
||||||
|
TrickyTests.cpp \
|
||||||
|
VariadicMacrosTests.cpp
|
||||||
|
OBJECTS = $(patsubst %.cpp, %.o, $(SOURCES))
|
||||||
|
CXX = g++
|
||||||
|
CXXFLAGS = -I../../single_include
|
||||||
|
|
||||||
|
CatchSelfTest: $(OBJECTS)
|
||||||
|
$(CXX) -o $@ $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f CatchSelfTest CatchSelfTest.exe $(OBJECTS)
|
@ -0,0 +1,34 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
using namespace System::Reflection;
|
||||||
|
using namespace System::Runtime::CompilerServices;
|
||||||
|
using namespace System::Runtime::InteropServices;
|
||||||
|
|
||||||
|
//
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
//
|
||||||
|
[assembly:AssemblyTitleAttribute("ManagedTestCatch")];
|
||||||
|
[assembly:AssemblyDescriptionAttribute("")];
|
||||||
|
[assembly:AssemblyConfigurationAttribute("")];
|
||||||
|
[assembly:AssemblyCompanyAttribute("Instron")];
|
||||||
|
[assembly:AssemblyProductAttribute("ManagedTestCatch")];
|
||||||
|
[assembly:AssemblyCopyrightAttribute("Copyright (c) Instron 2013")];
|
||||||
|
[assembly:AssemblyTrademarkAttribute("")];
|
||||||
|
[assembly:AssemblyCultureAttribute("")];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the value or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
|
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||||
|
[assembly:ComVisible(false)];
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TestSettings name="Local" id="0ee76c48-59a5-4c14-a4d5-d849401e9870" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||||
|
<Description>These are default test settings for a local test run.</Description>
|
||||||
|
<Deployment enabled="false" />
|
||||||
|
<Execution>
|
||||||
|
<TestTypeSpecific />
|
||||||
|
<AgentRule name="Execution Agents">
|
||||||
|
</AgentRule>
|
||||||
|
</Execution>
|
||||||
|
</TestSettings>
|
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManagedTestCatch", "ManagedTestCatch.vcxproj", "{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EAFF2A33-B90A-4957-A39D-F49589A088C8}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
Local.testsettings = Local.testsettings
|
||||||
|
ManagedTestCatch.vsmdi = ManagedTestCatch.vsmdi
|
||||||
|
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||||
|
CategoryFile = ManagedTestCatch.vsmdi
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
DebugMbcs|Win32 = DebugMbcs|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
ReleaseMbcs|Win32 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.DebugMbcs|Win32.ActiveCfg = DebugMbcs|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.DebugMbcs|Win32.Build.0 = DebugMbcs|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.ReleaseMbcs|Win32.ActiveCfg = ReleaseMbcs|Win32
|
||||||
|
{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}.ReleaseMbcs|Win32.Build.0 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,177 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="DebugMbcs|Win32">
|
||||||
|
<Configuration>DebugMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="ReleaseMbcs|Win32">
|
||||||
|
<Configuration>ReleaseMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
|
<ProjectTypes>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectTypes>
|
||||||
|
<ProjectGUID>{7CC06A6B-763E-42B3-AF6C-8F1E340372A1}</ProjectGUID>
|
||||||
|
<Keyword>ManagedCProj</Keyword>
|
||||||
|
<RootNamespace>ManagedTestCatch</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<CLRSupport>true</CLRSupport>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<CLRSupport>true</CLRSupport>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<CLRSupport>Safe</CLRSupport>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<CLRSupport>Safe</CLRSupport>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\10.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEventCommand>if exist app.config copy app.config "$(OutDir)app.config"</PostBuildEventCommand>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">true</LinkIncremental>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp" />
|
||||||
|
<ClCompile Include="AssemblyInfo.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="app.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="AssemblyInfo.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="app.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||||
|
<TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
|
||||||
|
<RunConfiguration id="0ee76c48-59a5-4c14-a4d5-d849401e9870" name="Local" storage="local.testsettings" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
</TestList>
|
||||||
|
</TestLists>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TestSettings name="Trace and Test Impact" id="e9a68de0-6b94-4b74-9333-9b481e6a3d16" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||||
|
<Description>These are test settings for Trace and Test Impact.</Description>
|
||||||
|
<Execution>
|
||||||
|
<TestTypeSpecific />
|
||||||
|
<AgentRule name="Execution Agents">
|
||||||
|
</AgentRule>
|
||||||
|
</Execution>
|
||||||
|
</TestSettings>
|
BIN
single_include_projects/VS2010/ManagedTestCatch/app.ico
Normal file
BIN
single_include_projects/VS2010/ManagedTestCatch/app.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
52
single_include_projects/VS2010/ManagedTestCatch/app.rc
Normal file
52
single_include_projects/VS2010/ManagedTestCatch/app.rc
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon placed first or with lowest ID value becomes application icon
|
||||||
|
|
||||||
|
LANGUAGE 9, 2
|
||||||
|
#pragma code_page(1252)
|
||||||
|
1 ICON "app.ico"
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by app.rc
|
@ -0,0 +1,5 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// ManagedTestCatch.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
7
single_include_projects/VS2010/ManagedTestCatch/stdafx.h
Normal file
7
single_include_projects/VS2010/ManagedTestCatch/stdafx.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently,
|
||||||
|
// but are changed infrequently
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
20
single_include_projects/VS2010/TestCatch/TestCatch.sln
Normal file
20
single_include_projects/VS2010/TestCatch/TestCatch.sln
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCatch", "TestCatch\TestCatch.vcxproj", "{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,149 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}</ProjectGuid>
|
||||||
|
<RootNamespace>TestCatch</RootNamespace>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||||
|
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
|
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\..\single_include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\..\single_include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\MessageTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\MiscTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\TrickyTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\VariadicMacrosTests.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_objc.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_objc_main.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_runner.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_with_main.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_capture.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_commandline.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_common.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_config.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_debugger.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_evaluate.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_exception_translator_registry.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_generators.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_generators_impl.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_hub.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_hub_impl.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_capture.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_exception.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_reporter.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_runner.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_testcase.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_list.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registrars.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registry.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_result_type.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_resultinfo.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_runner_impl.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_section.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_stream.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_info.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_registry_impl.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_registry.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_xmlwriter.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_basic.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_junit.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_xml.hpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,162 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\MiscTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\ExceptionTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\GeneratorTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\MessageTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\VariadicMacrosTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\SelfTest\TrickyTests.cpp">
|
||||||
|
<Filter>Sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_capture.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_commandline.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_common.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_config.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_debugger.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_evaluate.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_exception_translator_registry.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_generators.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_generators_impl.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_capture.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_registry_impl.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_exception.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_reporter.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_runner.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_testcase.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_list.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_junit.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registrars.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registry.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_xml.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_result_type.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_runner.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_runner_impl.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_section.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_stream.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_info.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_xmlwriter.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_test_registry.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_hub.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_with_main.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_hub_impl.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_objc.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\catch_objc_main.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_basic.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\..\include\internal\catch_resultinfo.hpp">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Headers">
|
||||||
|
<UniqueIdentifier>{18bce7d6-45c2-4f57-8334-f3e8469d4d41}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Sources">
|
||||||
|
<UniqueIdentifier>{fea8fbb4-5032-451a-ba31-e5cb8f32e0de}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,34 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
using namespace System::Reflection;
|
||||||
|
using namespace System::Runtime::CompilerServices;
|
||||||
|
using namespace System::Runtime::InteropServices;
|
||||||
|
|
||||||
|
//
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
//
|
||||||
|
[assembly:AssemblyTitleAttribute("ManagedTestCatch2012")];
|
||||||
|
[assembly:AssemblyDescriptionAttribute("")];
|
||||||
|
[assembly:AssemblyConfigurationAttribute("")];
|
||||||
|
[assembly:AssemblyCompanyAttribute("Instron")];
|
||||||
|
[assembly:AssemblyProductAttribute("ManagedTestCatch2012")];
|
||||||
|
[assembly:AssemblyCopyrightAttribute("Copyright (c) Instron 2013")];
|
||||||
|
[assembly:AssemblyTrademarkAttribute("")];
|
||||||
|
[assembly:AssemblyCultureAttribute("")];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the value or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
|
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||||
|
[assembly:ComVisible(false)];
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManagedTestCatch", "ManagedTestCatch.vcxproj", "{9757CB21-B840-49A6-B057-9F322E543DD6}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
DebugMbcs|Win32 = DebugMbcs|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
ReleaseMbcs|Win32 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.DebugMbcs|Win32.ActiveCfg = DebugMbcs|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.DebugMbcs|Win32.Build.0 = DebugMbcs|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.ReleaseMbcs|Win32.ActiveCfg = ReleaseMbcs|Win32
|
||||||
|
{9757CB21-B840-49A6-B057-9F322E543DD6}.ReleaseMbcs|Win32.Build.0 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,196 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="DebugMbcs|Win32">
|
||||||
|
<Configuration>DebugMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="ReleaseMbcs|Win32">
|
||||||
|
<Configuration>ReleaseMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
|
<ProjectTypes>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectTypes>
|
||||||
|
<ProjectGUID>{9757CB21-B840-49A6-B057-9F322E543DD6}</ProjectGUID>
|
||||||
|
<Keyword>ManagedCProj</Keyword>
|
||||||
|
<RootNamespace>ManagedTestCatch2012</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CLRSupport>Safe</CLRSupport>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CLRSupport>Safe</CLRSupport>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CLRSupport>true</CLRSupport>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CLRSupport>true</CLRSupport>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(LocalAppData)\Microsoft\VisualStudio\11.0\Microsoft.Cpp.$(Platform).user.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEventCommand>if exist app.config copy app.config "$(OutDir)app.config"</PostBuildEventCommand>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies />
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>taskkill /F /IM vstest.executionengine.x86.exe /FI "MEMUSAGE gt 1"</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>taskkill /F /IM vstest.executionengine.x86.exe /FI "MEMUSAGE gt 1"</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies />
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAsManaged>true</CompileAsManaged>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
|
||||||
|
<HintPath>..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp" />
|
||||||
|
<ClCompile Include="AssemblyInfo.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="app.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="app.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="AssemblyInfo.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="app.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="app.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
BIN
single_include_projects/VS2012/ManagedTestCatch/app.ico
Normal file
BIN
single_include_projects/VS2012/ManagedTestCatch/app.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
52
single_include_projects/VS2012/ManagedTestCatch/app.rc
Normal file
52
single_include_projects/VS2012/ManagedTestCatch/app.rc
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon placed first or with lowest ID value becomes application icon
|
||||||
|
|
||||||
|
LANGUAGE 9, 2
|
||||||
|
#pragma code_page(1252)
|
||||||
|
1 ICON "app.ico"
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by app.rc
|
@ -0,0 +1,5 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// ManagedTestCatch2012.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
7
single_include_projects/VS2012/ManagedTestCatch/stdafx.h
Normal file
7
single_include_projects/VS2012/ManagedTestCatch/stdafx.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently,
|
||||||
|
// but are changed infrequently
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NativeTestCatch", "NativeTestCatch.vcxproj", "{977CE524-3FC7-4281-9C1B-77C210F24A9B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
DebugMbcs|Win32 = DebugMbcs|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
ReleaseMbcs|Win32 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.DebugMbcs|Win32.ActiveCfg = DebugMbcs|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.DebugMbcs|Win32.Build.0 = DebugMbcs|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.ReleaseMbcs|Win32.ActiveCfg = ReleaseMbcs|Win32
|
||||||
|
{977CE524-3FC7-4281-9C1B-77C210F24A9B}.ReleaseMbcs|Win32.Build.0 = ReleaseMbcs|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,181 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="DebugMbcs|Win32">
|
||||||
|
<Configuration>DebugMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="ReleaseMbcs|Win32">
|
||||||
|
<Configuration>ReleaseMbcs</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{977CE524-3FC7-4281-9C1B-77C210F24A9B}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>NativeTestCatch</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>../../../single_include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp" />
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseMbcs|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VariadicMacrosTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MiscTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\SectionTrackerTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TrickyTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\RunAllTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\TestMain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests1.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\MessageInstantiationTests2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\SelfTest\VisualStudioConfigTests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,9 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// NativeTestCatch.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: reference any additional headers you need in STDAFX.H
|
||||||
|
// and not in this file
|
||||||
|
|
13
single_include_projects/VS2012/NativeTestCatch/stdafx.h
Normal file
13
single_include_projects/VS2012/NativeTestCatch/stdafx.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
// Headers for CppUnitTest
|
||||||
|
#include "CppUnitTest.h"
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||||
|
|
||||||
|
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||||
|
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
Loading…
Reference in New Issue
Block a user