Conversation
| target_link_libraries(top_multi pthread) | ||
|
|
||
|
|
||
| add_executable(main src/main.c) |
There was a problem hiding this comment.
у тебя библиотека top_multi не инклюдится не в один проект (
| int add_rate(Object* obj, int m, unsigned user_id); | ||
|
|
||
| Objects *create_objects(unsigned size); | ||
| void free_objects(Objects *objs); |
There was a problem hiding this comment.
звездочка слева или справа все таки?
|
|
||
| #include "top_utils.h" | ||
|
|
||
| Top* get_top(const Objects *objs, const User *user, unsigned count); |
|
|
||
| void *library; | ||
| Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c); | ||
| library = dlopen("./libtop_multi.so", RTLD_LAZY); |
There was a problem hiding this comment.
ну так тоже можно с динамическими библиотеками =)
There was a problem hiding this comment.
при ошибке открытия лучше писать название библиотеки
Cant open lib libtop_multi.so
There was a problem hiding this comment.
повсюду забываешь dlerror
| void *library; | ||
| Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c); | ||
| library = dlopen("./libtop_multi.so", RTLD_LAZY); | ||
| if (!library) { |
There was a problem hiding this comment.
никакого сообщения об ошибке
There was a problem hiding this comment.
не очень понимаю чем этот файл отличается от main.c
There was a problem hiding this comment.
Ничем не отличается. Я его добавил, потому что в нем исчезают ошибки в валгринде. Я в телегу писал. Если вкратце - чем больше потоков, тем чаще появляется утечка в сишном файле. В плюсовом вообще ни разу не возникает. На моём валгринде(3.15), на валгринде тревиса, что в сишном, что в плюсовом, все течет, причем каждый раз по разному. А валгринд силайона как молчал, так и молчит. Сейчас посмотрел, тревис вообще ужас показывает - в плюсовом 72К байт течет, прогнал у себя и ничего
|
|
||
| void *library; | ||
| Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c); | ||
| library = dlopen("./libtop_multi.so", RTLD_LAZY); |
There was a problem hiding this comment.
повсюду забываешь dlerror
idz-2/test/test.cpp
Outdated
| free_user(u); | ||
| } | ||
|
|
||
| class TopUtils: public ::testing::Test {}; |
There was a problem hiding this comment.
а зачем тебе нужен класс? и почему ты используешь TEST_F
idz-2/test/test.cpp
Outdated
| ASSERT_TRUE(!add_rate(objs, static_cast<Mark>(4), 0)); | ||
| ASSERT_TRUE(!add_rate(objs, static_cast<Mark>(3), 0)); | ||
| ASSERT_TRUE(!add_rate(objs, static_cast<Mark>(2), 0)); | ||
| ASSERT_TRUE(!add_rate(objs, static_cast<Mark>(1), 0)); |
There was a problem hiding this comment.
тут наверное можно использовать ASSERT_FALSE
idz-2/test/test.cpp
Outdated
| }; | ||
| Top *temp = find_top(arr, 5, 2); | ||
| for (size_t i = 0; i < 2; i++) { | ||
| ASSERT_TRUE(temp[i].avr_rate == etalon[i].avr_rate); |
There was a problem hiding this comment.
тут надо использовать ASSERT_EQ(temp[i].avr_rate, etalon[i].avr_rate)
idz-2/test/test.cpp
Outdated
| print_top(top_single, 10); | ||
|
|
||
| for (size_t i = 0; i < 10; i++) { | ||
| ASSERT_TRUE(top_multi[i].avr_rate == top_single[i].avr_rate); |
There was a problem hiding this comment.
тут лучше использовать ASSERT_EQ
No description provided.