mirror of
https://github.com/boostorg/conversion.git
synced 2025-07-29 20:17:25 +02:00
Initial re-commit after CVS disk crash
[SVN r18348]
This commit is contained in:
34
test/Jamfile
Normal file
34
test/Jamfile
Normal file
@ -0,0 +1,34 @@
|
||||
# Signals library
|
||||
|
||||
# Copyright (C) 2001-2003 Douglas Gregor
|
||||
|
||||
# Permission to copy, use, sell and distribute this software is granted
|
||||
# provided this copyright notice appears in all copies. Permission to modify
|
||||
# the code and to distribute modified code is granted provided this copyright
|
||||
# notice appears in all copies, and a notice that the code was modified is
|
||||
# included with the copyright notice. This software is provided "as is"
|
||||
# without express or implied warranty, and with no claim as to its suitability
|
||||
# for any purpose.
|
||||
|
||||
# For more information, see http://www.boost.org/
|
||||
|
||||
|
||||
# Testing Jamfile autogenerated from XML source
|
||||
subproject libs/conversion/test ;
|
||||
|
||||
# bring in rules for testing
|
||||
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
|
||||
include testing.jam ;
|
||||
|
||||
# Make tests run by default.
|
||||
DEPENDS all : test ;
|
||||
|
||||
{
|
||||
test-suite conversion
|
||||
: [ run implicit_cast.cpp ]
|
||||
[ compile-fail implicit_cast_fail.cpp ]
|
||||
[ run ../cast_test.cpp ]
|
||||
[ run ../lexical_cast_test.cpp ]
|
||||
;
|
||||
}
|
||||
|
34
test/implicit_cast.cpp
Normal file
34
test/implicit_cast.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright David Abrahams 2003. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
#include <boost/implicit_cast.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/type.hpp>
|
||||
|
||||
using boost::implicit_cast;
|
||||
using boost::type;
|
||||
|
||||
template <class T>
|
||||
type<T> check_return(T) { return type<T>(); }
|
||||
|
||||
struct foo
|
||||
{
|
||||
foo(char const*) {}
|
||||
operator long() const { return 0; }
|
||||
};
|
||||
|
||||
typedef type<long> long_type;
|
||||
typedef type<foo> foo_type;
|
||||
|
||||
int main()
|
||||
{
|
||||
type<long> x = check_return(boost::implicit_cast<long>(1));
|
||||
assert(boost::implicit_cast<long>(1) == 1L);
|
||||
|
||||
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
|
||||
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
|
||||
return 0;
|
||||
}
|
23
test/implicit_cast_fail.cpp
Normal file
23
test/implicit_cast_fail.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright David Abrahams 2003. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
#include <boost/implicit_cast.hpp>
|
||||
#include <boost/type.hpp>
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
using boost::implicit_cast;
|
||||
|
||||
struct foo
|
||||
{
|
||||
explicit foo(char const*) {}
|
||||
};
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
foo x = implicit_cast<foo>("foobar");
|
||||
}
|
Reference in New Issue
Block a user