MCPcopy Create free account
hub / github.com/Kitware/VTK / TestXMLFileOutputWindow

Function TestXMLFileOutputWindow

Common/Core/Testing/Cxx/TestXMLFileOutputWindow.cxx:11–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <iostream>
10
11int TestXMLFileOutputWindow(int argc, char* argv[])
12{
13 if (argc < 2)
14 {
15 std::cout << "Usage: " << argv[0] << " outputFilename" << std::endl;
16 return EXIT_FAILURE;
17 }
18 std::string sample("Test string: &\"'<>");
19
20 {
21 vtkSmartPointer<vtkXMLFileOutputWindow> ofw = vtkSmartPointer<vtkXMLFileOutputWindow>::New();
22 ofw->SetInstance(ofw);
23 ofw->FlushOn();
24
25 // Use the default filename
26 ofw->DisplayTag(sample.c_str());
27 ofw->DisplayText(sample.c_str());
28 ofw->DisplayErrorText(sample.c_str());
29 ofw->DisplayWarningText(sample.c_str());
30 ofw->DisplayGenericWarningText(sample.c_str());
31 ofw->DisplayDebugText(sample.c_str());
32
33 // Check nullptr strings
34 ofw->DisplayTag(nullptr);
35 ofw->DisplayText(nullptr);
36 ofw->DisplayErrorText(nullptr);
37 ofw->DisplayWarningText(nullptr);
38 ofw->DisplayGenericWarningText(nullptr);
39 ofw->DisplayDebugText(nullptr);
40 }
41
42 // Append to default
43 {
44 vtkSmartPointer<vtkXMLFileOutputWindow> ofw2 = vtkSmartPointer<vtkXMLFileOutputWindow>::New();
45 ofw2->SetInstance(ofw2);
46 ofw2->AppendOn();
47 ofw2->DisplayText("Appended");
48 }
49
50 // Change the file name
51 {
52 vtkSmartPointer<vtkXMLFileOutputWindow> ofw3 = vtkSmartPointer<vtkXMLFileOutputWindow>::New();
53 ofw3->SetInstance(ofw3);
54 ofw3->SetFileName(argv[1]);
55 ofw3->DisplayTag(sample.c_str());
56 ofw3->DisplayText(sample.c_str());
57 ofw3->DisplayErrorText(sample.c_str());
58 ofw3->DisplayWarningText(sample.c_str());
59 ofw3->DisplayGenericWarningText(sample.c_str());
60 ofw3->DisplayDebugText(sample.c_str());
61 ofw3->AppendOn();
62 ofw3->DisplayText("Appended");
63 }
64
65 // Now, compare the default and specified files
66 // Read the default XML file
67 vtksys::ifstream dfin("vtkMessageLog.xml");
68 std::string def((std::istreambuf_iterator<char>(dfin)), std::istreambuf_iterator<char>());

Callers

nothing calls this directly

Calls 10

DisplayTagMethod · 0.80
NewFunction · 0.70
SetInstanceMethod · 0.45
c_strMethod · 0.45
DisplayTextMethod · 0.45
DisplayErrorTextMethod · 0.45
DisplayWarningTextMethod · 0.45
DisplayDebugTextMethod · 0.45
SetFileNameMethod · 0.45

Tested by

no test coverage detected