Skip to content

Commit

Permalink
added save tc functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
dv-rastogi committed May 27, 2021
1 parent b092f60 commit 508242a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 10 additions & 2 deletions stress-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ def fail(tc, my_response, brute_response):
print(*my_response, sep = '\n')
print("\n-- Brute Output --\n")
print(*brute_response, sep = '\n')

if user_config["saveTC"] is not None:
with open(user_config["inputPipe"], "r") as f1:
lines = f1.readlines()
with open(user_config["saveTC"], "w") as f2:
f2.writelines(lines)
print(colored(f"\n> Test case saved at {user_config['saveTC']}", 'yellow'))

exit(0)


# TESTING LOOP =============>
print(colored("\n#### Stress Testing .. ####", 'cyan', attrs = ['bold']))
for currentTc in range(1, user_config["TestCases"] + 1):
for currentTc in range(1, user_config["testCases"] + 1):

# fetching test case
tc = gen_case()
if user_config["Usedtt"]:
if user_config["usedtt"]:
tc = ["1"] + tc
if user_config["debug"]:
print("Test case")
Expand Down
18 changes: 10 additions & 8 deletions user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
'''
user_config params:-
TestCases: Number of testCases to test against
Usedtt: Multiple testCases in input (NOTE: Refresh each global parameter after each test case)
testCases: Number of testCases to test against
usedtt: Multiple testCases in input (NOTE: Refresh each global parameter after each test case)
showEachPass: Print affirmative after each test case passed
removeBlanks: remove blanks (whitespaces) in the output
whereFail: print where the output doesn't match
inputPipe: input file used to feed input to executables
debug: for each input -> print input, your output & brute output
saveTC: path to a file which stores the failed test case, None if file is not to be saved
'''
user_config = {
"TestCases" : 1000,
"Usedtt" : False,
"testCases" : 1000,
"usedtt" : False,
"showEachPass" : True,
"removeBlanks" : True,
"whereFail" : True,
"inputPipe" : "temp/inputf.in",
"debug": False
"debug": False,
"saveTC": "sols/in.txt"
}


Expand All @@ -36,10 +38,10 @@
list of strings where each string is supposed to be displaed on a new line
'''
def gen_case():
lim = int(1000)
dlim = 100
lim = int(10)
dlim = 10
n = random.randint(1, lim)
a = [random.randint(1, dlim) for i in range(n)]
a = [random.randint(-dlim, dlim) for i in range(n)]
tc = [str(n), ' '.join(list(map(str, a)))]
return tc

Expand Down

0 comments on commit 508242a

Please sign in to comment.