Browse Source

Added the resources dir. Expanded instructions

Rafael Arce Nazario 9 years ago
parent
commit
e65d7d0e7e
7 changed files with 87 additions and 26 deletions
  1. 87
    26
      labTesting.md
  2. BIN
      resources/d1.png
  3. BIN
      resources/d2.png
  4. BIN
      resources/d3.png
  5. BIN
      resources/d4.png
  6. BIN
      resources/d5.png
  7. BIN
      resources/d6.png

+ 87
- 26
labTesting.md View File

@@ -9,58 +9,119 @@ Throughout this exercise the students will practice:
9 9
 
10 10
 ## Concepts
11 11
 
12
-As you have learned in previous labs, getting a program to compile is only a minor part of programming. It is super important to test functions in order to validate that they produce the correct results.
12
+As you have learned in previous labs, getting a program to compile is only a minor part of programming. It is super
13
+important to test functions in order to validate that they produce the correct results.
13 14
 
14 15
 
15 16
 ### Exercise 1
16 17
 
17
-This exercise is an adaptation of [1]. You are provided with a program that implements several versions of five simple functions, e.g. rock-paper-scisors, sorting 3 numbers. By testing the versions, you and your partner will determine which of the versions is correctly implemented.   
18
+This exercise is an adaptation of [1]. You are provided with a program that implements several versions of five simple
19
+functions, e.g. rock-paper-scisors, sorting 3 numbers. By testing the versions, you and your partner will determine
20
+which of the versions is correctly implemented.   
18 21
 
19
-This exercise requires **NO programming**, just testing. 
22
+This first exercise requires **NO programming**, just testing.  For this first exercise, you **do not** have to
23
+implement any unit tests.  Just use you testing ability (*by hand*) to determine which function version is the one that
24
+is correctly implemented.  
20 25
 
21
-The functions implemented in the program are:
26
+For instance, let us assume that a friend provides you with a program. He claims that his program solves the following
27
+problem:
22 28
 
23
-* **3 Sorts**: a program that receives three strings and sorts them in lexicographical order. For example, given `jirafa`, `zorra`, and `coqui`. Will sort them as: `coqui`, `jirafa`, and `zorra`.
29
+> *"given three different integers, displays the maximum value"*.  
24 30
 
25
-* **Dice**: when the user presses the `Roll them` button, the program will generate two random numbers between 1 and 6.  The sum of the random numbers is reported. 
31
+Let's say that the program has an interfaces as follows:
26 32
 
