]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/formatter: Add tests for dump_format_ns
authorAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Sat, 30 Aug 2014 08:12:42 +0000 (13:42 +0530)
committerAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Fri, 5 Sep 2014 03:34:48 +0000 (09:04 +0530)
Adding basic unit test to test the new formatter class'
dump_format_ns. Since the functionality only affects XML (and other
implementations mimic dump_format exactly), tests are added for these.
`fmt.close_section()` is avoided in the tests as this calls an
assert (and there is no section to close) and this triggers a test
failure.

Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@ril.com>
src/test/formatter.cc

index a02e895d6166d948eeae70038ea06626520fe7d0..bb556296167009630f3840eb23aee48a264dd71e 100644 (file)
@@ -178,3 +178,22 @@ TEST(XmlFormatter, NamespaceTest) {
     "<foo xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">"
     "<blah>hithere</blah><pi>3.14</pi></foo>");
 }
+
+TEST(XmlFormatter, DumpFormatNameSpaceTest) {
+  ostringstream oss1;
+  XMLFormatter fmt(false);
+
+  fmt.dump_format_ns("foo",
+                    "http://s3.amazonaws.com/doc/2006-03-01/",
+                    "%s","bar");
+  fmt.flush(oss1);
+  ASSERT_EQ(oss1.str(),
+           "<foo xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">bar</foo>");
+
+  // Testing with a null ns..should be same as dump format
+  ostringstream oss2;
+  fmt.reset();
+  fmt.dump_format_ns("foo",NULL,"%s","bar");
+  fmt.flush(oss2);
+  ASSERT_EQ(oss2.str(),"<foo>bar</foo>");
+}