summaryrefslogtreecommitdiff
path: root/26_tests_matrix_input
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /26_tests_matrix_input
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to '26_tests_matrix_input')
-rw-r--r--26_tests_matrix_input/README51
-rw-r--r--26_tests_matrix_input/grade.txt20
-rw-r--r--26_tests_matrix_input/input.110
-rw-r--r--26_tests_matrix_input/input.101
-rw-r--r--26_tests_matrix_input/next-README46
-rwxr-xr-x26_tests_matrix_input/run_all.sh30
-rw-r--r--26_tests_matrix_input/tests.txt15
7 files changed, 173 insertions, 0 deletions
diff --git a/26_tests_matrix_input/README b/26_tests_matrix_input/README
new file mode 100644
index 0000000..e1b7431
--- /dev/null
+++ b/26_tests_matrix_input/README
@@ -0,0 +1,51 @@
+For this assignment, you will be writing test cases for your next
+assignment. As usual, the instructions for the next assignment are
+in next-README.
+
+For this assignment, we have created compiled binaries (in
+/usr/local/l2p/rot_matrix/ where rotateMatrix is correct,
+and the numbered ones are each broken in some way).
+
+As with 09_testing2, you will write a file called tests.txt,
+which will list the command line arguments you want to use to
+run the programs. However, unlike 09_testing2, you will
+also want to create a wide variety of input files. You can
+name them anything you want, as long as you save them in the
+current (26_tests_matrix_input) directory, and submit them
+along with tests.txt.
+
+As usual, we have provided run_all.sh
+
+Hint 1: think about various error cases that the programmer
+might have forgotten!
+
+Hint 2: The trickiest of these is one in which the programmer
+did not pay attention to a rather subtle, but common mistake
+pointed out in your reading titled 'Reading a File'!
+
+Hint 3: If you find yourself needing to create an input
+file with non-typable/non-printable characters in it,
+you will want to do a few things.
+
+First, (after you have the file you want to edit open), you
+will want to force emacs to change the encoding it uses
+(so that it won't try to rewrite things in Unicode, for example):
+
+M-x revert-buffer-with-coding-system
+raw-text
+
+Once you have done this, you can do
+
+M-x hexl-mode
+
+to put emacs in hex editor mode.
+
+Then you will see hex values on the left, and their printable
+interpreations (or . for non-printable characters) on the right.
+Move the point to where you want to put a particular value, and do
+
+C-M-x
+
+then type the hex value (one byte, so two hex digits) that you want,
+and hit enter. It will overwrite the current character with that value.
+Then you can save the file.
diff --git a/26_tests_matrix_input/grade.txt b/26_tests_matrix_input/grade.txt
new file mode 100644
index 0000000..727e7c2
--- /dev/null
+++ b/26_tests_matrix_input/grade.txt
@@ -0,0 +1,20 @@
+Grading at Thu 02 Dec 2021 03:14:19 AM UTC
+Checking rotateMatrix1
+Your tests identified the problem with rotateMatrix1
+Checking rotateMatrix2
+Your tests identified the problem with rotateMatrix2
+Checking rotateMatrix3
+Your tests identified the problem with rotateMatrix3
+Checking rotateMatrix4
+Your tests identified the problem with rotateMatrix4
+Checking rotateMatrix5
+Your tests identified the problem with rotateMatrix5
+Checking rotateMatrix6
+Your tests identified the problem with rotateMatrix6
+Checking rotateMatrix7
+Your tests identified the problem with rotateMatrix7
+Checking rotateMatrix8
+Your tests identified the problem with rotateMatrix8
+Your tests identified problems with all broken programs
+
+Overall Grade: PASSED
diff --git a/26_tests_matrix_input/input.1 b/26_tests_matrix_input/input.1
new file mode 100644
index 0000000..104bde6
--- /dev/null
+++ b/26_tests_matrix_input/input.1
@@ -0,0 +1,10 @@
+1234567890
+/n/n/n/n/n
+%fdsfddgfg
+afsafsjhgh
+dgdgfgfgfg
+addjfkga01
+ fdsfdbvbd
+ashfshflks
+sajlasjfls
+gjgjjhjhjj
diff --git a/26_tests_matrix_input/input.10 b/26_tests_matrix_input/input.10
new file mode 100644
index 0000000..4a664e4
--- /dev/null
+++ b/26_tests_matrix_input/input.10
@@ -0,0 +1 @@
+123456782345678
diff --git a/26_tests_matrix_input/next-README b/26_tests_matrix_input/next-README
new file mode 100644
index 0000000..3484c1a
--- /dev/null
+++ b/26_tests_matrix_input/next-README
@@ -0,0 +1,46 @@
+In a previous function, you write a function
+
+ void rotate(char matrix[10][10])
+
+which performed 90 degree clockwise rotation of a 10x10
+matrix. In that assignment, we gave you a compiled
+object file which read the input matrix from a file,
+called your function to do the rotation, and then
+printed the result to the screen.
+
+In this assignment, you will write the code that we
+previously gave you, making the complete program on your own.
+You are encouraged to make use of your previously written
+rotate function in this assignment.
+
+For this problem, you will be writing a program which
+performs a 90 degree clockwise rotation of a 10x10 matrix.
+There is nothing special about a 10x10 matrix---I just need
+to fix the matrix size, since we have not learned about dynamic
+memory allocation yet, so we do not have the knowledge needed
+to read in any size of matrix.
+
+To keep the input processing simple, the matrix will be a matrix
+of characters (so you will have something like
+ char matrix[10][10]
+in your program), which will be read from a file. Each line
+in the input file should contain 10 characters (plus a newline).
+
+Requirements:
+=============
+ - Create a file called rotateMatrix.c
+ - Your program will take one command line argument, a string
+ specifying the input file to read.
+ - The input file should contain 10 lines, each of which
+ have 10 (non-newline) characters (plus a newline).
+ - Your program should then rotate this 90 degrees clockwise,
+ and print the result on stdout.
+ Note that sample.txt provides sample input, and
+ sample.out provides sample output.
+ - If there are any errors, your program should print an
+ appropriate message to stderr, and exit with EXIT_FAILURE.
+
+Hints:
+------
+ - You may find the strchr useful for error checking that
+ you read a proper line (10 non-newline characters, then a newline).
diff --git a/26_tests_matrix_input/run_all.sh b/26_tests_matrix_input/run_all.sh
new file mode 100755
index 0000000..f13fdf0
--- /dev/null
+++ b/26_tests_matrix_input/run_all.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+run_test() {
+ prog="$1"
+ testfile="$2"
+ IFS=$'\n'
+ for line in `cat $testfile | sed 's/^$/ /'`
+ do
+ IFS=" " correct=`/usr/local/l2p/rot_matrix/rotateMatrix $line 2>&1`
+ IFS=" " broken=`$prog $line 2>&1`
+ if [ "$broken" != "$correct" ]
+ then
+ return 0
+ fi
+ done
+ return 1
+}
+
+for i in /usr/local/l2p/rot_matrix/rotateMatrix*
+do
+ if [ "$i" != "/usr/local/l2p/rot_matrix/rotateMatrix" ]
+ then
+ echo "Checking `basename $i`"
+ run_test $i tests.txt
+ x="$?"
+ if [ "$x" != "0" ]
+ then
+ echo "***Your tests failed to show that `basename $i` was broken!"
+ fi
+ fi
+done
diff --git a/26_tests_matrix_input/tests.txt b/26_tests_matrix_input/tests.txt
new file mode 100644
index 0000000..b68a6cf
--- /dev/null
+++ b/26_tests_matrix_input/tests.txt
@@ -0,0 +1,15 @@
+
+input.x
+input.1
+input.2
+input.3
+input.4
+input.5
+empty trick
+input.6
+input.7
+input.8
+input.9
+input.10
+fake.fake
+