27
-* **Rock, Papers, Scissors**: The user enters the play for the two players ( 'R' for Rock, 'P' for Paper and 'S' for Scissors) and specifies the number of games needed to win the tournament. The program then reports who won and the score. The program reports if a player wins the tournament.
33
+![](http://i.imgur.com/BD6SmKh.png)
28 34
 
29
-* **Check Writer**: The user enters a number between 0 and 999,999,999 (inclusive). The program's output is a long string version of the number. For example, if the user inputs '654123' the program will output 'six hundred fifty four thousand one hundred twenty three'.
35
+**Without analysing the source code**, you could determine if the program provides valid results.  You could try the
36
+following cases:
30 37
 
31
-* **Zulu time**: given the time in zulu time (Greenwich Mean Time) and the military zone that the user whishes to know, the program outputs the time at that zone. The format for the input is `####` in 23 hour format, e.g. 2212. The list of valid military zones is given in http://en.wikipedia.org/wiki/List_of_military_time_zones. Examples of correct output:
38
+* a = 4, b = 2, c = 1, expect result: 4
39
+* a = 3, b = 6, c = 2, expected result: 6
40
+* a = 1, b = 10, c = 100, expected result: 100
41
+
42
+If any of the three cases fails to give the expected result, you friend's program is not working. On the other hand, If
43
+all three cases are successful, then the program has a high probability of being correct.
44
+
45
+In this exercise, you will be validating various versions of the following functions:
46
+
47
+* **3 Sorts**: a program that receives three strings and sorts them in lexicographical order. For example, given
48
+`jirafa`, `zorra`, and `coqui`. Will sort them as: `coqui`, `jirafa`, and `zorra`.
49
+
50
+* **Dice**: when the user presses the `Roll them` button, the program will generate two random numbers between 1 and 6.
51
+The sum of the random numbers is reported. 
52
+
53
+* **Rock, Papers, Scissors**: The user enters the play for the two players ( 'R' for Rock, 'P' for Paper and 'S' for
54
+Scissors) and specifies the number of games needed to win the tournament. The program then reports who won and the
55
+score. The program reports if a player wins the tournament.
56
+
57
+* **Check Writer**: The user enters a number between 0 and 999,999,999 (inclusive). The program's output is a long
58
+string version of the number. For example, if the user inputs '654123' the program will output 'six hundred fifty four
59
+thousand one hundred twenty three'.
60
+
61
+* **Zulu time**: given the time in zulu time (Greenwich Mean Time) and the military zone that the user whishes to know,
62
+the program outputs the time at that zone. The format for the input is `####` in 23 hour format, e.g. 2212. The list of
63
+valid military zones is given in http://en.wikipedia.org/wiki/List_of_military_time_zones. Examples of correct output:
32 64
     * Given 1230 and zone A, the output would be 1330
33
-    * Given 1230 and zone N, the output would be 1130
65
+        * Given 1230 and zone N, the output would be 1130
66
+
67
+
68
+        Step 1: 
69
+        For each of the functions described above, write down in your notebook the tests that you will perform in order
70
+        to determine validity. 
71
+
72
+        Step 2: 
73
+        Download the program from $XYZ$.
74
+
75
+        Step 3:
76
+        Run the program. You will see a window similar to the following:
77
+
78
+        ![](http://demo05.cloudimage.io/s/resize/300/i.imgur.com/Uxnb8jP.png)
79
+
80
+        Click the **3 Sorts** button and you will get the following:
81
+
82
+        ![](http://demo05.cloudimage.io/s/resize/300/i.imgur.com/p1NLIdM.png)
34 83
 
35
-Step 1: 
36
-Download the program from $XYZ$.
84
+        The "Version Alpha" combo box indicates that you are running the first version of the 3 Sorts algorithm. Use the
85
+        tests that you wrote in step 1 to validate "Version Alpha". Then, do the same for versions beta, gamma and
86
+        delta.  Report which is the correct version in every method. Also, explain the tests that you performed that
87
+        allowed you to determine that the other versions are incorrect. 
37 88
 
38
-Step 2:
39
-Run the program. For each of the functions, test all the versions and determine which is the valid one. Report which is the correct version in every method. Also, explain the tests that you performed that allowed you to determine that the other versions are incorrect. 
89
+        For example, you could organice your results into a table. 
40 90
 
91
+        | Num | Test | Alpha | Beta | Gamma | Delta | 
92
+        | ------------- | ----------- | ----------- | ----------- | ----------- | ----------- |
93
+        | 1| "alce", "coyote", "zorro" | "alce", "coyote", "zorro" | .... | .... |
94
+        | 2| "alce", "zorro", "coyote" | "zorro", "alce", "coyote" | .... | .... |
41 95
 
42 96
 ### Exercise 2
43 97
 
44
-Running tests "by hand" each time that you run a program gets tiresome very quickly. You and your partner have done it for a few simple functions. Imagine doing the same for full-blown program!, such as a browser or word processor.
98
+Running tests "by hand" each time that you run a program gets tiresome very quickly. You and your partner have done it
99
+for a few simple functions. Imagine doing the same for full-blown program!, such as a browser or word processor.
45 100
 
46
-Unit tests help programmers produce valid code and ease the process of debugging while avoiding the tedious task of entering tests by hand on each execution.
101
+    *Unit tests* help programmers produce valid code and ease the process of debugging while avoiding the tedious task
102
+    of entering tests by hand on each execution.
47 103
 
48 104
 
49
-Step 1: 
50
-Download the proyect from $XYZ$. The proyect contains only one source code file `main.cpp`. This file contains four functions whose results are only partially correct. Your task is to write unit tests for each them to identify their wrong results. 
105
+    Step 1: 
106
+    Download the proyect from $XYZ$. The proyect contains only one source code file `main.cpp`. This file contains four
107
+    functions whose results are only partially correct. Your task is to write unit tests for each them to identify their
108
+    wrong results.  **You do not need to rewrite the functions to correct them**.
51 109
 
52
-A unit test function `test_fact()` is provided for the function `fact`. If you invoke this function from `main` and compile and run the program. You will get the following message:
110
+    A unit test function `test_fact()` is provided for the function `fact`. If you invoke this function from `main` and
111
+    compile and run the program. You will get the following message:
53 112
 
54
-```cpp
55
-Assertion failed: (fact(2) == 2), function test_fact, file ../UnitTests/main.cpp, line 69.
56
-``` 
113
+    ```cpp
114
+    Assertion failed: (fact(2) == 2), function test_fact, file ../UnitTests/main.cpp, line 69.
115
+    ``` 
57 116
 
58
-This would be enough for us to claim that function `fact` is not correctly implemented. Comment the invocation of `test_fact()` from main.
117
+    This would be enough for us to claim that function `fact` is not correctly implemented. Comment the invocation of
118
+    `test_fact()` from main.
59 119
 
60
-Step 2:
61
-Write unit tests for the rest of the functions. Remember that you must call each of the unit test functions from the `main` for them to run. Copy each of the functions in the provided sheet.
120
+    Step 2:
121
+    Write unit tests for the rest of the functions. Remember that you must call each of the unit test functions from the
122
+    `main` for them to run. Copy each of the functions in the provided sheet.
62 123
 
63 124
 
64 125
 ### References
65 126
 
66
-[1] http://nifty.stanford.edu/2005/TestMe/
127
+[1] http://nifty.stanford.edu/2005/TestMe/

BIN
resources/d1.png View File


BIN
resources/d2.png View File


BIN
resources/d3.png View File


BIN
resources/d4.png View File


BIN
resources/d5.png View File


BIN
resources/d6.png View File