summaryrefslogtreecommitdiff
path: root/c2prj2_testing
diff options
context:
space:
mode:
Diffstat (limited to 'c2prj2_testing')
-rw-r--r--c2prj2_testing/README122
-rw-r--r--c2prj2_testing/example.txt1
-rw-r--r--c2prj2_testing/grade.txt26
-rwxr-xr-xc2prj2_testing/run_all.sh30
-rwxr-xr-xc2prj2_testing/test-evalbin0 -> 95120 bytes
-rw-r--r--c2prj2_testing/tests.txt30
6 files changed, 209 insertions, 0 deletions
diff --git a/c2prj2_testing/README b/c2prj2_testing/README
new file mode 100644
index 0000000..17a11a6
--- /dev/null
+++ b/c2prj2_testing/README
@@ -0,0 +1,122 @@
+The second part of this course's poker project is to write
+test cases for what you will do in the next course.
+
+In particular, one of the things you will do in your
+project in Course 3 is write the code to evaluate
+which poker hand wins between two complete hands.
+This involves writing all the code to figure out
+what kind of hand (straight flush, full house, etc.)
+is in a hand, and which 5 cards ultimately make it up.
+For example, if one hand is
+
+0c 0s 8s 7d 6d 6s 5c
+
+and the other is
+
+Js 0s 8s 7d 6s 5c 4c
+
+your code in the next course will figure out that
+the first hand has two pairs (10s and 6s) with an 8
+as the tie-breaking card (called the "kicker"),
+and that the second hand has a straight (8 7 6 5 4).
+The straight beats the two pairs, so hand 2 wins.
+
+We have provided you with test-eval, which reads
+a file containing lines with one pair of hands
+on each line and prints out the details of evaluating
+that hand. Each line has one hand, a semi-colon,
+then the other hand, so the input for the above would
+be:
+
+0c 0s 8s 7d 6d 6s 5c; Js 0s 8s 7d 6s 5c 4c
+
+We have put this in example.txt. If you run
+
+./test-eval example.txt
+
+Then you will get the following output:
+
+Hand 1:
+--------
+0c 0s 8s 7d 6d 6s 5c
+ - No flush
+ - The most of a kind is 2 of a kind (at index 0 / value 0)
+ - Secondary pair at index 4 (value 6)
+ - evaluate_hand's ranking: TWO_PAIR
+ - 5 cards used for hand: 0c 0s 6d 6s 8s
+Hand 2:
+--------
+Js 0s 8s 7d 6s 5c 4c
+ - No flush
+ - Straight at index 2
+ - The most of a kind is 1 of a kind (at index 0 / value J)
+ - No secondary pair
+ - evaluate_hand's ranking: STRAIGHT
+ - 5 cards used for hand: 8s 7d 6s 5c 4c
+Comparison :
+--------------
+Hand 2 wins!
+============================
+
+You can see that for each hand, this program not only prints
+the overall ranking (STRAIGHT, TWO_PAIR, etc), but also the
+results of various parts of the evaluation that went into
+the decision: Was there a flush? Was there a straight (if
+so, where?) How many of a kind were there? etc.
+
+As with other testing assignments, we have written
+some broken implementations and placed them in
+/usr/local/l2p/poker/
+
+Your goal is to write testcases in tests.txt
+that test this problem sufficiently to identify
+the problem in each broken implementation we provided.
+
+You can use the run_all.sh script that we provided
+to run your test cases against all implementations.
+
+Here are some hints:
+====================
+
+ - Straights are tricky. Think about various ways that a programmer
+ might mess up in finding a straight. These problems could include
+ both figuring out if there is a straight as well as copying out the
+ cards that make up the straight (or straight flush).
+
+ There could even be an off-by-one bug in where to look for a straight
+ in the hand ("count from 0 to the number of cards in the hand minus
+ [something], call it i. Check if a straight starts at position i"
+ In such an algorithm, [something] could be off by one)
+
+ - Think about ways in which a programmer might mis-think about what
+ they need to do. For example, one might think you can check for a
+ straight flush by checking for a straight AND a flush, but that is
+ not correct (with more than 5 cards, you could have some that are a
+ straight but others of the same suit).
+
+ - Be sure to just provide simple coverage of the basic cases (each
+ type of hand outcome, etc).
+
+ - The suits are numbers, and can be iterated across )where do you
+ think we iterate over all the suits?). What if we counted wrong
+ when iterating over the suits?
+
+
+ - Two pairs have some subtle cases in terms of selecting the right 5
+ cards for the final hand. Remember from the reading that the way
+ tie breaking works requires the final 5 card hand to be ordered:
+ (larger pair) (smaller pair) (tiebreaker)
+
+ - Think about everywhere the programer could be off-by-one.
+ This might include such things as counting through all the
+ positions in the hand (either missing the start or the end),
+ or being off-by-one in how many cards are required
+ for a particular hand (e.g., only requiring 4
+ cards meet a particular condition instead of 5).
+
+ - Note that you may be able to 'game' your way into passing all
+ the tests locally, but if you do this you won't actually pass the
+ assignment. The only way to pass is to provide good tests.
+
+ - Note additionally that you do not need to use invalid cards
+ in your tests.
diff --git a/c2prj2_testing/example.txt b/c2prj2_testing/example.txt
new file mode 100644
index 0000000..b6f6824
--- /dev/null
+++ b/c2prj2_testing/example.txt
@@ -0,0 +1 @@
+0c 0s 8s 7d 6d 6s 5c; Js 0s 8s 7d 6s 5c 4c
diff --git a/c2prj2_testing/grade.txt b/c2prj2_testing/grade.txt
new file mode 100644
index 0000000..02ff23b
--- /dev/null
+++ b/c2prj2_testing/grade.txt
@@ -0,0 +1,26 @@
+Grading at Mon 29 Nov 2021 02:22:00 AM UTC
+Your test cases identified the problem with test-eval-0000
+Your test cases identified the problem with test-eval-0001
+Your test cases identified the problem with test-eval-0002
+Your test cases identified the problem with test-eval-0003
+Your test cases identified the problem with test-eval-0004
+Your test cases identified the problem with test-eval-0005
+Your test cases identified the problem with test-eval-0006
+Your test cases identified the problem with test-eval-0007
+Your test cases identified the problem with test-eval-0008
+Your test cases identified the problem with test-eval-0009
+Your test cases identified the problem with test-eval-0010
+Your test cases identified the problem with test-eval-0011
+Your test cases identified the problem with test-eval-0012
+Your test cases identified the problem with test-eval-0013
+Your test cases identified the problem with test-eval-0014
+Your test cases identified the problem with test-eval-0015
+Your test cases identified the problem with test-eval-0016
+Your test cases identified the problem with test-eval-0017
+Your test cases identified the problem with test-eval-0018
+Your test cases identified the problem with test-eval-0019
+Your test cases identified the problem with test-eval-0020
+Your test cases identified the problem with test-eval-0021
+Your test cases identified the problem with test-eval-0022
+
+Overall Grade: PASSED
diff --git a/c2prj2_testing/run_all.sh b/c2prj2_testing/run_all.sh
new file mode 100755
index 0000000..a963b62
--- /dev/null
+++ b/c2prj2_testing/run_all.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+run_test(){
+ prog="$1"
+ testfile="$2"
+ IFS=$'\n'
+ IFS=" " correct=`/usr/local/l2p/poker/correct-test-eval $testfile 2>&1`
+ IFS=" " broken=`$prog $testfile 2>&1`
+ if [ "$broken" != "$correct" ]
+ then
+ return 0
+ fi
+ return 1
+}
+
+found=0
+notfound=0
+for i in /usr/local/l2p/poker/test-eval-*
+do
+ run_test $i tests.txt
+ x="$?"
+ if [ "$x" != "0" ]
+ then
+ echo "Your test cases did not identify the problem with `basename $i`"
+ let notfound=${notfound}+1
+ else
+ let found=${found}+1
+ fi
+done
+echo "Test cases identified $found problems"
+echo "Test cases failed to identify $notfound problems"
diff --git a/c2prj2_testing/test-eval b/c2prj2_testing/test-eval
new file mode 100755
index 0000000..bc28c9b
--- /dev/null
+++ b/c2prj2_testing/test-eval
Binary files differ
diff --git a/c2prj2_testing/tests.txt b/c2prj2_testing/tests.txt
new file mode 100644
index 0000000..63059d5
--- /dev/null
+++ b/c2prj2_testing/tests.txt
@@ -0,0 +1,30 @@
+Kc Qs Jd 9h 8c 7s 6d; Ac Qs Jd 9h 8c 7s 6d
+Kh Ac Kc 8c 7h 3d 6s; Kh As 7h 3s 5d 6h Ks
+As Ah Ks Kd 2h 3d 6s; Ac Ad Kh Kc Jd 3d 6s
+Kh Kc Kd Ac 3s 6h 2s; Kh Kc Kd Ac 7h 6s 3d
+Ks Qd Js 0h 6h 9d 2s; 0h 5d 8s 4s 3c 2h Ah
+Ah Qh 5s 6d 9h 7h 2h; 4s 6s 5s 7d 0s Qs As
+Kc Ks 3d 0c 0s Kh 8d; 9h Jd 9s Js 9d 3d 0c
+0c 0s 0h 2d 7c 0d 2h; Kc Kd Kh Ks 3c 4h 5d
+As 2d 3c Ks Qs Js 0s; 5s 4s 3s 2d Jc 2s As
+As Ks 4d 5d Jd 0d Qd; Kd Qd Js 0s 9s 4s 5s
+Qd Jd 0d 9s 9h 8h 8c; Jd 0d 9d 8s 8h 7h 7c
+0c 0s 8s 7d 6d 6s 5c; Js 0s 8s 7d 6s 5c 4c
+2d 3d 6d 8d 7c As Js; 2d 3d 6d 8d 7c Ah Ac
+Ac 2d 3c 0s 4d 5s 0h; Ac 2d 3c 0s 4d 8h Jh
+6c 3c 6d 4h Qs As 2d; 6c 3c 6d 4h Qs 2h Jh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