Open
Conversation
| #include <string.h> | ||
| #include <stdbool.h> | ||
|
|
||
| bool scanFile(char fileName[], char arrayForTest[]) { |
There was a problem hiding this comment.
Suggested change
| bool scanFile(char fileName[], char arrayForTest[]) { | |
| bool scanFile(const char fileName[], const char arrayForTest[]) { |
Мы их вроде ниже не меняем
| } | ||
| char data[100] = { '\0' }; | ||
| int pointerTest = 0; | ||
| while (fscanf(file, "%s", data) == 1){ |
There was a problem hiding this comment.
Suggested change
| while (fscanf(file, "%s", data) == 1){ | |
| while (fscanf(file, "%s", data) == 1) { |
| if (fileName != NULL && strcmp(fileName, "test.txt") != 0) { | ||
| printf("%c", data[0]); | ||
| } else { | ||
| if (arrayForTest[pointerTest] != data[0]) { |
There was a problem hiding this comment.
Вообще, в боевом коде не должно быть ничего про тесты. Тест должен тестировать наблюдаемое извне поведение настоящего кода, а не какой-то кастомный код, написанный специально под тест в реальной системе.
| printf("%c", data[0]); | ||
| } else { | ||
| if (arrayForTest[pointerTest] != data[0]) { | ||
| return false; |
Comment on lines
+45
to
+47
| char fileName[9] = "test.txt"; | ||
| char arrayTest[4] = "abc"; | ||
| return scanFile(fileName, arrayTest); |
There was a problem hiding this comment.
Вот если бы scanFile принимала const-ы, то эти переменные были бы не нужны
| return true; | ||
| } | ||
|
|
||
| bool test(){ |
There was a problem hiding this comment.
Suggested change
| bool test(){ | |
| bool test() { |
| } | ||
| else { | ||
| printf("Mistake...\n"); | ||
| return 0; |
There was a problem hiding this comment.
Suggested change
| return 0; | |
| return 1; |
| } | ||
|
|
||
| int main(void) { | ||
| setlocale(LC_ALL, "RUS"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.