class LoBTest(unittest.TestCase): def test_a(self): self.lob = LoB() assert self.lob.stringToNumber('a') == 0, self.lob.stringToNumber('a') assert self.lob.stringToNumber('ba') == 29, self.lob.stringToNumber( 'ba') def test_b(self): self.lob = LoB() assert len(self.lob.getPage( 'asaskjkfsdf:2:2:2:33')) == self.lob.length_of_page, len( self.lob.getPage('asasrkrtjfsdf:2:2:2:33')) assert 'hello kitty' == self.lob.toText( int(self.lob.int2base(self.lob.stringToNumber('hello kitty'), 36), 36)) def test_c(self): self.lob = LoB() assert self.lob.int2base(4, 36) == '4', self.lob.int2base(4, 36) assert self.lob.int2base(10, 36) == 'A', self.lob.int2base(10, 36) def test_d(self): self.lob = LoB() test_string = '.................................................' assert test_string in self.lob.getPage(self.lob.search(test_string)) def test_e(self): self.lob = LoB() print('') self.lob.printPage('HELLO:0:0:0:0')
# -*- coding: utf-8 -*- """ Created on Wed Nov 20 16:10:42 2019 @author: lu """ from library_of_babel import LoB import random import string import matplotlib.pyplot as plt import numpy as np lob = LoB() keyword = "trash" address = lob.search(keyword) print address page = lob.getPage(address) index = page.find(keyword) print page[index:index + len(keyword) + 10] keyword = "garbage" address = lob.search(keyword) #print address page = lob.getPage(address) index = page.find(keyword) #print page[index:index+len(keyword)+10] babelString = "" for i in range(0, 100):