/
githubmirror
/
nvme-cli
Обзор
Документация
Войти
/
githubmirror
/
nvme-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/test/test-temp-util.c
36 строк
887 B
Daniel Wagner
shared: move temperature/timestamp/spinner helpers out of util/types.c
07 авг 2026, 16:15
07 авг 2026, 16:15
5d56a60
Код
Авторство
О чём код?
// SPDX-License-Identifier: LGPL-2.1-or-later /* * This file is part of nvme-cli. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <temp-util.h> static bool check_long(const char *name, long got, long want) { if (got == want) { printf(" - %s [PASS]\n", name); return true; } printf(" - %s: got %ld, want %ld [FAIL]\n", name, got, want); return false; } int main(void) { bool pass = true; printf("test_temp_conversions:\n"); pass &= check_long("0 K -> -273 C", shr_kelvin_to_celsius(0), -273); pass &= check_long("273 K -> 0 C", shr_kelvin_to_celsius(273), 0); pass &= check_long("0 C -> 32 F", shr_celsius_to_fahrenheit(0), 32); pass &= check_long("100 C -> 212 F", shr_celsius_to_fahrenheit(100), 212); pass &= check_long("373 K -> 212 F", shr_kelvin_to_fahrenheit(373), 212); fflush(stdout); exit(pass ? EXIT_SUCCESS : EXIT_FAILURE); }