main(){
	/*getHammingDistance() test cases:*/

	getHammingDistance("AACCTT","GGCCTT"); //return 2
	getHammingDistance("TCGGA","AAAAG"); //returns 5
	getHammingDistance("A","AG"); //error message prompt returns 0

	/*countSubstrPattern() test cases:*/
	countSubstrPattern("AATATATAGG","GG");// returns 1
	countSubstrPattern("AATATATAGG","ATA");// returns 3
	countSubstrPattern("AATATATAGG","ACTGACTGACTG");// returns 0

	/*isValidString() test cases:*/
	isValidString("AAGGCTATGC","ACGT");//returns 1 / true
	isValidString("AAGGCTATGa","ACGT");// returns 0 / false
	isValidString("ACGT","ACGT");// returns 1 / true
	isValidString("ACGT101_","ACGT");// returns 0 / false
	isValidString("091212345","0123456789");// returns 1 / true

	/*getSkew() test cases:*/
	getSkew("GGCCAC", 1);// returns 1
	getSkew("GGCCAC", 2);// returns 2
	getSkew("GGCCAC", 3);// returns 1
	getSkew("GGCCAC", 4);// returns 0
	getSkew("GGCCAC", 5);// returns 0

	/*getMaxSkewN() test cases:*/
	getMaxSkewN("GGCCAC", 1);// returns 1
	getMaxSkewN("GGCCAC", 2);// returns 2
	getMaxSkewN("GGCCAC", 3);// returns 2
	getMaxSkewN("GGCCAC", 4);// returns 2
	getMaxSkewN("GGCCAC", 5);// returns 2

	/*getMinSkewN() test cases:*/
	getMinSkewN("GGCCAC", 1);// returns 1
	getMinSkewN("GGCCAC", 2);// returns 1
	getMinSkewN("GGCCAC", 3);// returns 1
	getMinSkewN("GGCCAC", 4);// returns 0
	getMinSkewN("GGCCAC", 5);// returns 0

}
void countSubstrPatternTest(char *str1, char *str2, int expectedResult) {
    int substrCount = countSubstrPattern(str1, str2);
     
    printf("countSubstrPattern(\"%s\", \"%s\") ", str1, str2);
    
    if(substrCount == expectedResult) {
        printf("PASSED\n");
    }
    else {
        printf("FAILED (Expected %i, got %i.)\n", expectedResult, substrCount);
        errorCount++;
    }
}
int main(){
	int choice = 7, result, n;
	char *str1, *str2;
	
	while(choice != 0){	//while user has not chosen to exit the program
		printMenu(&choice);	//calls function printMenu
		
		str1 = (char *)malloc(100*sizeof(char));
		str2 = (char *)malloc(100*sizeof(char));
		
		switch(choice){
			case 1:
				printf("\n*****************************************\n");
				printf("*\t   Get Hamming Distance\t\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter string 1: ");
				scanf("%s", str1);
				printf("Enter string 2: ");
				scanf("%s", str2);
				//return value of function getHammingDistance stored in result
				result = getHammingDistance(str1, str2);
				
				if(result == 0){	//if the strings have unequal length
					printf("\nError! Strings have unequal length!\n");
					
				}else{	//if the strings have equal length
					printf("\nHamming Distance: %d\n", result);
				}
				
				break;
				
			case 2:
				printf("\n*****************************************\n");
				printf("*\t Count Substring Pattern\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter original string: ");
				scanf("%s", str1);
				printf("Enter pattern: ");
				scanf("%s", str2);
				//return value of function countSubstrPattern stored in result
				result = countSubstrPattern(str1, str2);
				printf("\nNumber of occurence of pattern in orginal: %d\n", result);
				break;
				
			case 3:
				printf("\n*****************************************\n");
				printf("*\t    Is String Valid\t\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter alphabet: ");
				scanf("%s", str1);
				printf("Enter string: ");
				scanf("%s", str2);
				//return value of function isValidString stored in result
				result = isValidString(str2, str1);
				
				if(result == 1){
					printf("\nString is valid.\n");
				}else{
					printf("\nString is not valid.\n");
				}
				
				break;
				
			case 4:
				printf("\n*****************************************\n");
				printf("*\t\tGet Skew\t\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter genome string: ");
				scanf("%s", str1);
				printf("Enter number: ");
				scanf("%d", &n);
				
				if(n > (strlen(str1)+1) || n <= 0){
					printf("\nError! Number must be within string length!\n");
				}else{
					//return value of function getSkew stored in result
					result = getSkew(str1, n);
					printf("\nNumber of G-C: %d\n", result);
				}
				
				break;
				
			case 5:
				printf("\n*****************************************\n");
				printf("*\t  Get Maximum Skew of N\t\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter genome string: ");
				scanf("%s", str1);
				printf("Enter number: ");
				scanf("%d", &n);
				
				if(n > (strlen(str1)+1) || n <= 0){
					printf("\nError! Number must be within string length!\n");
				}else{
					//return value of function getMaxSkewN stored in result
					result = getMaxSkewN(str1, n);
					printf("\nMaximum Skew: %d\n", result);
				}
				
				break;
				
			case 6:
				printf("\n*****************************************\n");
				printf("*\t  Get Minimum Skew of N\t\t*\n");
				printf("*****************************************\n");
				
				printf("\nEnter genome string: ");
				scanf("%s", str1);
				printf("Enter number: ");
				scanf("%d", &n);
				
				if(n > (strlen(str1)+1) || n <= 0){
					printf("\nError! Number must be within string length!\n");
				}else{
					//return value of function getMinSkewN stored in result
					result = getMinSkewN(str1, n);
					printf("\nMinimum Skew: %d\n", result);
				}
				
				break;
				
			case 0:
				free(str1);
				free(str2);
				printf("\nProgram Terminated...\n");
				break;
				
			default:
				printf("\nInvalid input!\n");
				break;
		}
		
	}
}
main(){
	int x;
	
	printf("getHammingDistance\n");
	x = getHammingDistance("AACCTT","GGCCTT");
	printf("%d\n",x );
	x = getHammingDistance("TCGGA","AAAAG");
	printf("%d\n",x );
	x = getHammingDistance("A","AG");
	printf("%d\n",x );
	
	printf("countSubstrPattern\n");
	x = countSubstrPattern("AATATATAGG","GG");
	printf("%d\n",x);
	x = countSubstrPattern("AATATATAGG","ATA");
	printf("%d\n",x);
	x = countSubstrPattern("AATATATAGG","ACTGACTGACTG");
	printf("%d\n",x);
	
	printf("isValidString\n");
	x = isValidString("AAGGCTATGC","ACGT");
	printf("%d\n",x);
	x = isValidString("AAGGCTATGa","ACGT");
	printf("%d\n",x);
	x = isValidString("ACGT","ACGT");
	printf("%d\n",x);
	x = isValidString("ACGT101_","ACGT");
	printf("%d\n",x);
	x = isValidString("091212345","0123456789");
	printf("%d\n",x);
	
	printf("getSkew\n");
	x = getSkew("GGCCAC", 1);
	printf("%d\n",x );
	x = getSkew("GGCCAC", 2);
	printf("%d\n",x );
	x = getSkew("GGCCAC", 3);
	printf("%d\n",x );
	x = getSkew("GGCCAC", 4);
	printf("%d\n",x );
	x = getSkew("GGCCAC", 5);
	printf("%d\n",x );
	
	printf("getMaxSkewN\n");
	x = getMaxSkewN("GGCCAC", 1);
	printf("%d\n",x );
	x = getMaxSkewN("GGCCAC", 2);
	printf("%d\n",x );
	x = getMaxSkewN("GGCCAC", 3);
	printf("%d\n",x );
	x = getMaxSkewN("GGCCAC", 4);
	printf("%d\n",x );
	x = getMaxSkewN("GGCCAC", 5);
	printf("%d\n",x );
	
	printf("getMinSkewN\n");
	x = getMinSkewN("GGCCAC", 1);
	printf("%d\n",x );
	x = getMinSkewN("GGCCAC", 2);
	printf("%d\n",x );
	x = getMinSkewN("GGCCAC", 3);
	printf("%d\n",x );
	x = getMinSkewN("GGCCAC", 4);
	printf("%d\n",x );
	x = getMinSkewN("GGCCAC", 5);
	printf("%d\n",x );
}