Update of /cvsroot/jsoncpp/jsoncpp/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27056/test
Modified Files:
.cvsignore runtests.py
Log Message:
* added FastWriter implementation and updated test (read the written input and check if correct).
Index: .cvsignore
===================================================================
RCS file: /cvsroot/jsoncpp/jsoncpp/test/.cvsignore,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** .cvsignore 27 Jul 2005 07:09:23 -0000 1.1.1.1
--- .cvsignore 27 Jul 2005 22:28:07 -0000 1.2
***************
*** 1 ****
--- 1,4 ----
*.actual
+ *.actual-rewrite
+ *.rewrite
+ *.process-output
Index: runtests.py
===================================================================
RCS file: /cvsroot/jsoncpp/jsoncpp/test/runtests.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** runtests.py 27 Jul 2005 07:09:23 -0000 1.1.1.1
--- runtests.py 27 Jul 2005 22:28:07 -0000 1.2
***************
*** 10,14 ****
jsontest_executable_path = os.path.normpath( os.path.abspath( sys.argv[1] ) )
! def compareOutputs( expected, actual ):
expected = expected.strip().replace('\r','').split('\n')
actual = actual.strip().replace('\r','').split('\n')
--- 10,14 ----
jsontest_executable_path = os.path.normpath( os.path.abspath( sys.argv[1] ) )
! def compareOutputs( expected, actual, message ):
expected = expected.strip().replace('\r','').split('\n')
actual = actual.strip().replace('\r','').split('\n')
***************
*** 28,38 ****
return ''
return lines[index].strip()
! return """ Difference at line %d:
Expected: '%s'
Actual: '%s'
! """ % (diff_line,
safeGetLine(expected,diff_line),
safeGetLine(actual,diff_line) )
tests = glob.glob( '*.json' )
--- 28,43 ----
return ''
return lines[index].strip()
! return """ Difference in %s at line %d:
Expected: '%s'
Actual: '%s'
! """ % (message, diff_line,
safeGetLine(expected,diff_line),
safeGetLine(actual,diff_line) )
+ def safeReadFile( path ):
+ try:
+ return file( base_path + '.actual', 'rt' ).read()
+ except:
+ return ""
tests = glob.glob( '*.json' )
***************
*** 41,55 ****
print 'TESTING:', input_path,
pipe = os.popen( "%s %s" % (jsontest_executable_path, input_path) )
! actual_output = pipe.read()
status = pipe.close()
! actual_output_path = os.path.splitext(input_path)[0] + '.actual'
! file(actual_output_path,'wt').write( actual_output )
if status:
print 'parsing failed'
! failed_tests.append( (input_path, 'Parsing failed:\n' + actual_output) )
else:
expected_output_path = os.path.splitext(input_path)[0] + '.expected'
expected_output = file( expected_output_path, 'rt' ).read()
! detail = compareOutputs( expected_output, actual_output )
if detail:
print 'FAILED'
--- 46,63 ----
print 'TESTING:', input_path,
pipe = os.popen( "%s %s" % (jsontest_executable_path, input_path) )
! process_output = pipe.read()
status = pipe.close()
! base_path = os.path.splitext(input_path)[0]
! actual_output = safeReadFile( base_path + '.actual' )
! actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' )
! file(base_path + '.process-output','wt').write( process_output )
if status:
print 'parsing failed'
! failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) )
else:
expected_output_path = os.path.splitext(input_path)[0] + '.expected'
expected_output = file( expected_output_path, 'rt' ).read()
! detail = ( compareOutputs( expected_output, actual_output, 'input' )
! or compareOutputs( expected_output, actual_rewrite_output, 'rewrite' ) )
if detail:
print 'FAILED'
|