|
From: <tbr...@us...> - 2012-03-20 13:48:04
|
Revision: 201
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=201&view=rev
Author: tbrowder2
Date: 2012-03-20 13:47:53 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add ustring tests from the glibmm project
Modified Paths:
--------------
trunk/tests/Makefile.am
Added Paths:
-----------
trunk/tests/ustring/
trunk/tests/ustring/test_ustring_compose.cc
trunk/tests/ustring/test_ustring_format.cc
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 13:35:13 UTC (rev 200)
+++ trunk/tests/Makefile.am 2012-03-20 13:47:53 UTC (rev 201)
@@ -2,9 +2,10 @@
TESTS = test
AM_CPPFLAGS = -I$(top_srcdir)/include
-LIBS = $(top_builddir)/src/libxmlwrapp.la \
- $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
- $(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS)
+LIBS = $(top_builddir)/src/libxmlwrapp.la \
+ $(top_builddir)/src/libustring.la \
+ $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
+ $(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS)
noinst_PROGRAMS = test
@@ -15,7 +16,9 @@
document/test_document.cc \
event/test_event.cc \
node/test_node.cc \
- tree/test_tree.cc
+ tree/test_tree.cc \
+ ustring/test_ustring_compose.cc \
+ ustring/test_ustring_format.cc \
if WITH_XSLT
LIBS += $(top_builddir)/src/libxsltwrapp.la
Added: trunk/tests/ustring/test_ustring_compose.cc
===================================================================
--- trunk/tests/ustring/test_ustring_compose.cc (rev 0)
+++ trunk/tests/ustring/test_ustring_compose.cc 2012-03-20 13:47:53 UTC (rev 201)
@@ -0,0 +1,36 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
+int main(int, char**)
+{
+ Glib::init();
+
+ //TODO: Check the output?
+ const char *constant_string = "constant string";
+ ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
+
+ int i = 1;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
+
+ ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
+
+ //TODO: More tests.
+
+ return EXIT_SUCCESS;
+}
+
Property changes on: trunk/tests/ustring/test_ustring_compose.cc
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/tests/ustring/test_ustring_format.cc
===================================================================
--- trunk/tests/ustring/test_ustring_format.cc (rev 0)
+++ trunk/tests/ustring/test_ustring_format.cc 2012-03-20 13:47:53 UTC (rev 201)
@@ -0,0 +1,30 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+int main(int, char**)
+{
+ Glib::init();
+
+ char carr[10] = "Užduotys";
+ char * const cptr = carr;
+
+ /*
+ std::wostringstream wsout;
+ wsout << carr;
+ const std::wstring& wstr = wsout.str();
+ const gunichar * const data = reinterpret_cast<const gunichar *>(
+ wstr.data());
+
+ for(int i = 0; wstr.size() > i; ++i)
+ std::cout << data[i] << std::endl;
+ */
+
+ //Check both the const char* and char* versions.
+ Glib::ustring::format(carr);
+
+ //This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
+ Glib::ustring::format(cptr);
+
+ return EXIT_SUCCESS;
+}
Property changes on: trunk/tests/ustring/test_ustring_format.cc
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|