Skip to content

Commit 5ddd46e

Browse files
committed
first assignment
1 parent cc85b8e commit 5ddd46e

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

conf/username.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
your-github-username-here-in-conf-file
1+
amisev

examples/autotest-validate/autotest-validate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ bool this_function_returns_false()
2727
*/
2828
const char *my_username()
2929
{
30-
return "todo-please-enter-your-username-here-in-my_username";
30+
return "amisev";
3131
}

finder-app/finder-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rm -rf "${WRITEDIR}"
3434
# create $WRITEDIR if not assignment1
3535
assignment=`cat ../conf/assignment.txt`
3636

37-
if [ $assignment != 'assignment1' ]
37+
if [ $assignment = 'assignment1' ]
3838
then
3939
mkdir -p "$WRITEDIR"
4040

finder-app/finder.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
filesdir="$1"
2+
searchstr="$2"
3+
4+
if [ -z "$filesdir" ] || [ -z "$searchstr" ]; then
5+
echo "Error: files dir or search str is empty"
6+
exit 1
7+
fi
8+
9+
if [ ! -d "$filesdir" ]; then
10+
echo "Error: directory '$filesdir' does not exist"
11+
exit 1
12+
fi
13+
14+
# num_files=$(find "$filesdir" -type f -name "$searchstr" | wc -l)
15+
num_files=$(grep -rl "$searchstr" "$filesdir" | wc -l)
16+
num_lines=$(grep -r -I "$searchstr" "$filesdir" | wc -l)
17+
18+
echo "The number of files are $num_files and the number of matching lines are $num_lines"

finder-app/writer.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
writefile="$1"
2+
writestr="$2"
3+
if [ -z "$writefile" ] || [ -z "$writestr" ]; then
4+
echo "Error: File to write and str to write should not be empty"
5+
exit 1
6+
fi
7+
8+
echo "$writestr" > "$writefile"
9+
10+
if [ $? -eq 0 ]; then
11+
echo "Successfully wrote '$writestr' to '$writefile'."
12+
else
13+
echo "Error: Failed to write to '$writefile'."
14+
exit 1
15+
fi

student-test/assignment1/Test_validate_username.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ void test_validate_my_username()
1818
* TODO: Replace the line below with your code here as described above to verify your /conf/username.txt
1919
* config file and my_username() functions are setup properly
2020
*/
21-
TEST_ASSERT_TRUE_MESSAGE(false,"AESD students, please fix me!");
21+
const char* msg1 = my_username();
22+
const char* msg2 = malloc_username_from_conf_file();
23+
TEST_ASSERT_EQUAL_STRING_MESSAGE(msg1, msg2, "string are not equal");
2224
}

0 commit comments

Comments
 (0)