12345678910111213141516171819202122232425262728 |
- #include "tests/BufferTests.h"
- #include "tests/Test.h"
- #include "utils/Buffer.h"
- static void testAdd(Test& test) {
- Buffer<10> bits;
- int a = 5;
- bits.add(a);
- test.checkEqual(static_cast<int> (sizeof (a)), bits.getLength(), "add increments length");
- }
- static void testOverflow(Test& test) {
- Buffer<10> bits;
- for(int i = 0; i < 1000000; i++) {
- bits.add(5);
- bits.add(5L);
- bits.add(5.0f);
- bits.add(5.0);
- }
- test.checkEqual(10, bits.getLength(), "add increments length");
- }
- void BufferTests::test() {
- Test test("Buffer");
- testAdd(test);
- testOverflow(test);
- test.finalize();
- }
|