forked from 131/lab3_test
написал bit_count, тесты и добавил цель в Makefile
This commit is contained in:
30
bit_test.c
Normal file
30
bit_test.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "munit.h"
|
||||
#include "bit_lib.h"
|
||||
|
||||
static MunitResult
|
||||
test_bit_count_basic(const MunitParameter params[], void *data) {
|
||||
(void) params; (void) data;
|
||||
|
||||
munit_assert_int(bit_count(0), ==, 0); // 0b0
|
||||
munit_assert_int(bit_count(1), ==, 1); // 0b1
|
||||
munit_assert_int(bit_count(2), ==, 1); // 0b10
|
||||
munit_assert_int(bit_count(3), ==, 2); // 0b11
|
||||
munit_assert_int(bit_count(15), ==, 4); // 0b1111
|
||||
munit_assert_int(bit_count(16), ==, 1); // 0b10000
|
||||
munit_assert_int(bit_count(255), ==, 8); // 0b11111111
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
static const MunitTest tests[] = {
|
||||
{ "/bit_count/basic", test_bit_count_basic, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
|
||||
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
|
||||
};
|
||||
|
||||
static const MunitSuite suite = {
|
||||
NULL, tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
||||
};
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
return munit_suite_main(&suite, (void*) "", argc, (char * const*) argv);
|
||||
}
|
||||
Reference in New Issue
Block a user