Skip to content

Making idz 2 - #2

Open
Sermelyan wants to merge 16 commits into
masterfrom
making-idz-2
Open

Making idz 2#2
Sermelyan wants to merge 16 commits into
masterfrom
making-idz-2

Conversation

@Sermelyan

Copy link
Copy Markdown
Owner

No description provided.

@Sermelyan
Sermelyan requested a review from Vinograduss October 26, 2019 09:29
Comment thread idz-2/CMakeLists.txt
target_link_libraries(top_multi pthread)


add_executable(main src/main.c)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у тебя библиотека top_multi не инклюдится не в один проект (

Comment thread idz-2/include/object.h
int add_rate(Object* obj, int m, unsigned user_id);

Objects *create_objects(unsigned size);
void free_objects(Objects *objs);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

звездочка слева или справа все таки?


#include "top_utils.h"

Top* get_top(const Objects *objs, const User *user, unsigned count);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут добавил const =)

Comment thread idz-2/src/main.c

void *library;
Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c);
library = dlopen("./libtop_multi.so", RTLD_LAZY);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну так тоже можно с динамическими библиотеками =)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при ошибке открытия лучше писать название библиотеки
Cant open lib libtop_multi.so

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

повсюду забываешь dlerror

Comment thread idz-2/test/mem_test.cpp
void *library;
Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c);
library = dlopen("./libtop_multi.so", RTLD_LAZY);
if (!library) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

никакого сообщения об ошибке

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не очень понимаю чем этот файл отличается от main.c

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ничем не отличается. Я его добавил, потому что в нем исчезают ошибки в валгринде. Я в телегу писал. Если вкратце - чем больше потоков, тем чаще появляется утечка в сишном файле. В плюсовом вообще ни разу не возникает. На моём валгринде(3.15), на валгринде тревиса, что в сишном, что в плюсовом, все течет, причем каждый раз по разному. А валгринд силайона как молчал, так и молчит. Сейчас посмотрел, тревис вообще ужас показывает - в плюсовом 72К байт течет, прогнал у себя и ничего

Comment thread idz-2/src/main.c

void *library;
Top* (*get_top_multi)(const Objects *o, const User *u, unsigned c);
library = dlopen("./libtop_multi.so", RTLD_LAZY);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

повсюду забываешь dlerror

Comment thread idz-2/test/test.cpp Outdated
free_user(u);
}

class TopUtils: public ::testing::Test {};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем тебе нужен класс? и почему ты используешь TEST_F

Comment thread 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));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут наверное можно использовать ASSERT_FALSE

Comment thread 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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут надо использовать ASSERT_EQ(temp[i].avr_rate, etalon[i].avr_rate)

Comment thread 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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут лучше использовать ASSERT_EQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants