public void ShouldNotFindOneSymbolMiss()
        {
            var lookup = new SymbolLookup();

            lookup.InsertSymbol("Test", 0x100, 0x10);
            Symbol dummy;

            Assert.IsFalse(lookup.TryGetSymbolByAddress(0x120, out dummy));
        }
Ejemplo n.º 2
0
        public void ShouldCorrectlyGuessZeroLengthSymbol()
        {
            var symbols = new List <Symbol>
            {
                MakeSymbolEntry("一", 20, 0),
                MakeSymbolEntry("三", 30, 10),
                MakeSymbolEntry("国", 40, 0),
                MakeSymbolEntry("五", 50, 50),
                MakeSymbolEntry("中", 60, 10),
                MakeSymbolEntry("猫", 65, 0),
                MakeSymbolEntry("私", 80, 0),
                MakeSymbolEntry("糞", 100, 0),
                MakeSymbolEntry("二", 110, 0)
            };
            var lookup = new SymbolLookup();

            lookup.InsertSymbols(symbols);
            Symbol dummySymbol;

            Assert.IsFalse(lookup.TryGetSymbolByAddress(19, out dummySymbol));
            Assert.AreEqual("一", lookup.GetSymbolByAddress(20).Name);
            Assert.AreEqual("一", lookup.GetSymbolByAddress(21).Name);
            Assert.AreEqual("国", lookup.GetSymbolByAddress(40).Name);
            Assert.AreEqual("国", lookup.GetSymbolByAddress(41).Name);

            Assert.AreEqual("猫", lookup.GetSymbolByAddress(65).Name);
            Assert.AreEqual("中", lookup.GetSymbolByAddress(66).Name);
            Assert.AreEqual("五", lookup.GetSymbolByAddress(70).Name);

            Assert.AreEqual("私", lookup.GetSymbolByAddress(80).Name);
            Assert.AreEqual("五", lookup.GetSymbolByAddress(81).Name);

            Assert.AreEqual("糞", lookup.GetSymbolByAddress(100).Name);
            Assert.AreEqual("糞", lookup.GetSymbolByAddress(101).Name);
            Assert.AreEqual("二", lookup.GetSymbolByAddress(110).Name);
            Assert.IsFalse(lookup.TryGetSymbolByAddress(111, out dummySymbol));
        }
Ejemplo n.º 3
0
        public void ShouldNotFindHole()
        {
            var symbols = new List <Symbol>
            {
                MakeSymbolEntry("Alice", 0, 50),
                MakeSymbolEntry("Bob", 51, 50)
            };
            var lookup = new SymbolLookup();

            lookup.InsertSymbols(symbols);

            Symbol dummy;

            Assert.IsFalse(lookup.TryGetSymbolByAddress(50, out dummy));
        }
Ejemplo n.º 4
0
        public void ShouldTrimBigSymbol()
        {
            Symbol dummy;
            var    lookup  = new SymbolLookup();
            var    symbols = new List <Symbol>
            {
                MakeSymbolEntry("Large", 0, 10),
                MakeSymbolEntry("Small", 9, 1)
            };

            lookup.InsertSymbols(symbols);

            Assert.IsFalse(lookup.TryGetSymbolByAddress(10, out dummy));
            Assert.AreEqual("Small", lookup.GetSymbolByAddress(9).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(8).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(0).Name);
        }
Ejemplo n.º 5
0
        public void ShouldNotCrashOnInsertDoubledSymbol()
        {
            var symbols = new List <Symbol>
            {
                MakeSymbolEntry("一", 0, 100),
                MakeSymbolEntry("二", 0, 100),
                MakeSymbolEntry("三", 100, 15),
                MakeSymbolEntry("四", 100, 15),
                MakeSymbolEntry("国", 10, 15),
                MakeSymbolEntry("五", 10, 15),
            };
            var lookup = new SymbolLookup();

            lookup.InsertSymbols(symbols);
            Symbol dummySymbol;

            foreach (var symbol in symbols)
            {
                lookup.GetSymbolsByName(symbol.Name);
                lookup.GetSymbolByAddress(symbol.Start);
                lookup.TryGetSymbolByAddress(symbol.End, out dummySymbol);
            }
        }
Ejemplo n.º 6
0
        public void ShouldWorkWithLongSeriesAndNesting()
        {
            var symbols = new List <Symbol>
            {
                MakeSymbolEntry("Large", 0, 10),
                MakeSymbolEntry("First", 3, 3),
                MakeSymbolEntry("Small", 4, 1),
                MakeSymbolEntry("Last", 6, 1)
            };

            var lookup = new SymbolLookup();

            lookup.InsertSymbols(symbols);

            Symbol dummy;

            Assert.IsFalse(lookup.TryGetSymbolByAddress(10, out dummy));
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(9).Name);
            Assert.AreEqual("Last", lookup.GetSymbolByAddress(6).Name);
            Assert.AreEqual("First", lookup.GetSymbolByAddress(5).Name);
            Assert.AreEqual("Small", lookup.GetSymbolByAddress(4).Name);
            Assert.AreEqual("First", lookup.GetSymbolByAddress(3).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(2).Name);
        }
Ejemplo n.º 7
0
 public void ShouldNotFindOneSymbolMiss()
 {
     var lookup = new SymbolLookup();
     lookup.InsertSymbol("Test", 0x100, 0x10);
     Symbol dummy;
     Assert.IsFalse(lookup.TryGetSymbolByAddress(0x120, out dummy));
 }
Ejemplo n.º 8
0
        public void ShouldCorrectlyGuessZeroLengthSymbol()
        {
            var symbols = new List<Symbol>
            {
                MakeSymbolEntry("一", 20, 0),
                MakeSymbolEntry("三", 30, 10),
                MakeSymbolEntry("国", 40, 0),
                MakeSymbolEntry("五", 50, 50),
                MakeSymbolEntry("中", 60, 10),
                MakeSymbolEntry("猫", 65, 0),
                MakeSymbolEntry("私", 80, 0),
                MakeSymbolEntry("糞", 100, 0),
                MakeSymbolEntry("二", 110, 0)
            };
            var lookup = new SymbolLookup();
            lookup.InsertSymbols(symbols);
            Symbol dummySymbol;
            Assert.IsFalse(lookup.TryGetSymbolByAddress(19, out dummySymbol));
            Assert.AreEqual("一", lookup.GetSymbolByAddress(20).Name);
            Assert.AreEqual("一", lookup.GetSymbolByAddress(21).Name);
            Assert.AreEqual("国", lookup.GetSymbolByAddress(40).Name);
            Assert.AreEqual("国", lookup.GetSymbolByAddress(41).Name);

            Assert.AreEqual("猫", lookup.GetSymbolByAddress(65).Name);
            Assert.AreEqual("中", lookup.GetSymbolByAddress(66).Name);
            Assert.AreEqual("五", lookup.GetSymbolByAddress(70).Name);

            Assert.AreEqual("私", lookup.GetSymbolByAddress(80).Name);
            Assert.AreEqual("五", lookup.GetSymbolByAddress(81).Name);

            Assert.AreEqual("糞", lookup.GetSymbolByAddress(100).Name);
            Assert.AreEqual("糞", lookup.GetSymbolByAddress(101).Name);
            Assert.AreEqual("二", lookup.GetSymbolByAddress(110).Name);
            Assert.IsFalse(lookup.TryGetSymbolByAddress(111, out dummySymbol));
        }
Ejemplo n.º 9
0
 public void ShouldNotCrashOnInsertDoubledSymbol()
 {
     var symbols = new List<Symbol>
     {
         MakeSymbolEntry("一", 0, 100),
         MakeSymbolEntry("二", 0, 100),
         MakeSymbolEntry("三", 100, 15),
         MakeSymbolEntry("四", 100, 15),
         MakeSymbolEntry("国", 10, 15),
         MakeSymbolEntry("五", 10, 15),
     };
     var lookup = new SymbolLookup();
     lookup.InsertSymbols(symbols);
     Symbol dummySymbol;
     foreach(var symbol in symbols)
     {
         lookup.GetSymbolsByName(symbol.Name);
         lookup.GetSymbolByAddress(symbol.Start);
         lookup.TryGetSymbolByAddress(symbol.End, out dummySymbol);
     }
 }
Ejemplo n.º 10
0
        public void ShouldWorkWithStackedTest()
        {
            var symbols = new List<Symbol>
            {
                MakeSymbolEntry("一", 0, 50),
                MakeSymbolEntry("国", 50, 50),
                MakeSymbolEntry("五", 65, 35),
                MakeSymbolEntry("中", 70, 30),
                MakeSymbolEntry("猫", 80, 20),
                MakeSymbolEntry("私", 81, 9),
                MakeSymbolEntry("糞", 90, 10)
            };
            var lookup = new SymbolLookup();
            lookup.InsertSymbols(symbols);

            Assert.AreEqual("一", lookup.GetSymbolByAddress(1).Name);
            Assert.AreEqual("国", lookup.GetSymbolByAddress(52).Name);
            Assert.AreEqual("五", lookup.GetSymbolByAddress(66).Name);
            Assert.AreEqual("中", lookup.GetSymbolByAddress(71).Name);
            Assert.AreEqual("猫", lookup.GetSymbolByAddress(80).Name);
            Assert.AreEqual("私", lookup.GetSymbolByAddress(82).Name);
            Assert.AreEqual("糞", lookup.GetSymbolByAddress(94).Name);
            Assert.AreEqual("糞", lookup.GetSymbolByAddress(99).Name);
            Symbol dummy;
            Assert.IsFalse(lookup.TryGetSymbolByAddress(100, out dummy));
        }
Ejemplo n.º 11
0
        public void ShouldWorkWithLongSeriesAndNesting()
        {
            var symbols = new List<Symbol>
            {
                MakeSymbolEntry("Large", 0, 10),
                MakeSymbolEntry("First", 3, 3),
                MakeSymbolEntry("Small", 4, 1),
                MakeSymbolEntry("Last", 6, 1)
            };

            var lookup = new SymbolLookup();
            lookup.InsertSymbols(symbols);

            Symbol dummy;
            Assert.IsFalse(lookup.TryGetSymbolByAddress(10, out dummy));
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(9).Name);
            Assert.AreEqual("Last", lookup.GetSymbolByAddress(6).Name);
            Assert.AreEqual("First", lookup.GetSymbolByAddress(5).Name);
            Assert.AreEqual("Small", lookup.GetSymbolByAddress(4).Name);
            Assert.AreEqual("First", lookup.GetSymbolByAddress(3).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(2).Name);
        }
Ejemplo n.º 12
0
        public void ShouldNotFindHole()
        {
            var symbols = new List<Symbol>
            {
                MakeSymbolEntry("Alice", 0, 50),
                MakeSymbolEntry("Bob", 51, 50)
            };
            var lookup = new SymbolLookup();

            lookup.InsertSymbols(symbols);

            Symbol dummy;
            Assert.IsFalse(lookup.TryGetSymbolByAddress(50, out dummy));
        }
Ejemplo n.º 13
0
        public void ShouldTrimBigSymbol()
        {
            Symbol dummy;
            var lookup = new SymbolLookup();
            var symbols = new List<Symbol>
            {
                MakeSymbolEntry("Large", 0, 10),
                MakeSymbolEntry("Small", 9, 1)
            };
            lookup.InsertSymbols(symbols);

            Assert.IsFalse(lookup.TryGetSymbolByAddress(10, out dummy));
            Assert.AreEqual("Small", lookup.GetSymbolByAddress(9).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(8).Name);
            Assert.AreEqual("Large", lookup.GetSymbolByAddress(0).Name);
        }