int isOlder2(char *date1, char *date2) { int year[2], mon[2], day[2], i, ans; if (formatValidate2(date1) == -1 || formatValidate2(date2) == -1)return -1; day[0] = (date1[0] - 48) * 10 + (date1[1] - 48); mon[0] = (date1[3] - 48) * 10 + (date1[4] - 48); year[0] = (date1[6] - 48) * 1000 + (date1[7] - 48) * 100 + (date1[8] - 48) * 10 + (date1[9] - 48); day[1] = (date2[0] - 48) * 10 + (date2[1] - 48); mon[1] = (date2[3] - 48) * 10 + (date2[4] - 48); year[1] = (date2[6] - 48) * 1000 + (date2[7] - 48) * 100 + (date2[8] - 48) * 10 + (date2[9] - 48); if (!validate2(day[0], mon[0], year[0]))return -1; if (!validate2(day[1], mon[1], year[1]))return -1; ans = compare2(year[0], year[1]); if (ans != -1)return ans; else { ans = compare2(mon[0], mon[1]); if (ans != -1)return ans; else { ans = compare2(day[0], day[1]); if (ans != -1)return ans; return 0; } } }
// tests if the a file exists with relative path TEST(FileExists, FileRelativePath) { ValidateCreate validate("moneytracker.exe"); EXPECT_TRUE(validate.WalletExists()); ValidateCreate validate2("missingFile.cpp"); EXPECT_FALSE(validate2.WalletExists()); }
// tests if the a file exists with absolute path TEST(FileExists, FileAbsolutePath) { ValidateCreate validate("main\\tst\\TestValidateCreate.cpp"); EXPECT_TRUE(validate.WalletExists()); ValidateCreate validate2("main\\tst\\missingFile"); EXPECT_FALSE(validate2.WalletExists()); ValidateCreate validate3("main\\tst\\src\\TestValidateCreate.cpp"); EXPECT_FALSE(validate3.WalletExists()); }
int * sortedArrayInsertNumber(int *Arr, int len, int num) { int i = 0; if (!validate2(Arr, len)) return NULL; Arr = (int *)realloc(Arr, 100); while (Arr[i] <= num && i < len) i++; int pos = i, j = len - 1; while (j >= pos) { Arr[j + 1] = Arr[j]; j--; } Arr[pos] = num; return Arr; }