Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test folder #41

Open
gabrielcarneiro97 opened this issue Jul 31, 2019 · 2 comments
Open

Test folder #41

gabrielcarneiro97 opened this issue Jul 31, 2019 · 2 comments
Labels
🆘 help wanted Extra attention is needed ⭐ enhancement New feature or request

Comments

@gabrielcarneiro97
Copy link
Collaborator

I belive that would be good to have a folder with some default inputs and outputs, so anyone that wants to add some solution in any given language must post with it the outputs of his code too, its kind important to have some sort of validation to the added codes.

My idea is to create a folder with numbered folders in it, related to the number of the test, so if exists 20 tests, the folder tests will contain 20 folders numbered from 1 to 20.

stalin-sort/tests/1...20

In each of this folders will exist 2 .txt files, one called input and other one called output. This files will contain numbers with pipes ( | ) between them.

EXAMPLE

stalin-sort/tests/1

input.txt

1|2|3|4|5|2

output.txt

1|2|3|4|5
@gabrielcarneiro97 gabrielcarneiro97 added 🆘 help wanted Extra attention is needed ⭐ enhancement New feature or request labels Aug 1, 2019
@ration
Copy link

ration commented Aug 2, 2019

If implementations support reading from stdin we could create a testbench that feeds random sequences in and verifies it's correctness .

One testbench could be to verify it's sorted:

for i in  `seq 1000`; do echo $RANDOM; done | CALL IMPL | sort -n -c

Example with awk StalinSort:

for i in `seq 1000`; do echo $RANDOM; done | awk '{if (f <= $1) { print $1; f=$1+0}}' | sort -c -n

Second step would be to compare the output to a known correct implementation.

A third step would be to verify that the output is truly O(n), which might be trickier.

@eggplants
Copy link
Contributor

I suggest :

# make test folder
mkdir test
# create 20 test files
# 1. Vertical (Each number is separated by a break line)
seq 20 | while read i;do shuf -rn100 -i1-1000 > test/$i;done

# 2. Horizontal (Each number is separated by a space)
seq 20 | while read i;do shuf -rn100 -i1-1000 | xargs > test/$i;done

That's enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆘 help wanted Extra attention is needed ⭐ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants