Procházet zdrojové kódy

The qsp part of the test - basic functions, setup, etc.

netuttki před 10 měsíci
rodič
revize
15288ae70a
1 změnil soubory, kde provedl 165 přidání a 0 odebrání
  1. 165 0
      test/testframework.qsrc

+ 165 - 0
test/testframework.qsrc

@@ -0,0 +1,165 @@
+# testframework
+
+_ISTEST = 1
+
+!! Set up the date, the player character basic attributes, etc.
+if $ARGS[0] = 'testsetup':
+	
+	daystart = 0
+	month = 8
+	$month = 'August'
+	day = 26
+	week = 5
+	hour = 9
+
+
+	birthyear = 1999
+	birthmonth = 4
+	birthday = 1
+	pcs_haircol = 1
+	pcs_eyesize = 2
+	pcs_lip = 1
+	pcs_lashes = 1
+
+!!	Body
+	pcs_hgt = 170
+	pcs_teeth = 0
+	pcs_butt = 8
+	pcs_skin = 500
+
+!!	Stats
+	pcs_stren = 35
+	strenbuf = 10
+	pcs_agil = 35
+	agilbuf = 10
+	pcs_vital = 35
+	vitalbuf = 10
+	pcs_intel = 35
+	pcs_sprt = 35
+	pcs_react = 35
+	pcs_chrsm = 35
+	pcs_prcptn = 35
+	pcs_magik = 0
+
+	$pcs_firstname = "Svetlana"
+	$pcs_lastname = "Lebedev"
+	$pcs_nickname = "Sveta"
+end
+
+!! Asserts that the two strings passed in $ARGS[1] and $ARGS[2] are equal.
+if $ARGS[0] = 'assertEqualsString':
+	RESULT = $ARGS[1] = $ARGS[2]
+end
+
+!! Asserts that the two numbers passed in ARGS[1] and ARGS[2] are equal.
+if $ARGS[0] = 'assertEqualsNumber':
+	RESULT = ARGS[1] = ARGS[2]
+end
+
+
+!! Asserts that the two Arrays passed in $ARGS[1] and $ARGS[2] are equal.
+!! The two parameters are the Array variable names
+if $ARGS[0] = 'assertEqualsStringArray':
+	RESULT = ARRSIZE($ARGS[1]) = ARRSIZE($ARGS[2])
+end
+
+if $ARGS[0] = 'cleanUpDefault':
+	killvar 'EXPECTED'
+	killvar 'ACTUAL'
+	killvar 'FUNCTIONNAME'
+	killvar 'TESTRESULT'
+end
+
+
+if $ARGS[0] = 'addTestResult':
+	$testResults[testCount] = "<<$TESTNAME>>; gs '<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>'" + iif($ARGUMENTS ! '', ', <<$ARGUMENTS>>', '') + "; <<$EXPECTED_MESSAGE>>; <<$ACTUAL_MESSAGE>>; "
+	if TESTRESULT ! 0:
+		$testResults[testCount] += '<font style="color: green;"><b>S</b></font>'
+		testPassed += 1
+	else
+		$testResults[testCount] += '<font style="color: red;"><b>F</b></font>'
+		testFailed += 1
+	end
+	testCount += 1
+end
+
+if $ARGS[0] = 'displayTestResults':
+	$ROW[0] = '<h1>Test results for TestSuite: <<$_TESTSUITE>></h1>'
+	$ROW[1] = '	<b>Test built</b>: <<$_TESTBUILDTIME>>'
+	if _TESTSAVED ! 0:
+		$ROW[2] = '	<h3>This is a saved test result, not a new run.</h3>'
+	else 
+		$ROW[2] = '	<h3>New test run results</h3>'
+	end
+	$ROW[5] = '	<b>Number of tests executed</b>: <<testCount>>'
+	$ROW[6] = '	<b>Number of test passed</b>   : <<testPassed>>'
+	$ROW[7] = '	<b>Number of test failed</b>   : <<testFailed>>'
+	$ROW[8] = '<table style="border: 2px solid #000; background: white;">'
+	$ROW[9] = '<tr style="border: 2px solid #000; background: white;"><th style="max-width: 15%; border: 2px solid #000; background: white;">Test Name</th><th style="max-width: 30%; border: 1px solid #000; background: white;">Call (location, function)</th><th style="max-width: 25%; border: 1px solid #000; background: white;">Expected</th><th style="max-width: 20%; border: 1px solid #000; background: white;">Actual</th><th style="max-width: 10%; border: 1px solid #000; background: white;">Result</th></tr>'
+	size = ARRSIZE('testResults')
+	rowindex = ARRSIZE('ROW')
+	resultindex = 0
+	:testresultprocessloop
+		$ROW[rowindex] = '<tr style="padding: 5px; border: 1px solid #000;"><td style="border: 1px solid #000; padding: 10px; margin-right: 10px;">' + $REPLACE($testResults[resultindex], '; ', '</td><td style="border: 1px solid #000; padding: 10px; margin: 0px 10px 0px 10px;">') + '</td></tr>'
+		rowindex += 1
+		resultindex += 1
+		if resultindex < size: jump 'testresultprocessloop' 
+	$ROW[rowindex] = '</table>'
+	size = ARRSIZE('ROW')
+	index = 0
+	:testresultdisplayloop
+		'<<$ROW[index]>>'
+		index += 1
+	if index < size: jump 'testresultdisplayloop'
+	'<hr>'
+	*nl
+end
+
+if $ARGS[0] = 'saveTestResults':
+	gs 'testframework', 'cleanUpTestData'
+	_TESTSAVED = 1
+	savegame '<<$_TESTSUITE>>-Results-<<$_TESTFILETIME>>.test'
+end
+
+if $ARGS[0] = 'cleanUpTestData':
+	killvar 'daystart'
+	killvar 'month'
+	killvar '$month'
+	killvar 'day'
+	killvar 'week'
+	killvar 'hour'
+
+	killvar 'birthyear'
+	killvar 'birthmonth'
+	killvar 'birthday'
+	killvar 'pcs_haircol'
+	killvar 'pcs_eyesize'
+	killvar 'pcs_lip'
+	killvar 'pcs_lashes'
+
+!!	Body
+	killvar 'pcs_hgt'
+	killvar 'pcs_teeth'
+	killvar 'pcs_butt'
+	killvar 'pcs_skin'
+
+!!	Stats
+	killvar 'pcs_stren'
+	killvar 'strenbuf'
+	killvar 'pcs_agil'
+	killvar 'agilbuf'
+	killvar 'pcs_vital'
+	killvar 'vitalbuf'
+	killvar 'pcs_intel'
+	killvar 'pcs_sprt'
+	killvar 'pcs_react'
+	killvar 'pcs_chrsm'
+	killvar 'pcs_prcptn'
+	killvar 'pcs_magik'
+
+	killvar 'pcs_firstname'
+	killvar 'pcs_lastname'
+	killvar 'pcs_nickname'
+end
+
+--- testframework --------------------------------