Question

In: Computer Science

Its a (Test) Case of Swapping Download swap_case_test.c here, or copy it to your CSE account...

Its a (Test) Case of Swapping

Download swap_case_test.c here, or copy it to your CSE account using the following command:

cp -n /web/cs1511/20T3/activities/swap_case_test/swap_case_test.c .

Read Me First: Software Testing

One of the most fundamental parts of writing software is testing. In this course, we mostly do the testing for you -- the autotest program checks your software is correct. While this is handy, testing will not always be so easy. In the following labs, and in Assignment 2, there will be a focus on writing tests yourself.

For this program, you will be asked to write a program that tests some code -- the code you will test is your swap_case function from the previous exercise. To test your code, we have written some incorrect solutions. Your job is to tell us in whether the solution meets the specification given in the last exercise. That means, you will have to tell us whether swap_case:

  • returns the character in lower case if it is an upper case letter
  • returns the character in upper case if it is a lower case letter
  • returns the character unchanged otherwise

Swap Case Test

Edit the C program swap_case_test.c (linked above) so that it tests whether the swap_case function is correct. You should not edit the main function; and you should not use scanf, printf, getchar or any other functions from stdio.h. You can hardcode the inputs to swap_case inside your testing functions.

You will only need to edit the test_lower_to_upper function, the test_upper_to_lower and the test_non_alphabetical function. Each function should call swap_case, and depending on it's output, should return MEETS_SPEC (if swap_case did the right thing, or DOES_NOT_MEET_SPEC if it does something unexpected.

For example, if swap_case was the following function:

int swap_case(int character) {
    return character;
}

Your program should behave as follows:

dcc swap_case_test.c -o swap_case_test
./swap_case_test
Testing turning an lowercase into uppercase: DOES NOT MEET SPEC
Testing turning an uppercase into lowercase: DOES NOT MEET SPEC
Testing a non-alphabetical character not changing: MEETS SPEC

For example, if swap_case was the following function:

int swap_case(int character) {
    return 1000;
}

Your program should behave as follows:

dcc swap_case_test.c -o swap_case_test
./swap_case_test
Testing turning an lowercase into uppercase: DOES NOT MEET SPEC
Testing turning an uppercase into lowercase: DOES NOT MEET SPEC
Testing a non-alphabetical character not changing: DOES NOT MEET SPEC

For example, if swap_case was the code you wrote in the last exercise, Your program should (hopefully) behave as follows:

dcc swap_case_test.c -o swap_case_test
./swap_case_test
Testing turning an lowercase into uppercase: MEETS SPEC
Testing turning an uppercase into lowercase: MEETS SPEC
Testing a non-alphabetical character not changing: MEETS SPEC

NOTE: You don't need to test every valid input -- only testing one or two will be enough.

Solutions

Expert Solution

Solution:

Givendata:

One of the most fundamental parts of writing software is testing. In this course, we mostly do the testing for you -- the autotest program checks your software is correct. While this is handy, testing will not always be so easy. In the following labs, and in Assignment 2, there will be a focus on writing tests yourself.

Answer:

int swap_case(int character)

{

return character;

}

the problem with this code is that this code uses "int" to store a character. but it is not possible.

"int" stores only integer values.

so when you try to input any alphabet in "character", then you will get an error.

one should write 'char character' instead of 'int character'.

also, the function is a integer type. it can return only integer value. but we want the function to return characters.

so instead of 'int swap_case', we should use 'char swap_case'.

also, in the question you provided, there's no code written to swap the case of the characters.

so, even if we make the changes i told above, we will get the same output we took in the input. the case will not change.

for example:

'a' will remain 'a' only and will not be changed to 'A'.

so, we need to modify the code as well.

PLEASE GIVEME THUMBUP.....


Related Solutions

Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program // This program uses a function that returns a value. #include <iostream> using namespace std; // Function prototype int sum(int num1, int num2); int main() {    int value1 = 20,   // The first value        value2 = 40,   // The second value        total;         //...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug. To be able to receive your full discussion points, you need to submit the following. Following is your check list and rubric       Attach your .cpp file/s with an implemented bug - 20pnts       Describe what the code...
Test for Correlation - Download the data set “Course Evaluations” in your preferred technology format (StatCrunch,...
Test for Correlation - Download the data set “Course Evaluations” in your preferred technology format (StatCrunch, Statdisk, Excel). Column 2 denotes the mean course rating, and Column 3 denotes the mean professor rating. Using your preferred technology format (StatCrunch, Statdisk, Excel), generate a scatterplot for these two data sets. Based on the graph, do you believe the two sets are correlated? Now, using the same program, complete a hypothesis test to test the claim that the course rating and the...
Fundamentals of Programming USING JAVA Please copy here your source codes, including your input and output...
Fundamentals of Programming USING JAVA Please copy here your source codes, including your input and output screenshots. Please upload this document along with your source files (i.e., the .java files) on Blackboard by the due date. 1. (Display three messages) Write a program that displays Welcome to Java, Welcome to Computer Science, and Programming is fun. 2. (Convert feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot...
ONLY COPY AND PASTE ANSWERS!!! According to the Codification Research Case, your client is in the...
ONLY COPY AND PASTE ANSWERS!!! According to the Codification Research Case, your client is in the planning phase for a major plant expansion, which will involve the construction of a new warehouse. The assistant controller does not believe that interest cost can be included in the cost of the warehouse, because it is a financing expense. Others on the planning team believe that some interest cost can be included in the cost of the warehouse, but no one could identify...
JAVA Copy the attached code into your IDE or an online compiler and test an additional...
JAVA Copy the attached code into your IDE or an online compiler and test an additional type with the generic class. Submit your code and execution display. JAVA The test cases for Integer and String is given in the code. Please add test cases for Character, Boolean and Double type etc. // A Simple Java program to show working of user defined // Generic classes    // We use < > to specify Parameter type class Test<T> {     //...
I'm really confused Junit test case Here is my code. How can I do Junit test...
I'm really confused Junit test case Here is my code. How can I do Junit test with this code? package pieces; import java.util.ArrayList; import board.Board; public class Knight extends Piece {    public Knight(int positionX, int positionY, boolean isWhite) {        super("N", positionX, positionY, isWhite);    }    @Override    public String getPossibleMoves() {        ArrayList<String> possibleMoves = new ArrayList<>();               // check if squares where knight can go are available for it       ...
Review the case study and complete the questions to increase your knowledge of Fundamentals content. Copy...
Review the case study and complete the questions to increase your knowledge of Fundamentals content. Copy and paste the questions into a document to type your answers. Copy and paste the questions and answers back into messaging to your coach. You coach will provide you with feedback on your answers. A 70-year-old female has been admitted to the hospital. The client has had nausea and vomiting for the past three days. Upon admission the client is slightly confused and weak....
what is common (case) law ? explain in your own words rather than to copy paste...
what is common (case) law ? explain in your own words rather than to copy paste from interenet but you can take idea from it the answer must long?
Note: Strictly no copy paste, write in your language. Q. What are the best case studies...
Note: Strictly no copy paste, write in your language. Q. What are the best case studies and examples of Lean practice?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT