Skip to content

Hw1 - #1

Open
Elderly-AI wants to merge 9 commits into
masterfrom
HW1
Open

Hw1#1
Elderly-AI wants to merge 9 commits into
masterfrom
HW1

Conversation

@Elderly-AI

Copy link
Copy Markdown
Owner

V 1.0

@Elderly-AI
Elderly-AI requested a review from leshiy1295 October 10, 2019 13:10
Comment thread .travis.yml

branches:
only:
- gh-pages

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.

что это и зачем?

Comment thread .travis.yml
- source ci/travis/install-$TRAVIS_OS_NAME

script:
- g++ -g -Wall -Wextra test1.c -o test1

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.

почему для .c программы используется g++?

Comment thread .travis.yml

script:
- g++ -g -Wall -Wextra test1.c -o test1
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./test1 ; fi

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.

можно было вынести всё в отдельный скрипт по аналогии с install...
чтобы не дублировать постоянно if..

Comment thread .travis.yml
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then g++ -g -o0 -coverage -Wall -Wextra -Werror test1.c -o test1 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./test1 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then uname -a ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then g++ --version ; fi

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.

смысл выводить версии после проверок?

Comment thread .travis.yml
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cppcheck --error-exitcode=1 --enable=warning,performance,information,style *.c *.h ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -q https://github.com/catchorg/Catch2/releases/download/v2.2.3/catch.hpp ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then g++ -g -o0 -coverage -Wall -Wextra -Werror test1.c -o test1 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./test1 ; fi

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.

зачем изначально запускался valgrind не на тестах?

Comment thread test1.c

void test(){

size_t animals_count = 1000; //Random Generated 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.

тесты не должны быть случайными

  • должна была быть возможность вводить числа с stdin, а тесты - это отдельная программа или она же, но запускаемая через специальные аргументы

Comment thread test1.c

size_t animals_count = 1000; //Random Generated Test

size_t types_count = 21;

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 test1.c
size_t animals_count = 1000; //Random Generated Test

size_t types_count = 21;
char types[21][10] = {"dog", "cat", "fish", "goat", "kid",

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.

types_count...

  • так память сейчас выделяется неэффективно

Comment thread test1.c

insert_sort(animals_array, animals_count, my_custom_sort_function);

show(animals_array, animals_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.

это не автотест, так как нет проверки корректности вывода

Comment thread test1.c
char names[12][8] = {"Caval", "Diamond", "Rogue", "Nelson", "Prim",
"Rufus", "Polly", "Dicky", "Jack", "Rapid", "Freed", "Jeremy"};

Animal *animals_array = (Animal*) malloc (sizeof(Animal) * animals_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.

что если malloc вернёт ошибку?

Comment thread test1.c
free(animals_array);
}

int main(){

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, который не содержит логики, а просто вызывает функцию ввода/инициализации, обработки и вывода
  • реализация интерфейса - определение функций

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