public void gen_chain_charTest1() //没有-r。-c { string filePath = ("test2.txt"); char head = '\0', tail = '\0'; string[] words = Read_file(filePath); coreBuild core = new coreBuild(); int result = core.gen_chain_char(words, 0, words, head, tail, false); Assert.AreEqual(result, 28); }
public void gen_chain_wordTest2() //有-r。-w { string filePath = ("test3.txt"); char head = '\0', tail = '\0'; string[] words = Read_file(filePath); coreBuild core = new coreBuild(); int result = core.gen_chain_word(words, 0, words, head, tail, true); Assert.AreEqual(result, 6); }
//“生成”按钮 单击事件 private void button1_Click(object sender, EventArgs e) { string textInput = ""; if (tabPage.SelectedIndex == 0) { string filename = Directory.GetCurrentDirectory() + "\\" + textBox2.Text; if (File.Exists(filename)) { textInput = File.ReadAllText(filename); } } else { textInput = textBox1.Text; } if (textInput.Length == 0) { textBox5.Text = "ERROR : NO INPUT !"; return; } //确定char_h char_t if (!b_h) { char_h = '#'; } if (!b_t) { char_t = '#'; } //调用ConsoleApp1项目内对应接口实现 textOutput = ""; char c_wc = b_w ? 'w' : 'c'; coreBuild core = new coreBuild(); WordChain wc = core.get_chainByLine(textInput, char_h, char_t, b_r, c_wc); foreach (Word word in wc.GetWordChain()) { textOutput += word.Get_allWord(); } //输出指结果框 textBox5.Text = textOutput; }