Conversation
…из zipped файла запись алфавита, размера алфавита и размер символов
yurii-litvinov
left a comment
There was a problem hiding this comment.
Сжал/разжал, получил из .txt .exe-шник :) Вообще, файлы бывают не только .txt и .exe, а ещё бывают файлы без расширения вовсе, и их тоже иногда хочется сжимать.
LZW/LZW/Bor.cs
Outdated
| @@ -0,0 +1,119 @@ | |||
| namespace Bor; | |||
|
|
|||
| // A container for storing strings, in the form of a suspended tree | |||
There was a problem hiding this comment.
В этой задаче уже надо было комментарии в формате XML Documentation
LZW/LZW/Bor.cs
Outdated
| // A container for storing strings, in the form of a suspended tree | ||
| public class Bor | ||
| { | ||
| private BorElement root = new BorElement(); |
There was a problem hiding this comment.
| private BorElement root = new BorElement(); | |
| private BorElement root = new(); |
LZW/LZW/Bor.cs
Outdated
| private BorElement root = new BorElement(); | ||
|
|
||
| // Adding an element | ||
| public (bool, int) Add(Bor bor, char[] buffer, int from, int to) |
There was a problem hiding this comment.
Что за bor и бывает ли он отличным от this?
| { | ||
| if (root == null || buffer == null) | ||
| { | ||
| throw new InvalidOperationException(); |
There was a problem hiding this comment.
Если buffer null, надо кидать ArgumentNullException(nameof(buffer))
LZW/LZW/Bor.cs
Outdated
| pointer++; | ||
| i++; | ||
| } | ||
| if (walker.IsTerminal == false) |
There was a problem hiding this comment.
| if (walker.IsTerminal == false) | |
| if (!walker.IsTerminal) |
LZW/TestLZW/TestLZW.cs
Outdated
| var (isCorrect, _) = lzw.LzwAlgorithm(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestsForLZW", "testAnElementaryExample.txt"), "-c"); | ||
| if (!isCorrect ) | ||
| { | ||
| Assert.Fail(); |
There was a problem hiding this comment.
Не пользуйтесь Assert.Fail, пользуйтесь Assert.AreEqual или, лучше, Assert.That
LZW/TestLZW/TestLZW.cs
Outdated
| } | ||
| string correctText = File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestsForLZW", "testAnElementaryExample.txt")); | ||
| string fromLZWText = File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestsForLZW", "testAnElementaryExample.exe")); | ||
| Assert.True(correctText == fromLZWText); |
There was a problem hiding this comment.
Так тоже нельзя, из-за невнятного сообщения об ошибке при непроходящем тесте. Пользуйтесь Assert.That
| using Bor; | ||
| public class TestsForBor |
There was a problem hiding this comment.
| using Bor; | |
| public class TestsForBor | |
| using Bor; | |
| public class TestsForBor |
LZW/TestsBor/TestsBor.cs
Outdated
| using Bor; | ||
| public class TestsForBor | ||
| { | ||
| Bor bor; |
There was a problem hiding this comment.
Тут тоже надо модификатор видимости и пустую строку
| [TestCaseSource(nameof(BorForTests))] | ||
| public void TheAddedElementShouldbeFoundInBor(Bor bor) | ||
| { | ||
| Setup(); |
lzw