#include "unity.h" #include "StringManipulation.h" void test_to_string() { /*initializing test values*/ char *result_1[] = {"0","1","2","3","4","5","6","7","8","9","10"}; char *result_2[] = {"500","502","504","506","508","510","512","514","516","518"}; char *result_3[] = {"1000","2000","3000","4000","5000","6000","7000","8000","9000","10000"}; char *result_4[] = {"9999","8999","7999","6999","5999","4999","3999","2999","1999","999"}; char *result_5[] = {"1000000","2000000","3000000","4000000","5000000","6000000","7000000", "8000000","9000000","10000000"}; for(int i=0;i<=10;++i){ printf("%s\n", to_string(i)); TEST_ASSERT_EQUAL_STRING(result_1[i],to_string(i)); } for(int i=0, j=500;i<10;++i,j+=2){ printf("%s\n", to_string(j)); TEST_ASSERT_EQUAL_STRING(result_2[i],to_string(j)); } for(int i=0, j=1000;i<10;++i,j+=1000){ printf("%s\n", to_string(j)); TEST_ASSERT_EQUAL_STRING(result_3[i],to_string(j)); } for(int i=0, j=9999;i<10;++i,j-=1000){ printf("%s\n", to_string(j)); TEST_ASSERT_EQUAL_STRING(result_4[i], to_string(j)); } for(int i=0, j=1000000;i<10;++i,j+=1000000){ printf("%s\n", to_string(j)); TEST_ASSERT_EQUAL_STRING(result_5[i],to_string(j)); } }