MCPcopy Create free account
hub / github.com/ActiveState/code / Test

Class Test

recipes/Python/492209_dal1py/recipe-492209.py:166–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164################################################################################
165
166class Test:
167
168 # DAL1 Test Class
169 def __init__(self, size):
170 self.__string = chr(0) * size
171
172 # Read Some Data
173 def read(self, index, size):
174 assert type(index) is int and 0 <= index < len(self)
175 assert type(size) is int and index < index + size <= len(self)
176 return self.__string[index:index+size]
177
178 # Write Some Data
179 def write(self, index, data):
180 assert type(index) is int and 0 <= index < len(self)
181 assert type(data) is str and index < index + len(data) <= len(self)
182 self.__string = self.__string[:index] + data + \
183 self.__string[index+len(data):]
184
185 # Erase Some Data
186 def erase(self, index, size):
187 self.write(index, chr(0) * size)
188
189 # Get Length Information
190 def __len__(self):
191 return len(self.__string)
192
193################################################################################
194

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected