/**
* @file lab5_1.cpp
* @author Мосяж А.М., гр. 515б
* @date 1 травня 2023
* @brief Лабораторна робота № 5, варіант 4
* застосування вказівників. Завдання 1
*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include "func.h"
int main()
{
int hours, minutes, seconds=0;
int result = convertTime(&seconds, &hours, &minutes, &seconds);
if (result)
{
printf("\nHours: %d", hours);
printf("\nMinutes: %d", minutes);
printf("\nSeconds: %d", seconds);
}
else
{
printf("Invalid input!");
}
return 0;
}
#include <stdio.h>
int convertTime(int seconds, int* hours, int* minutes, int* secs)
{
printf("Enter time :");
scanf("%d", &seconds);
if (seconds < 0)
{
return 0;
}
*hours = seconds / 3600;
seconds %= 3600;
*minutes = seconds / 60;
*secs = seconds % 60;
return 1;
}
int convertTime(int seconds, int* hours, int* minutes, int* secs);
#include "pch.h"
#include "pch.h"
#include "C:\Users\amos1\source\repos\lb5_1\lb5_1\func.c"
#include <gtest/gtest.h>
TEST(convertTime, Test01)
{
int hours, minutes, seconds;
EXPECT_EQ(1, convertTime(1, &hours, &minutes, &seconds));
EXPECT_EQ(0, hours);
EXPECT_EQ(0, minutes);
EXPECT_EQ(1, seconds);
}
TEST(convertTime, Test1err)
{
int hours, minutes, seconds;
EXPECT_EQ(0, convertTime(-45, & hours, &minutes, &seconds));
}
TEST(convertTime, Test02)
{
int hours, minutes, seconds;
EXPECT_EQ(1, convertTime(3666, & hours, &minutes, &seconds));
EXPECT_EQ(1, hours);
EXPECT_EQ(1, minutes);
EXPECT_EQ(6, seconds);
}
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}