util: MemoryMap test case for hex/octal support
+ abort() on test failure Change-Id: I3bd4f19615b1234dae8854950e9d3e1b5810c101
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "util/MemoryMap.hpp"
|
#include "util/MemoryMap.hpp"
|
||||||
|
|
||||||
using namespace fail;
|
using namespace fail;
|
||||||
@ -16,6 +17,7 @@ uint32_t outside[] = { 0, 10, 16, 1, 20, 1, 25, 10 };
|
|||||||
void test_failed(std::string msg)
|
void test_failed(std::string msg)
|
||||||
{
|
{
|
||||||
cerr << "MemoryMap test failed (" << msg << ")!" << endl;
|
cerr << "MemoryMap test failed (" << msg << ")!" << endl;
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass by value intentional
|
// pass by value intentional
|
||||||
@ -98,6 +100,7 @@ int main()
|
|||||||
char const *filename_tmp = "tmp.memorymap";
|
char const *filename_tmp = "tmp.memorymap";
|
||||||
char const *filename_test1 = "test1.memorymap";
|
char const *filename_test1 = "test1.memorymap";
|
||||||
char const *filename_test2 = "test2.memorymap";
|
char const *filename_test2 = "test2.memorymap";
|
||||||
|
char const *filename_test3 = "test3.memorymap";
|
||||||
|
|
||||||
for (unsigned i = 0; i < LEN(inside); i += 2) {
|
for (unsigned i = 0; i < LEN(inside); i += 2) {
|
||||||
mm.add(inside[i], inside[i+1]);
|
mm.add(inside[i], inside[i+1]);
|
||||||
@ -125,4 +128,8 @@ int main()
|
|||||||
mm.clear();
|
mm.clear();
|
||||||
mm.readFromFile(filename_test2);
|
mm.readFromFile(filename_test2);
|
||||||
test(mm);
|
test(mm);
|
||||||
|
|
||||||
|
mm.clear();
|
||||||
|
mm.readFromFile(filename_test3);
|
||||||
|
test(mm);
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/core/util/testing/test3.memorymap
Normal file
3
src/core/util/testing/test3.memorymap
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
012 0x6
|
||||||
|
0x11 3
|
||||||
|
21 0x4
|
||||||
Reference in New Issue
Block a user