Skip to content

Conversation

@pvktk
Copy link
Owner

@pvktk pvktk commented Mar 13, 2018

No description provided.

Anton added 3 commits March 14, 2018 00:19

p.isTerminal = true;
return true;
}

Choose a reason for hiding this comment

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

странное форматирование, табы/пробелы?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Вроде тут только табы.


public class TrieImplTest
extends TestCase
{

Choose a reason for hiding this comment

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

форматирование выше

assertEquals(0, b.howManyStartsWithPrefix("HeadZ"));

assertTrue(b.remove("Head"));
assertEquals(0, b.size());

Choose a reason for hiding this comment

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

тесты стоит представлять в виде наименее возможных тестовых случаев, чтобы их можно было читать, понять, что проверено, а что нет

Node p = bor;
p.nwords++;
for (int i = 0; i < element.length(); i++) {
if (p.lifes[arr_num(element.charAt(i))] == null) {

Choose a reason for hiding this comment

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

arr_num(element.charAt(i)) используется три раза, что намекает на переменную

return true;
}

return false;

Choose a reason for hiding this comment

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

return p.isTerminal;

}

private Node bor;
private int size = 0;

Choose a reason for hiding this comment

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

почему не равен bor.nwords?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Я думал, что size это количество символов в боре.

Choose a reason for hiding this comment

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

нет, это количество строк в боре, что эквивалентно количеству терминальных узлов или же bor.nwords

}

private Node bor;
private int size = 0;

Choose a reason for hiding this comment

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

поля описываются в начале класса

return p.nwords;
}

private Node bor;

Choose a reason for hiding this comment

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

final


private Node bor;
private int size = 0;
private int arr_num(char a) {

Choose a reason for hiding this comment

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

в джаве CamelCase именование

Разделил тесты на блоки.
return p.nwords;
}

private int arrNum(char a) {

Choose a reason for hiding this comment

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

на буквах экономить не стоит, особенно если они помогают понимать код, что верно почти всегда

assertEquals(4, b.size());
}
/*
public void testBorBigTest() {

Choose a reason for hiding this comment

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

ненужный код лучше удалять, чтобы он не мозолил глаза
в крайнем случае, он останется в истории системы контроля версий

import junit.framework.TestCase;

public class TrieImplTest extends TestCase {
private Bor b;

Choose a reason for hiding this comment

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

можно бор создавать в каждом тестовом методе, будет чуть длиньше файл, зато "чище"

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.

3 participants