Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
test_d01 and test_d02 now working
Browse files Browse the repository at this point in the history
  • Loading branch information
Millon15 committed Jan 16, 2019
1 parent ea7dc24 commit 61ee632
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 144 deletions.
170 changes: 85 additions & 85 deletions unit-tests/test_d01.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
# START OF TESTS START OF TESTS START OF TESTS START OF TESTS

# ex00
test_command(day_location + "ex00/hw.php", "Hello World\n")
test_command('php ' + day_location + "ex00/hw.php", "Hello World\n")
print("")

# ex01
# test_command(helpers + "helper_ex01.zsh '" + day_location + "ex01/mlx.php'", "")
test_command(day_location + "ex01/mlx.php", "X" * 1000 + "\n")
# test_command('php ' + helpers + "helper_ex01.zsh '" + day_location + "ex01/mlx.php'", "")
test_command('php ' + day_location + "ex01/mlx.php", "X" * 1000 + "\n")
print("")

# ex02 at bototm of file

# ex03
test_command(helpers + 'helper_ex03.php ' + day_location \
test_command('php ' + helpers + 'helper_ex03.php ' + day_location \
+ ' "Hello World AAA"' \
+ ' " b d w r "' \
+ ' " "' \
Expand Down Expand Up @@ -62,31 +62,31 @@
print("")

# ex04
test_command(day_location + "ex04/aff_param.php", "")
test_command(day_location + "ex04/aff_param.php toto ahah foo bar quax", """toto
test_command('php ' + day_location + "ex04/aff_param.php", "")
test_command('php ' + day_location + "ex04/aff_param.php toto ahah foo bar quax", """toto
ahah
foo
bar
quax
""")
test_command(day_location + 'ex04/aff_param.php ""', """
test_command('php ' + day_location + 'ex04/aff_param.php ""', """
""")
test_command(day_location + 'ex04/aff_param.php "a"', """a
test_command('php ' + day_location + 'ex04/aff_param.php "a"', """a
""")
print("")

# ex05
test_command(day_location + 'ex05/epur_str.php', "")
test_command(day_location + 'ex05/epur_str.php "Salut, comment ca va ?"', "Salut, comment ca va ?\n")
test_command(day_location + 'ex05/epur_str.php " Hello World "', "Hello World\n")
test_command('php ' + day_location + 'ex05/epur_str.php', "")
test_command('php ' + day_location + 'ex05/epur_str.php "Salut, comment ca va ?"', "Salut, comment ca va ?\n")
test_command('php ' + day_location + 'ex05/epur_str.php " Hello World "', "Hello World\n")
print("")

# ex06
test_command(day_location + 'ex06/ssap.php', "")
test_command(day_location + 'ex06/ssap.php foo bar', """bar
test_command('php ' + day_location + 'ex06/ssap.php', "")
test_command('php ' + day_location + 'ex06/ssap.php foo bar', """bar
foo
""")
test_command(day_location + 'ex06/ssap.php foo bar "yo man" "A moi compte, deux mots" Xibul', """A
test_command('php ' + day_location + 'ex06/ssap.php foo bar "yo man" "A moi compte, deux mots" Xibul', """A
Xibul
bar
compte,
Expand All @@ -100,31 +100,31 @@
print("")

# ex07
test_command(day_location + 'ex07/rostring.php', "")
test_command(day_location + 'ex07/rostring.php sdfkjsdkl sdkjfskljdf', "sdfkjsdkl\n")
test_command(day_location + 'ex07/rostring.php "hello world aaa" fslkdjf', "world aaa hello\n")
test_command(day_location + 'ex07/rostring.php "a b" fslkdjf', "b a\n")
test_command(day_location + 'ex07/rostring.php "a"', "a\n")
test_command(day_location + 'ex07/rostring.php "c b a"', "b a c\n")
test_command(day_location + 'ex07/rostring.php "a b c d e f g h i j k l"', "b c d e f g h i j k l a\n")
test_command('php ' + day_location + 'ex07/rostring.php', "")
test_command('php ' + day_location + 'ex07/rostring.php sdfkjsdkl sdkjfskljdf', "sdfkjsdkl\n")
test_command('php ' + day_location + 'ex07/rostring.php "hello world aaa" fslkdjf', "world aaa hello\n")
test_command('php ' + day_location + 'ex07/rostring.php "a b" fslkdjf', "b a\n")
test_command('php ' + day_location + 'ex07/rostring.php "a"', "a\n")
test_command('php ' + day_location + 'ex07/rostring.php "c b a"', "b a c\n")
test_command('php ' + day_location + 'ex07/rostring.php "a b c d e f g h i j k l"', "b c d e f g h i j k l a\n")
print("")

# ex08
test_command(helpers + 'helper_ex08.php ' + day_location + ' ""', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "" ""', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "c b"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b 1"', "unsorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j j"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j j j j j"', "sorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j i"', "unsorted")
test_command(helpers + 'helper_ex08.php ' + day_location + ' "b a c d e f"', "unsorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' ""', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "" ""', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "c b"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b 1"', "unsorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j j"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j j j j j"', "sorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "a b c d e f g h i j i"', "unsorted")
test_command('php ' + helpers + 'helper_ex08.php ' + day_location + ' "b a c d e f"', "unsorted")
print("")

test_command(day_location + 'ex09/ssap2.php', "")
test_command(day_location + 'ex09/ssap2.php toto tutu 4234 "_hop XXX" "##" "1948372 AhAhAh"', """AhAhAh
test_command('php ' + day_location + 'ex09/ssap2.php', "")
test_command('php ' + day_location + 'ex09/ssap2.php toto tutu 4234 "_hop XXX" "##" "1948372 AhAhAh"', """AhAhAh
toto
tutu
XXX
Expand All @@ -133,75 +133,75 @@
##
_hop
""")
test_command(day_location + 'ex09/ssap2.php aaa aaaa', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php aaa aaaa', """aaa
aaaa
""")
test_command(day_location + 'ex09/ssap2.php "aaa aaaa"', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php "aaa aaaa"', """aaa
aaaa
""")
test_command(day_location + 'ex09/ssap2.php "hello "', """hello
test_command('php ' + day_location + 'ex09/ssap2.php "hello "', """hello
""")
test_command(day_location + 'ex09/ssap2.php "aaaa aaa"', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php "aaaa aaa"', """aaa
aaaa
""")
test_command(day_location + 'ex09/ssap2.php aaaa aaa', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php aaaa aaa', """aaa
aaaa
""")
# TODO: someone some tests here to test the ord thingy
print("")

test_command(day_location + 'ex10/do_op.php', "Incorrect Parameters\n")
test_command(day_location + 'ex10/do_op.php "" "" "" "fourth"', "Incorrect Parameters\n")
test_command(day_location + 'ex10/do_op.php "first" "second"', "Incorrect Parameters\n")
test_command(day_location + 'ex10/do_op.php 1 + 3', "4\n")
test_command(day_location + 'ex10/do_op.php 1 - 3', "-2\n")
test_command(day_location + 'ex10/do_op.php 5 * 3', "15\n")
test_command(day_location + 'ex10/do_op.php 99 * 189274987', "18738223713\n")
test_command(day_location + 'ex10/do_op.php " 1" " *" " 3"', "3\n")
test_command(day_location + 'ex10/do_op.php 42 "% " 3', "0\n")
test_command(day_location + 'ex10/do_op.php " 1 " + 3', "4\n")
test_command(day_location + 'ex10/do_op.php " 5" " * " 3', "15\n")
test_command(day_location + 'ex10/do_op.php "\t5" "*\t" "3\t"', "15\n")
test_command(day_location + 'ex10/do_op.php "5" "*" "\t3"', "15\n")
test_command(day_location + 'ex10/do_op.php "5" "\t*" "3"', "15\n")
test_command(day_location + 'ex10/do_op.php "\t5" "*" "3"', "15\n")
test_command(day_location + 'ex10/do_op.php "\t 5 \t" " \t *\t " "\t3 "', "15\n")
test_command(day_location + 'ex10/do_op.php "-3 \t " " \t * " " -3"', "9\n")
test_command(day_location + 'ex10/do_op.php " 50" "% " " 20"', "10\n")
test_command(day_location + 'ex10/do_op.php "-3 " " *" " -3"', "9\n")
test_command(day_location + 'ex10/do_op.php "-3" "/ " " 2"', "-1.5\n")
test_command(day_location + 'ex10/do_op.php "-3 " "+ " " 5"', "2\n")
test_command('php ' + day_location + 'ex10/do_op.php', "Incorrect Parameters\n")
test_command('php ' + day_location + 'ex10/do_op.php "" "" "" "fourth"', "Incorrect Parameters\n")
test_command('php ' + day_location + 'ex10/do_op.php "first" "second"', "Incorrect Parameters\n")
test_command('php ' + day_location + 'ex10/do_op.php 1 + 3', "4\n")
test_command('php ' + day_location + 'ex10/do_op.php 1 - 3', "-2\n")
test_command('php ' + day_location + 'ex10/do_op.php 5 * 3', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php 99 * 189274987', "18738223713\n")
test_command('php ' + day_location + 'ex10/do_op.php " 1" " *" " 3"', "3\n")
test_command('php ' + day_location + 'ex10/do_op.php 42 "% " 3', "0\n")
test_command('php ' + day_location + 'ex10/do_op.php " 1 " + 3', "4\n")
test_command('php ' + day_location + 'ex10/do_op.php " 5" " * " 3', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "\t5" "*\t" "3\t"', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "5" "*" "\t3"', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "5" "\t*" "3"', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "\t5" "*" "3"', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "\t 5 \t" " \t *\t " "\t3 "', "15\n")
test_command('php ' + day_location + 'ex10/do_op.php "-3 \t " " \t * " " -3"', "9\n")
test_command('php ' + day_location + 'ex10/do_op.php " 50" "% " " 20"', "10\n")
test_command('php ' + day_location + 'ex10/do_op.php "-3 " " *" " -3"', "9\n")
test_command('php ' + day_location + 'ex10/do_op.php "-3" "/ " " 2"', "-1.5\n")
test_command('php ' + day_location + 'ex10/do_op.php "-3 " "+ " " 5"', "2\n")
print("")

test_command(day_location + "ex11/do_op_2.php", "Incorrect Parameters\n")
test_command(day_location + "ex11/do_op_2.php first second", "Incorrect Parameters\n")
test_command(day_location + "ex11/do_op_2.php toto", "Syntax Error\n")
test_command(day_location + 'ex11/do_op_2.php "42 * 2" ', "84\n")
test_command(day_location + 'ex11/do_op_2.php "42 / 2" ', "21\n")
test_command(day_location + 'ex11/do_op_2.php "42 % 2" ', "0\n")
test_command(day_location + 'ex11/do_op_2.php "42 % 3" ', "0\n")
test_command(day_location + 'ex11/do_op_2.php "42 - 2" ', "40\n")
test_command(day_location + 'ex11/do_op_2.php "six6*7sept" ', "Syntax Error\n")
test_command(day_location + 'ex11/do_op_2.php "ls -lR /" ', "Syntax Error\n")
test_command(day_location + 'ex11/do_op_2.php "10000 * 20000000" ', "200000000000\n")
test_command(day_location + 'ex11/do_op_2.php "-3 \t \t * -3" ', "9\n")
test_command(day_location + 'ex11/do_op_2.php "50 % 20" ', "10\n")
test_command(day_location + 'ex11/do_op_2.php "-3 * -3" ', "9\n")
test_command(day_location + 'ex11/do_op_2.php "-3 / 2" ', "-1.5\n")
test_command(day_location + 'ex11/do_op_2.php "-3 + 5" ', "2\n")
test_command('php ' + day_location + "ex11/do_op_2.php", "Incorrect Parameters\n")
test_command('php ' + day_location + "ex11/do_op_2.php first second", "Incorrect Parameters\n")
test_command('php ' + day_location + "ex11/do_op_2.php toto", "Syntax Error\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "42 * 2" ', "84\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "42 / 2" ', "21\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "42 % 2" ', "0\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "42 % 3" ', "0\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "42 - 2" ', "40\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "six6*7sept" ', "Syntax Error\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "ls -lR /" ', "Syntax Error\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "10000 * 20000000" ', "200000000000\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "-3 \t \t * -3" ', "9\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "50 % 20" ', "10\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "-3 * -3" ', "9\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "-3 / 2" ', "-1.5\n")
test_command('php ' + day_location + 'ex11/do_op_2.php "-3 + 5" ', "2\n")
print("")

test_command(day_location + 'ex12/search_it!.php', "")
test_command(day_location + 'ex12/search_it!.php toto', "")
test_command(day_location + 'ex12/search_it!.php toto "key1:val1" "key2:val2" "toto:42"', "42\n")
test_command(day_location + 'ex12/search_it!.php toto "toto:val1" "key2:val2" "toto:42"', "42\n")
test_command(day_location + 'ex12/search_it!.php "toto" "key1:val1" "key2:val2" "0:hop"', "")
test_command(day_location + 'ex12/search_it!.php "0" "key1:val1" "key2:val2" "0:hop"', "hop\n")
test_command('php ' + day_location + 'ex12/search_it!.php', "")
test_command('php ' + day_location + 'ex12/search_it!.php toto', "")
test_command('php ' + day_location + 'ex12/search_it!.php toto "key1:val1" "key2:val2" "toto:42"', "42\n")
test_command('php ' + day_location + 'ex12/search_it!.php toto "toto:val1" "key2:val2" "toto:42"', "42\n")
test_command('php ' + day_location + 'ex12/search_it!.php "toto" "key1:val1" "key2:val2" "0:hop"', "")
test_command('php ' + day_location + 'ex12/search_it!.php "0" "key1:val1" "key2:val2" "0:hop"', "hop\n")
print("")

#ex13
test_command(day_location + 'ex13/agent_stats.php < ' + '' + helpers + 'resources01/peer_notes_1.csv', "")
# test_command(day_location + 'ex13/agent_stats.php < ' + 'average' + helpers + 'resources01/peer_notes_1.csv', "9.8621262458472")
test_command('php ' + day_location + 'ex13/agent_stats.php < ' + '' + helpers + 'resources01/peer_notes_1.csv', "")
# test_command('php ' + day_location + 'ex13/agent_stats.php < ' + 'average' + helpers + 'resources01/peer_notes_1.csv', "9.8621262458472")
print("")

# END OF TESTS END OF TESTS END OF TESTS END OF TESTS END OF TESTS
Expand All @@ -227,7 +227,7 @@
Other:
C-d to close should exit smoothly""")

# test_command(day_location + 'ex02/oddeven.php < ' + helpers + 'helper_ex02.txt',
# test_command('php ' + day_location + 'ex02/oddeven.php < ' + helpers + 'helper_ex02.txt',
# """Enter a number: The number 42 is even
# Enter a number: The number 0 is even
# Enter a number: The number -0 is even
Expand Down
Loading

0 comments on commit 61ee632

Please sign in to comment.