push for windows
This commit is contained in:
@@ -16,7 +16,6 @@ int addAnimal(const Animal* animalPtr, Animal* animalArray, size_t animalArrayLe
|
||||
}
|
||||
|
||||
int removeAnimal(int animalId, Animal* animalArray, size_t numberOfAnimalsPresent, size_t* newNumberOfAnimalsPresent){
|
||||
int fault = 0;
|
||||
size_t removedCount = 0;
|
||||
|
||||
if (animalArray == NULL || numberOfAnimalsPresent == 0) {
|
||||
@@ -35,26 +34,18 @@ int removeAnimal(int animalId, Animal* animalArray, size_t numberOfAnimalsPresen
|
||||
}
|
||||
}
|
||||
}
|
||||
fault = removedCount;
|
||||
*newNumberOfAnimalsPresent = (numberOfAnimalsPresent - removedCount);
|
||||
return fault;
|
||||
return removedCount;
|
||||
}
|
||||
|
||||
int findAnimalById(int animalId, const Animal* animalArray, size_t numberOfAnimalsPresent, Animal* foundAnimal) {
|
||||
int fault = -1;
|
||||
if (animalArray == NULL || numberOfAnimalsPresent == 0 || foundAnimal == NULL) {
|
||||
fault = -1;
|
||||
} else {
|
||||
for (size_t i = 0; i < numberOfAnimalsPresent; i++) {
|
||||
if (animalArray[i].Id == animalId) {
|
||||
*foundAnimal = animalArray[i];
|
||||
fault = 0;
|
||||
break; // Exit loop after finding the animal
|
||||
}
|
||||
}
|
||||
if (fault == -1) { // Only zero out if animal wasn't found
|
||||
memset(foundAnimal, 0, sizeof(Animal));
|
||||
if (animalArray == NULL || foundAnimal == NULL) return -1; // Invalid input
|
||||
|
||||
for (size_t i = 0; i < numberOfAnimalsPresent; i++) {
|
||||
if (animalArray[i].Id == animalId) {
|
||||
*foundAnimal = animalArray[i];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -19,16 +19,13 @@ void watch_registers_get_config_settings(uint8_t config, bool* is_paused, time_f
|
||||
}
|
||||
|
||||
void watch_registers_set_time_hours(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t hours){
|
||||
if (hours > 11) hours = 11;
|
||||
*time_bits_high = (*time_bits_high & 0x0F) | ((hours & 0x0F) << 4); // Set the upper nibble
|
||||
}
|
||||
void watch_registers_set_time_minutes(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t minutes){
|
||||
if (minutes > 59) minutes = 59;
|
||||
*time_bits_high = (*time_bits_high & 0xF0) | ((minutes >> 2) & 0x0F); // Set the lower nibble of MSB
|
||||
*time_bits_low = (*time_bits_low & 0x3F) | ((minutes & 0x03) << 6); // Set the upper two bits of LSB
|
||||
}
|
||||
void watch_registers_set_time_seconds(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t seconds){
|
||||
if (seconds > 59) seconds = 59;
|
||||
*time_bits_low = (*time_bits_low & 0xC0) | (seconds & 0x3F); // Set the lower 6 bits of LSB
|
||||
}
|
||||
void watch_registers_get_time(uint8_t time_bits_low, uint8_t time_bits_high, uint8_t* hours, uint8_t* minutes, uint8_t* seconds){
|
||||
@@ -38,18 +35,13 @@ void watch_registers_get_time(uint8_t time_bits_low, uint8_t time_bits_high, uin
|
||||
}
|
||||
|
||||
void watch_registers_set_date_year(uint8_t* date_bits_low, uint8_t* date_bits_high, uint8_t year){
|
||||
if (year > 127) year = 127; // Maximum year value is 127 (0x7F) for 7 bits
|
||||
*date_bits_low = (*date_bits_low & 0x80) | (year & 0x7F); // Set the lower 2 bits of LSB
|
||||
}
|
||||
void watch_registers_set_date_month(uint8_t* date_bits_low, uint8_t* date_bits_high, uint8_t month){
|
||||
if (month > 12) month = 12; // Maximum month value is 12
|
||||
else if (month < 1) month = 1; // Minimum month value is 1
|
||||
*date_bits_high = (*date_bits_high & 0xF8) | ((month >> 1) & 0x07);
|
||||
*date_bits_low = (*date_bits_low & 0x7F) | ((month & 0x01) << 7);
|
||||
}
|
||||
void watch_registers_set_date_day_of_month(uint8_t* date_bits_low, uint8_t* date_bits_high,uint8_t day_of_month){
|
||||
if (day_of_month > 31) day_of_month = 31; // Maximum day of month value is 31
|
||||
else if (day_of_month < 1) day_of_month = 1; // Minimum day of month value is 1
|
||||
*date_bits_high = (*date_bits_high & 0x07) | ((day_of_month & 0x1F) << 3); // Set the upper 5 bits of MSB
|
||||
}
|
||||
void watch_registers_get_date(uint8_t date_bits_low, uint8_t date_bits_high, uint8_t* year, uint8_t* month, uint8_t* day_of_month){
|
||||
|
||||
@@ -59,6 +59,25 @@ void test_setting_get_config_settings(void){
|
||||
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
|
||||
TEST_ASSERT_EQUAL(TIME_EVERY_1_SECOND, interval);
|
||||
}
|
||||
|
||||
|
||||
void test_setting_get_config_settings2(void){
|
||||
uint8_t config = 0xAA; // 0b00000000 so time is updated, time format hour:minute, time refresh not updated
|
||||
bool is_paused;
|
||||
time_format format;
|
||||
time_update_interval interval;
|
||||
|
||||
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
|
||||
TEST_ASSERT_EQUAL(true, is_paused);
|
||||
TEST_ASSERT_EQUAL(0, format);
|
||||
TEST_ASSERT_EQUAL(0b01, interval);
|
||||
|
||||
config = 0x55;
|
||||
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
|
||||
TEST_ASSERT_EQUAL(false, is_paused);
|
||||
TEST_ASSERT_EQUAL(1, format);
|
||||
TEST_ASSERT_EQUAL(0b10, interval);
|
||||
}
|
||||
//
|
||||
//time
|
||||
void test_time_set_hours(void){
|
||||
@@ -215,6 +234,7 @@ void run_watch_tests()
|
||||
MY_RUN_TEST(test_setting_set_config_time_format);
|
||||
MY_RUN_TEST(test_setting_set_config_time_update_interval);
|
||||
MY_RUN_TEST(test_setting_get_config_settings);
|
||||
MY_RUN_TEST(test_setting_get_config_settings2);
|
||||
|
||||
MY_RUN_TEST(test_time_set_hours);
|
||||
MY_RUN_TEST(test_time_set_minutes);
|
||||
@@ -227,7 +247,5 @@ void run_watch_tests()
|
||||
MY_RUN_TEST(test_date_get_date);
|
||||
|
||||
MY_RUN_TEST(test_full_watch_configuration);
|
||||
MY_RUN_TEST(test_full_datetime_overflow_setup);
|
||||
|
||||
UnityUnregisterSetupTearDown();
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
C/C6 Adidas.zip
Normal file
BIN
C/C6 Adidas.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user