[Python-checkins] r46399 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py
martin.blais
python-checkins at python.org
Fri May 26 21:25:58 CEST 2006
Author: martin.blais
Date: Fri May 26 21:25:58 2006
New Revision: 46399
Modified:
sandbox/trunk/hotbuffer/README.txt
sandbox/trunk/hotbuffer/test_hotbuf.py
Log:
Added tests for nonzero and restore
Modified: sandbox/trunk/hotbuffer/README.txt
==============================================================================
--- sandbox/trunk/hotbuffer/README.txt (original)
+++ sandbox/trunk/hotbuffer/README.txt Fri May 26 21:25:58 2006
@@ -14,17 +14,18 @@
..
1 TODO
1.1 Features
- 1.2 Document
- 1.3 Convert from ASCII formats
+ 1.2 Ideas
+ 1.3 Document
+ 1.4 Convert from ASCII formats
2 Notes on the Java NIO / ByteBuffer
TODO
====
-* Run oprofile on the code
+* Make push() and pop() instead of save() and restore()
-* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC
+* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC
* We need to make the client more easily remove the calls to remaining()
@@ -40,6 +41,8 @@
* Add restore() to the tests.
+* Implement pack() in C
+
* Change the mark, this will make the loop easier to understand
* setmark() to save both the position and limit
@@ -61,7 +64,19 @@
* Add with protocol for guards
+Ideas
+-----
+
+- (From Bob): Automatically do the compact-and-read when something hits the
+ limit of the buffer. To discriminate between coding errors (i.e. a message
+ parsing much more than it should) and hitting the end of the file, different
+ exceptions would be needed.
+
+- Write the loop in C, compacting and windowing as you go, calling a function to
+ process for each message.
+
+
Document
--------
Modified: sandbox/trunk/hotbuffer/test_hotbuf.py
==============================================================================
--- sandbox/trunk/hotbuffer/test_hotbuf.py (original)
+++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 21:25:58 2006
@@ -52,6 +52,16 @@
b.setposition(15)
self.assertEquals(b.mark_position, 10)
+ # Play with restore
+ b.setposition(10)
+ b.setlimit(100)
+ b.save()
+ b.setposition(0)
+ b.setlimit(b.capacity)
+ b.restore()
+ self.assertEquals((b.position, b.limit),
+ (10, 100))
+
# Play with clear
b.clear()
self.assertEquals((b.position, b.limit, b.mark_position),
@@ -277,12 +287,16 @@
self.assertEquals(b.find('d'), 2)
self.assertEquals(b.find('1' * 100), -1)
+ def test_nonzero(self):
+ b = hotbuf(CAPACITY)
+ self.assertEquals(bool(b), True)
+ b.setposition(b.limit)
+ self.assertEquals(bool(b), False)
+
+
def test_main():
test_support.run_unittest(HotbufTestCase)
if __name__ == "__main__":
test_main()
-
-
-## FIXME TODO add restore() in test.
More information about the Python-checkins
mailing list