|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60994 - sandbox/xint/libs/xint/test
From: pbristow_at_[hidden]
Date: 2010-04-01 12:21:45
Author: pbristow
Date: 2010-04-01 12:21:45 EDT (Thu, 01 Apr 2010)
New Revision: 60994
URL: http://svn.boost.org/trac/boost/changeset/60994
Log:
Two naive tests using Boost.Test. BUT they report a memory leak.
Added:
sandbox/xint/libs/xint/test/xint_test.cpp (contents, props changed)
sandbox/xint/libs/xint/test/xint_test_addsub.cpp (contents, props changed)
Added: sandbox/xint/libs/xint/test/xint_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/xint/libs/xint/test/xint_test.cpp 2010-04-01 12:21:45 EDT (Thu, 01 Apr 2010)
@@ -0,0 +1,76 @@
+// xint_test.cpp
+
+// Copyright Paul A. Bristow 2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/**
+\file
+\brief Test xint stream output.
+\details
+Tests for output to a std:: stream.
+**/
+
+#include <boost/xint/xint.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <limits>
+
+//! Compare stream output with expected.
+#define BOOST_XINT_TEST_OUTPUT(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ BOOST_CHECK_EQUAL(ss.str(), expected); \
+}
+
+BOOST_AUTO_TEST_CASE(test_output_1)
+{ // No formatting
+#define FORMATTERS
+ xint::integer my_int2(2);
+ BOOST_XINT_TEST_OUTPUT(my_int2, "2"); //
+#undef FORMATTERS
+}
+
+//BOOST_AUTO_TEST_CASE(test_output_2)
+//{ // Formatting
+//#define FORMATTERS << std::showpos
+// xint::integer my_int2(-2);
+// BOOST_XINT_TEST_OUTPUT(my_int2, "-2");//
+//#undef FORMATTERS
+//}
+
+
+//BOOST_AUTO_TEST_CASE(test_output_2)
+//{ // Formatting
+//#define FORMATTERS << std::showpos
+// xint::integer my_int2(2);
+// BOOST_XINT_TEST_OUTPUT(my_int2, "+2");//
+//#undef FORMATTERS
+//}
+
+
+/*
+
+Output
+
+Autorun "j:\Cpp\Misc\debug\xint_test.exe"
+Running 2 test cases...
+./xint_test.cpp(45): error in "test_output_2": check ss.str() == "+2" failed [2 != +2]
+*** 1 failure detected in test suite "Master Test Suite"
+Detected memory leaks!
+Dumping objects ->
+{397} normal block at 0x00232038, 52 bytes long.
+ Data: < D # > 01 00 00 00 03 00 00 00 44 20 23 00 00 00 00 00
+{396} normal block at 0x00021FA0, 4 bytes long.
+ Data: <8 # > 38 20 23 00
+Object dump complete.
+Project : error PRJ0019: A tool returned an error code from "Autorun "j:\Cpp\Misc\debug\xint_test.exe""
+Build Time 0:03
+*/
Added: sandbox/xint/libs/xint/test/xint_test_addsub.cpp
==============================================================================
--- (empty file)
+++ sandbox/xint/libs/xint/test/xint_test_addsub.cpp 2010-04-01 12:21:45 EDT (Thu, 01 Apr 2010)
@@ -0,0 +1,70 @@
+// xint_test_addsub.cpp
+
+// Copyright Paul A. Bristow 2010
+// Copyright Chad Nelson 2010
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/**
+\file
+\brief Test xint add and subtract operators.
+\details
+Tests Test xint add and subtract operators.
+Simple and longer tests using random numbers are provided.
+**/
+
+#include <boost/xint/xint.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <limits>
+
+//! Compare stream output with expected.
+#define BOOST_XINT_TEST_OUTPUT(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ BOOST_CHECK_EQUAL(ss.str(), expected); \
+}
+
+BOOST_AUTO_TEST_CASE(test_xint_add)
+{ //
+ #define FORMATTERS
+ xint::integer my_int1(2);
+ xint::integer my_int2(2);
+ BOOST_CHECK_EQUAL(my_int1 + my_int2, 4); //
+ BOOST_XINT_TEST_OUTPUT((my_int2 + my_int2), "4");//
+#undef FORMATTERS
+}
+
+/*
+
+Output
+
+------ Rebuild All started: Project: xint_test_addsub, Configuration: Debug Win32 ------
+Deleting intermediate and output files for project 'xint_test_addsub', configuration 'Debug|Win32'
+Compiling...
+xint_test_addsub.cpp
+Linking...
+Embedding manifest...
+Autorun "j:\Cpp\Misc\debug\xint_test_addsub.exe"
+Running 1 test case...
+*** No errors detected
+Detected memory leaks!
+Dumping objects ->
+{395} normal block at 0x007520F8, 52 bytes long.
+ Data: < !u > 01 00 00 00 03 00 00 00 04 21 75 00 00 00 00 00
+{394} normal block at 0x00721FD0, 4 bytes long.
+ Data: < u > F8 20 75 00
+Object dump complete.
+Build Time 0:05
+Build log was saved at "file://j:\Cpp\Misc\xint_test_addsub\Debug\BuildLog.htm"
+xint_test_addsub - 0 error(s), 0 warning(s)
+========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
+
+*/
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk