]> git.siccegge.de Git - frida/frida.git/blobdiff - src/core/tests/FunctionTest.cxx
Add support for deserializing functions
[frida/frida.git] / src / core / tests / FunctionTest.cxx
diff --git a/src/core/tests/FunctionTest.cxx b/src/core/tests/FunctionTest.cxx
new file mode 100644 (file)
index 0000000..5357bb9
--- /dev/null
@@ -0,0 +1,26 @@
+#include <gtest/gtest.h>
+
+#include "gui/qt.hxx"
+#include "core/InformationManager.hxx"
+#include "core/BasicBlock.hxx"
+#include "core/Function.hxx"
+
+TEST(FunctionTest, deserializeValidInstance) {
+       QFile file("testdata/core/Function/valid.xml");
+       InformationManager manager;
+       file.open(QFile::ReadOnly | QFile::Text);
+       QXmlStreamReader reader(&file);
+
+       reader.readNextStartElement();
+       Function* fun = Function::deserialize(reader, &manager);
+
+       ASSERT_NE((void*)NULL, (void*)fun);
+       EXPECT_STREQ("main", fun->getName().c_str());
+       EXPECT_EQ(0x403e10, fun->getStartAddress());
+
+       EXPECT_STREQ("BLOCK_403e10_403e48", fun->blocks().find(0x403e10)->second->getName().c_str());
+       EXPECT_STREQ("BLOCK_403e48_403e50", fun->blocks().find(0x403e48)->second->getName().c_str());
+       EXPECT_STREQ("BLOCK_403e50_403e66", fun->blocks().find(0x403e50)->second->getName().c_str());
+       EXPECT_STREQ("BLOCK_403e66_403e75", fun->blocks().find(0x403e66)->second->getName().c_str());
+}
+