Sfoglia il codice sorgente

Added tests for the 'is_solicitation_location' function.

Discovered another issue for testing:
If the tested code checks `$curloc` it's difficult to do it right as the value of `$curloc` is set by the player and can't be changed by code.
netuttki 1 anno fa
parent
commit
de63b22f8d
1 ha cambiato i file con 53 aggiunte e 0 eliminazioni
  1. 53 0
      test/test_prostitution_functions.qsrc

+ 53 - 0
test/test_prostitution_functions.qsrc

@@ -287,6 +287,59 @@ if $ARGS[0] = 'test_prostitute_work_hours_1am_Pushkin':
     killvar 'region'
 end
 
+if $ARGS[0] = 'test_is_solicitation_location_pav_commercial':
+    $TESTNAME = "Location is Pavlovsk Commercial, check if solicitation location check returns true."
+    $FUNCTIONNAME = 'is_solicitation_location'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        $loc = 'pav_commercial'
+        menu_off = 0
+        $loc_arg = ''
+
+        EXPECTED = _TRUE
+        $EXPECTED_MESSAGE = "FUNC('<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>') => <<EXPECTED>>"
+
+        ACTUAL = FUNC($LOCATIONNAME, $FUNCTIONNAME, -1)
+        $ACTUAL_MESSAGE = "FUNC('<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>') => <<ACTUAL>>"
+        TESTRESULT = EXPECTED = ACTUAL
+    else:
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testDefaultCleanup'
+    killvar 'loc'
+    killvar 'menu_off'
+    killvar 'loc_arg'
+end
+
+if $ARGS[0] = 'test_is_solicitation_location_city_center':
+    $TESTNAME = "Location is City Center, check if solicitation location check returns false."
+    $FUNCTIONNAME = 'is_solicitation_location'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        $loc = 'city_center'
+        menu_off = 0
+        $loc_arg = ''
+
+        EXPECTED = _FALSE
+        $EXPECTED_MESSAGE = "FUNC('<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>') => <<EXPECTED>>"
+      
+        ACTUAL = FUNC($LOCATIONNAME, $FUNCTIONNAME, -1)
+        $ACTUAL_MESSAGE = "FUNC('<<$LOCATIONNAME>>', '<<$FUNCTIONNAME>>') => <<ACTUAL>>"
+        TESTRESULT = EXPECTED = ACTUAL
+    else:
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testDefaultCleanup'
+    killvar 'loc'
+    killvar 'menu_off'
+    killvar 'loc_arg'
+end
+
+
 killvar 'LOCATIONNAME'
 killvar '_ISTEST'