From: Abhishek Lekshmanan Date: Sat, 30 Aug 2014 08:12:42 +0000 (+0530) Subject: test/formatter: Add tests for dump_format_ns X-Git-Tag: v0.86~142^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e503b56fc8f67cc10740a225529aff59b48dd81;p=ceph.git test/formatter: Add tests for dump_format_ns 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 --- diff --git a/src/test/formatter.cc b/src/test/formatter.cc index a02e895d616..bb556296167 100644 --- a/src/test/formatter.cc +++ b/src/test/formatter.cc @@ -178,3 +178,22 @@ TEST(XmlFormatter, NamespaceTest) { "" "hithere3.14"); } + +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(), + "bar"); + + // 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(),"bar"); +}