You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "unity.h"
#include "conversionOfNumbers.h"
#include <stdlib.h>
void setUp(){} void tearDown(){}
void test_convertNum2ToBinaryStr10(){ //arrange
char* result; char expected[] = "10";
//act
result = convertIntToBinaryStr(2);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_binaryStringLengthOfInput5is3(){ //arrange
int result; int expected = 3;
//act
result = binaryStrLen(5);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_binaryStringLengthOfInput0is1(){ //arrange
int result; int expected = 1;
//act
result = binaryStrLen(0);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_convertNum10ToBinaryStr1010(){ //arrange
char* result; char expected[] = "1010";
//act
result = convertIntToBinaryStr(10);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_binaryStringLengthOfInputNegative10is5(){ //arrange
int result; int expected = 5;
//act
result = binaryStrLen(-10);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_convertNegativeNum12ToBinaryStrNegative1100(){ //arrange
char* result; char expected[] = "-1100";
//act
result = convertIntToBinaryStr(-12);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_convertBinaryStr11ToInt3(){ //arrange
unsigned int result; unsigned int expected = 3;
//act
result = convertBinaryStrToInt("11");
//assert
TEST_ASSERT_EQUAL_UINT(expected, result); }
void test_convertBinaryStr1111ToInt15(){ //arrange
unsigned int result; unsigned int expected = 15;
//act
result = convertBinaryStrToInt("1111");
//assert
TEST_ASSERT_EQUAL_UINT(expected, result); }
void test_convertBinaryStr1001ToInt9(){ //arrange
unsigned int result; unsigned int expected = 9;
//act
result = convertBinaryStrToInt("1001");
//assert
TEST_ASSERT_EQUAL_UINT(expected, result); }
void test_convertNum3ToHexStr3(){ //arrange
char* result; char expected[] = "3";
//act
result = convertIntToHex(3);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_convertNum12ToHexStrC(){ //arrange
char* result; char expected[] = "C";
//act
result = convertIntToHex(12);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_hexStringLengthOfInput256is3(){ //arrange
int result; int expected = 3;
//act
result = hexStrLen(256);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_hexStringLengthOfInput255is2(){ //arrange
int result; int expected = 2;
//act
result = hexStrLen(255);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_hexStringLengthOfInput0is1(){ //arrange
int result; int expected = 1;
//act
result = hexStrLen(0);
//assert
TEST_ASSERT_EQUAL_INT(expected, result); }
void test_convertNum234ToHexStrEA(){ //arrange
char* result; char expected[] = "EA";
//act
result = convertIntToHex(234);
//assert
TEST_ASSERT_EQUAL_STRING(expected, result); free(result); }
void test_convertBinaryStr10110ToInt22(){ //arrange
unsigned int result; unsigned int expected = 22;
//act
result = convertBinaryStrToInt("10110");
//assert
TEST_ASSERT_EQUAL_UINT(expected, result); }
void test_convertHexStr2A3ToInt675(){ //arrange
unsigned int result; unsigned int expected = 675;
//act
result = convertHexStrToInt("2A3");
//assert
TEST_ASSERT_EQUAL_UINT(expected, result); }
|