public void Set() { var trie = new UnicodeTrieBuilder(10, 666); trie.Set(0x4567, 99); Assert.Equal(10u, trie.Get(0x4566)); Assert.Equal(99u, trie.Get(0x4567)); Assert.Equal(666u, trie.Get(-1)); Assert.Equal(666u, trie.Get(0x110000)); }
public void RunRangeChecks(TestRange[] testRanges, CheckValue[] checkValues) { uint initialValue = testRanges[0].value; uint errorValue = 0x0bad; var builder = new UnicodeTrieBuilder(initialValue, errorValue); for (int i = 1; i < testRanges.Length; i++) { var r = testRanges[i]; builder.SetRange(r.start, r.end - 1, r.value, r.overwrite); } var frozen = builder.Freeze(); int cp = 0; for (int i = 0; i < checkValues.Length; i++) { var v = checkValues[i]; for (; cp < v.codePoint; cp++) { Assert.Equal(v.value, builder.Get(cp)); Assert.Equal(v.value, frozen.Get(cp)); } } }
public void RunRangeChecks(TestRange[] testRanges, CheckValue[] checkValues) { uint initialValue = testRanges[0].Value; const uint errorValue = 0x0bad; var builder = new UnicodeTrieBuilder(initialValue, errorValue); for (int i = 1; i < testRanges.Length; i++) { TestRange r = testRanges[i]; builder.SetRange(r.Start, r.End - 1, r.Value, r.Overwrite); } UnicodeTrie frozen = builder.Freeze(); int cp = 0; for (int i = 0; i < checkValues.Length; i++) { CheckValue v = checkValues[i]; while (cp < v.CodePoint) { Assert.Equal(v.Value, builder.Get(cp)); Assert.Equal(v.Value, frozen.Get(cp)); cp++; } } }
public void SetRange() { var trie = new UnicodeTrieBuilder(10, 666); trie.SetRange(13, 6666, 7788, false); trie.SetRange(6000, 7000, 9900, true); Assert.Equal(10u, trie.Get(12)); Assert.Equal(7788u, trie.Get(13)); Assert.Equal(7788u, trie.Get(5999)); Assert.Equal(9900u, trie.Get(6000)); Assert.Equal(9900u, trie.Get(7000)); Assert.Equal(10u, trie.Get(7001)); Assert.Equal(666u, trie.Get(0x110000)); }