static void Test_Clear() { SplitArray <char> chars = new SplitArray <char>(5, 8); chars.Clear(); TestUtl.AssertEquals(0, chars.Count); for (int x = 0; x < 10; x++) { try{ chars.GetAt(x); Debug.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } try{ chars.SetAt('!', x); Debug.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } } chars.Add("hoge".ToCharArray()); chars.Clear(); TestUtl.AssertEquals(0, chars.Count); for (int x = 0; x < 10; x++) { try{ chars.GetAt(x); Debug.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } try{ chars.SetAt('!', x); Debug.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } } }
public void Clear() { SplitArray <char> chars = new SplitArray <char>(5, 8); chars.Clear(); Assert.AreEqual(0, chars.Count); for (int x = 0; x < 10; x++) { MyAssert.Throws <AssertException>(delegate { chars.GetAt(x); }); MyAssert.Throws <AssertException>(delegate { chars.SetAt('!', x); }); } chars.Add("hoge".ToCharArray()); chars.Clear(); Assert.AreEqual(0, chars.Count); for (int x = 0; x < 10; x++) { MyAssert.Throws <AssertException>(delegate { chars.GetAt(x); }); MyAssert.Throws <AssertException>(delegate { chars.SetAt('!', x); }); } }
public void RemoveRange() { const string InitData = "hogepiyo"; SplitArray <char> chars = new SplitArray <char>(5, 8); // case 2 (moving gap to buffer head) chars.Add(InitData.ToCharArray()); chars.RemoveAt(2); Assert.AreEqual(7, chars.Count); Assert.AreEqual("hoepiyo", ToString(chars)); MyAssert.Throws <AssertException>(delegate { chars.GetAt(7); }); // case 1 (moving gap to buffer end) chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(5, 7); Assert.AreEqual(6, chars.Count); Assert.AreEqual("hogepo", ToString(chars)); MyAssert.Throws <AssertException>(delegate { chars.GetAt(6); }); // before head to middle chars.Clear(); chars.Add(InitData.ToCharArray()); MyAssert.Throws <AssertException>(delegate { chars.RemoveRange(-1, 2); }); // head to middle chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(0, 2); Assert.AreEqual("gepiyo", ToString(chars)); // middle to middle chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(2, 5); Assert.AreEqual("hoiyo", ToString(chars)); // middle to end chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(5, 8); Assert.AreEqual("hogep", ToString(chars)); // middle to after end chars.Clear(); chars.Add(InitData.ToCharArray()); MyAssert.Throws <AssertException>(delegate { chars.RemoveRange(5, 9); }); }
static void Test_Add() { SplitArray <char> chars = new SplitArray <char>(5, 8); chars.Add('a'); TestUtl.AssertEquals(1, chars.Count); TestUtl.AssertEquals('a', chars.GetAt(0)); chars.SetAt('b', 0); TestUtl.AssertEquals('b', chars.GetAt(0)); try{ chars.GetAt(1); Debug.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } }
static void Test_RemoveRange() { const string InitData = "hogepiyo"; SplitArray <char> chars = new SplitArray <char>(5, 8); // case 2 (moving gap to buffer head) chars.Add(InitData.ToCharArray()); chars.RemoveAt(2); TestUtl.AssertEquals(7, chars.Count); TestUtl.AssertEquals("hoepiyo", ToString(chars)); try{ chars.GetAt(7); Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!"); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } // case 1 (moving gap to buffer end) chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(5, 7); TestUtl.AssertEquals(6, chars.Count); TestUtl.AssertEquals("hogepo", ToString(chars)); try{ chars.GetAt(6); Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!"); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } // before head to middle chars.Clear(); chars.Add(InitData.ToCharArray()); try{ chars.RemoveRange(-1, 2); Debug.Fail("Exception wasn't thrown as expected."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } // head to middle chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(0, 2); TestUtl.AssertEquals("gepiyo", ToString(chars)); // middle to middle chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(2, 5); TestUtl.AssertEquals("hoiyo", ToString(chars)); // middle to end chars.Clear(); chars.Add(InitData.ToCharArray()); chars.RemoveRange(5, 8); TestUtl.AssertEquals("hogep", ToString(chars)); // middle to after end chars.Clear(); chars.Add(InitData.ToCharArray()); try{ chars.RemoveRange(5, 9); Debug.Fail("Exception wasn't thrown as expected."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } }
public void Add() { SplitArray <char> chars = new SplitArray <char>(5, 8); chars.Add('a'); Assert.AreEqual(1, chars.Count); Assert.AreEqual('a', chars.GetAt(0)); chars.SetAt('b', 0); Assert.AreEqual('b', chars.GetAt(0)); MyAssert.Throws <AssertException>(delegate { chars.GetAt(1); }); }
static void Test_Init() { SplitArray <char> chars = new SplitArray <char>(5, 8); TestUtl.AssertEquals(0, chars.Count); for (int x = 0; x < 10; x++) { try{ chars.GetAt(x); Debug.Fail("exception must be thrown here. (index:" + x + ")"); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } try{ chars.SetAt('!', x); Debug.Fail("exception must be thrown here. (index:" + x + ")"); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } } }
public void Init() { SplitArray <char> chars = new SplitArray <char>(5, 8); Assert.AreEqual(0, chars.Count); for (int x = 0; x < 10; x++) { MyAssert.Throws <AssertException>(delegate { chars.GetAt(x); }); MyAssert.Throws <AssertException>(delegate { chars.SetAt('!', x); }); } }