|
@@ -1,6 +1,9 @@
|
|
#include "tests/BitArrayTests.h"
|
|
#include "tests/BitArrayTests.h"
|
|
#include "tests/Test.h"
|
|
#include "tests/Test.h"
|
|
#include "utils/BitArray.h"
|
|
#include "utils/BitArray.h"
|
|
|
|
+#include "utils/StringBuffer.h"
|
|
|
|
+
|
|
|
|
+typedef StringBuffer<50> String;
|
|
|
|
|
|
static void testSetRead(Test& test) {
|
|
static void testSetRead(Test& test) {
|
|
BitArray<4, 3> bits;
|
|
BitArray<4, 3> bits;
|
|
@@ -58,10 +61,29 @@ static void testChainedSet(Test& test) {
|
|
BitArray<4, 3> bits;
|
|
BitArray<4, 3> bits;
|
|
bits[0] = bits[2] = bits[3] = 2;
|
|
bits[0] = bits[2] = bits[3] = 2;
|
|
bits[3] = bits[1] = 7;
|
|
bits[3] = bits[1] = 7;
|
|
- test.checkEqual(2, static_cast<int>(bits[0]), "chained set sets correct value");
|
|
|
|
- test.checkEqual(7, static_cast<int>(bits[1]), "chained set sets correct value");
|
|
|
|
- test.checkEqual(2, static_cast<int>(bits[2]), "chained set sets correct value");
|
|
|
|
- test.checkEqual(7, static_cast<int>(bits[3]), "chained set sets correct value");
|
|
|
|
|
|
+ test.checkEqual(2, static_cast<int> (bits[0]), "chained set sets correct value");
|
|
|
|
+ test.checkEqual(7, static_cast<int> (bits[1]), "chained set sets correct value");
|
|
|
|
+ test.checkEqual(2, static_cast<int> (bits[2]), "chained set sets correct value");
|
|
|
|
+ test.checkEqual(7, static_cast<int> (bits[3]), "chained set sets correct value");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testToString1(Test& test) {
|
|
|
|
+ BitArray<4, 3> bits;
|
|
|
|
+ bits[0] = 1;
|
|
|
|
+ bits[1] = 2;
|
|
|
|
+ bits[2] = 3;
|
|
|
|
+ bits[3] = 4;
|
|
|
|
+ String s;
|
|
|
|
+ s.append(bits);
|
|
|
|
+ test.checkEqual(String("[1, 2, 3, 4]"), s, "bit array to string 1");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void testToString2(Test& test) {
|
|
|
|
+ BitArray<1, 3> a;
|
|
|
|
+ a[0] = 1;
|
|
|
|
+ String s;
|
|
|
|
+ s.append(a);
|
|
|
|
+ test.checkEqual(String("[1]"), s, "bit array to string 1");
|
|
}
|
|
}
|
|
|
|
|
|
void BitArrayTests::test() {
|
|
void BitArrayTests::test() {
|
|
@@ -71,5 +93,7 @@ void BitArrayTests::test() {
|
|
testRandomSetRead(test);
|
|
testRandomSetRead(test);
|
|
testReadOnly(test);
|
|
testReadOnly(test);
|
|
testChainedSet(test);
|
|
testChainedSet(test);
|
|
|
|
+ testToString1(test);
|
|
|
|
+ testToString2(test);
|
|
test.finalize();
|
|
test.finalize();
|
|
}
|
|
}
|