private void BtnOpenCode_Click(object sender, EventArgs e) { if (_ofdSourceCode.ShowDialog() != DialogResult.OK) { return; } BtnShowFullSourceCode.Visible = false; try { var sourceCode = ArithmeticFile.Read(_ofdSourceCode.FileName); var decoded = ArithmeticCoding.Decode(sourceCode); _lastSaveSourceCode = sourceCode.ToString(); if (_lastSaveSourceCode.Length > MaxCodeLength) { BtnShowFullSourceCode.Visible = true; } LblSourceCode.Text = "Код: " + _lastSaveSourceCode; RtbDecoded.Text = decoded; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void TestCoding20AlphabetAbd20TextLength() { var source = "абвгдеёжзийклмнопрст"; var encoded = ArithmeticCoding.Encode(source); var decoded = ArithmeticCoding.Decode(encoded); Assert.AreEqual(source, decoded); }
public void TestCoding1AlphabetAnd20TextLength() { var source = "cccccccccccccccccccc"; var encoded = ArithmeticCoding.Encode(source); var decoded = ArithmeticCoding.Decode(encoded); Assert.AreEqual(source, decoded); }