/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
util/system/nice_ut.cpp
42 строки
957 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#include "nice.h" #include "platform.h" #include <library/cpp/testing/unittest/registar.h> #ifdef _unix_ #include <sys/resource.h> static int GetPriority() { return getpriority(PRIO_PROCESS, 0); } #endif Y_UNIT_TEST_SUITE(NiceTest) { Y_UNIT_TEST(TestNiceZero) { UNIT_ASSERT(Nice(0)); UNIT_ASSERT(Nice(0)); } #ifdef _unix_ Y_UNIT_TEST(TestNice) { int prio = GetPriority(); if (prio >= 10) { return; } if (Nice(-2)) { UNIT_ASSERT_VALUES_EQUAL(GetPriority(), prio - 2); prio -= 2; } else { UNIT_ASSERT_VALUES_EQUAL(GetPriority(), prio); } UNIT_ASSERT(Nice(1)); UNIT_ASSERT_VALUES_EQUAL(GetPriority(), prio + 1); UNIT_ASSERT(Nice(0)); UNIT_ASSERT_VALUES_EQUAL(GetPriority(), prio + 1); UNIT_ASSERT(Nice(2)); UNIT_ASSERT_VALUES_EQUAL(GetPriority(), prio + 3); } #endif }