public void TestCreateSrcMLArchiveFtM() { IntPtr s = new IntPtr(0); List <String> documents = new List <String>(); using (Archive srcmlArchive = new Archive(), srcmlArchive2 = new Archive()) { using (Unit srcmlUnit = new Unit()) { srcmlUnit.SetUnitFilename(Path.Combine(TestInputPath, "input.cpp")); srcmlUnit.SetUnitLanguage(LibSrcMLRunner.SrcMLLanguages.SRCML_LANGUAGE_CXX); srcmlArchive.AddUnit(srcmlUnit); srcmlArchive.ArchivePack(); srcmlUnit.SetUnitFilename(Path.Combine(TestInputPath, "input2.cpp")); srcmlUnit.SetUnitLanguage(LibSrcMLRunner.SrcMLLanguages.SRCML_LANGUAGE_CXX); srcmlArchive2.AddUnit(srcmlUnit); srcmlArchive2.ArchivePack(); IntPtr structPtr = srcmlArchive.GetPtrToStruct(); IntPtr structPtr2 = srcmlArchive2.GetPtrToStruct(); List <IntPtr> structArrayPtr = new List <IntPtr>(); structArrayPtr.Add(structPtr); structArrayPtr.Add(structPtr2); try { s = LibSrcMLRunner.SrcmlCreateArchiveFtM(structArrayPtr.ToArray(), structArrayPtr.Count()); } catch (Exception e) { throw new SrcMLException(e.Message, e); } for (int i = 0; i < 2; ++i) { IntPtr docptr = Marshal.ReadIntPtr(s); String docstr = Marshal.PtrToStringAnsi(docptr); Marshal.FreeHGlobal(docptr); documents.Add(docstr); s += Marshal.SizeOf(typeof(IntPtr)); } } Assert.False(String.IsNullOrEmpty(documents.ElementAt(0))); XDocument doc = XDocument.Parse(documents.ElementAt(0)); var units = from unit in doc.Descendants(XName.Get("unit", "http://www.srcML.org/srcML/src")) where unit.Attribute("filename") != null select unit; string file = Path.Combine(TestInputPath, "input.cpp");; var f1 = (from ele in units where ele.Attribute("filename").Value == file select ele); Assert.AreEqual(file, f1.FirstOrDefault().Attribute("filename").Value); Assert.False(String.IsNullOrEmpty(documents.ElementAt(1))); XDocument doc2 = XDocument.Parse(documents.ElementAt(1)); var units2 = from unit in doc2.Descendants(XName.Get("unit", "http://www.srcML.org/srcML/src")) where unit.Attribute("filename") != null select unit; string file2 = Path.Combine(TestInputPath, "input2.cpp");; var f2 = (from ele in units2 where ele.Attribute("filename").Value == file2 select ele); Assert.AreEqual(file2, f2.FirstOrDefault().Attribute("filename").Value); } }