Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef A_H
#define A_H
#include <cassert>
class A
{
int id_;
public:
explicit A(int id) : id_(id) {++count;}
A(const A& a) : id_(a.id_) {++count;}
~A() {assert(id_ >= 0); id_ = -1; --count;}
int id() const {return id_;}
static int count;
};
int A::count = 0;
#endif // A_H

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef AB_H
#define AB_H
#include <cassert>
class A
{
int id_;
public:
explicit A(int id) : id_(id) {++count;}
A(const A& a) : id_(a.id_) {++count;}
virtual ~A() {assert(id_ >= 0); id_ = -1; --count;}
static int count;
};
int A::count = 0;
class B
: public A
{
public:
explicit B(int id) : A(id) {++count;}
B(const B& a) : A(a) {++count;}
virtual ~B() {--count;}
static int count;
};
int B::count = 0;
#endif // AB_H

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr& operator=(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p1 = new A(1);
const std::auto_ptr<A> ap1(p1);
A* p2 = new A(2);
std::auto_ptr<A> ap2(p2);
assert(A::count == 2);
assert(ap1.get() == p1);
assert(ap2.get() == p2);
std::auto_ptr<A>& apr = ap2 = ap1;
assert(&apr == &ap2);
assert(A::count == 1);
assert(ap1.get() == 0);
assert(ap2.get() == p1);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr& operator=(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p1 = new A(1);
std::auto_ptr<A> ap1(p1);
A* p2 = new A(2);
std::auto_ptr<A> ap2(p2);
assert(A::count == 2);
assert(ap1.get() == p1);
assert(ap2.get() == p2);
std::auto_ptr<A>& apr = ap2 = ap1;
assert(&apr == &ap2);
assert(A::count == 1);
assert(ap1.get() == 0);
assert(ap2.get() == p1);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
{
B* p = new B(1);
const std::auto_ptr<B> ap1(p);
std::auto_ptr<A> ap2(ap1);
assert(ap1.get() == 0);
assert(ap2.get() == p);
assert(A::count == 1);
assert(B::count == 1);
}
assert(A::count == 0);
assert(B::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
{
B* p = new B(1);
std::auto_ptr<B> ap1(p);
std::auto_ptr<A> ap2(ap1);
assert(ap1.get() == 0);
assert(ap2.get() == p);
assert(A::count == 1);
assert(B::count == 1);
}
assert(A::count == 0);
assert(B::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
{
B* p1 = new B(1);
const std::auto_ptr<B> ap1(p1);
A* p2 = new A(2);
std::auto_ptr<A> ap2(p2);
assert(A::count == 2);
assert(B::count == 1);
assert(ap1.get() == p1);
assert(ap2.get() == p2);
std::auto_ptr<A>& apr = ap2 = ap1;
assert(&apr == &ap2);
assert(A::count == 1);
assert(B::count == 1);
assert(ap1.get() == 0);
assert(ap2.get() == p1);
}
assert(A::count == 0);
assert(B::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
{
B* p1 = new B(1);
std::auto_ptr<B> ap1(p1);
A* p2 = new A(2);
std::auto_ptr<A> ap2(p2);
assert(A::count == 2);
assert(B::count == 1);
assert(ap1.get() == p1);
assert(ap2.get() == p2);
std::auto_ptr<A>& apr = ap2 = ap1;
assert(&apr == &ap2);
assert(A::count == 1);
assert(B::count == 1);
assert(ap1.get() == 0);
assert(ap2.get() == p1);
}
assert(A::count == 0);
assert(B::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
const std::auto_ptr<A> ap1(p);
std::auto_ptr<A> ap2(ap1);
assert(ap1.get() == 0);
assert(ap2.get() == p);
assert(A::count == 1);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr(auto_ptr& a) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap1(p);
std::auto_ptr<A> ap2(ap1);
assert(ap1.get() == 0);
assert(ap2.get() == p);
assert(A::count == 1);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// explicit auto_ptr(X* p =0) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap = p;
assert(ap.get() == p);
assert(A::count == 1);
}
assert(A::count == 0);
{
std::auto_ptr<A> ap;
assert(ap.get() == 0);
}
}
int main()
{
test();
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// explicit auto_ptr(X* p =0) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
assert(ap.get() == p);
assert(A::count == 1);
}
assert(A::count == 0);
{
std::auto_ptr<A> ap;
assert(ap.get() == 0);
}
}
int main()
{
test();
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr& operator=(auto_ptr_ref<X> r) throw()
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p1 = new A(1);
std::auto_ptr<A> ap1(p1);
std::auto_ptr_ref<A> apr = ap1;
std::auto_ptr<A> ap2(new A(2));
ap2 = apr;
assert(A::count == 1);
assert(ap2.get() == p1);
assert(ap1.get() == 0);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// auto_ptr(auto_ptr_ref<X> r) throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
{
B* p1 = new B(1);
std::auto_ptr<B> ap1(p1);
std::auto_ptr_ref<A> apr = ap1;
std::auto_ptr<A> ap2(apr);
assert(ap2.get() == p1);
assert(ap1.get() == 0);
}
assert(A::count == 0);
assert(B::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// template<class Y> operator auto_ptr<Y>() throw();
#include <memory>
#include <cassert>
#include "../AB.h"
std::auto_ptr<B>
source()
{
return std::auto_ptr<B>(new B(1));
}
void
test()
{
std::auto_ptr<A> ap2(source());
}
int main()
{
test();
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// template<class Y> operator auto_ptr_ref<Y>() throw();
#include <memory>
#include <cassert>
#include "../AB.h"
void
test()
{
B* p1 = new B(1);
std::auto_ptr<B> ap1(p1);
std::auto_ptr_ref<A> apr = ap1;
delete p1;
}
int main()
{
test();
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// X& operator*() const throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
assert(ap->id() == 1);
*ap = A(3);
assert(ap->id() == 3);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// X& operator*() const throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
const std::auto_ptr<A> ap(p);
assert((*ap).id() == 1);
*ap = A(3);
assert((*ap).id() == 3);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// X* release() throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
A* p2 = ap.release();
assert(p2 == p);
assert(ap.get() == 0);
delete p;
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X> class auto_ptr;
// void reset(X* p=0) throw();
#include <memory>
#include <cassert>
#include "../A.h"
void
test()
{
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
ap.reset();
assert(ap.get() == 0);
assert(A::count == 0);
}
assert(A::count == 0);
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
ap.reset(p);
assert(ap.get() == p);
assert(A::count == 1);
}
assert(A::count == 0);
{
A* p = new A(1);
std::auto_ptr<A> ap(p);
A* p2 = new A(2);
ap.reset(p2);
assert(ap.get() == p2);
assert(A::count == 1);
}
assert(A::count == 0);
}
int main()
{
test();
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X>
// class auto_ptr
// {
// public:
// typedef X element_type;
// ...
// };
#include <memory>
#include <type_traits>
template <class T>
void
test()
{
static_assert((std::is_same<typename std::auto_ptr<T>::element_type, T>::value), "");
}
int main()
{
test<int>();
test<double>();
test<void>();
std::auto_ptr<void> p;
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <assert.h>
#include <assert.h>
#ifndef assert
#error assert not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ciso646>
#include <ciso646>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <complex.h>
#include <complex.h>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
std::complex<double> d;
}

View File

@@ -0,0 +1,103 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ctype.h>
#include <ctype.h>
#include <type_traits>
#include <cassert>
#ifdef isalnum
#error isalnum defined
#endif
#ifdef isalpha
#error isalpha defined
#endif
#ifdef isblank
#error isblank defined
#endif
#ifdef iscntrl
#error iscntrl defined
#endif
#ifdef isdigit
#error isdigit defined
#endif
#ifdef isgraph
#error isgraph defined
#endif
#ifdef islower
#error islower defined
#endif
#ifdef isprint
#error isprint defined
#endif
#ifdef ispunct
#error ispunct defined
#endif
#ifdef isspace
#error isspace defined
#endif
#ifdef isupper
#error isupper defined
#endif
#ifdef isxdigit
#error isxdigit defined
#endif
#ifdef tolower
#error tolower defined
#endif
#ifdef toupper
#error toupper defined
#endif
int main()
{
static_assert((std::is_same<decltype(isalnum(0)), int>::value), "");
static_assert((std::is_same<decltype(isalpha(0)), int>::value), "");
static_assert((std::is_same<decltype(isblank(0)), int>::value), "");
static_assert((std::is_same<decltype(iscntrl(0)), int>::value), "");
static_assert((std::is_same<decltype(isdigit(0)), int>::value), "");
static_assert((std::is_same<decltype(isgraph(0)), int>::value), "");
static_assert((std::is_same<decltype(islower(0)), int>::value), "");
static_assert((std::is_same<decltype(isprint(0)), int>::value), "");
static_assert((std::is_same<decltype(ispunct(0)), int>::value), "");
static_assert((std::is_same<decltype(isspace(0)), int>::value), "");
static_assert((std::is_same<decltype(isupper(0)), int>::value), "");
static_assert((std::is_same<decltype(isxdigit(0)), int>::value), "");
static_assert((std::is_same<decltype(tolower(0)), int>::value), "");
static_assert((std::is_same<decltype(toupper(0)), int>::value), "");
assert(isalnum('a'));
assert(isalpha('a'));
assert(isblank(' '));
assert(!iscntrl(' '));
assert(!isdigit('a'));
assert(isgraph('a'));
assert(islower('a'));
assert(isprint('a'));
assert(!ispunct('a'));
assert(!isspace('a'));
assert(!isupper('a'));
assert(isxdigit('a'));
assert(tolower('A') == 'a');
assert(toupper('a') == 'A');
}

View File

@@ -0,0 +1,33 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <errno.h>
#include <errno.h>
#ifndef EDOM
#error EDOM not defined
#endif
#ifndef EILSEQ
#error EILSEQ not defined
#endif
#ifndef ERANGE
#error ERANGE not defined
#endif
#ifndef errno
#error errno not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,76 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// XFAIL: newlib
// <fenv.h>
#include <fenv.h>
#include <type_traits>
#ifndef FE_DIVBYZERO
#error FE_DIVBYZERO not defined
#endif
#ifndef FE_INEXACT
#error FE_INEXACT not defined
#endif
#ifndef FE_INVALID
#error FE_INVALID not defined
#endif
#ifndef FE_OVERFLOW
#error FE_OVERFLOW not defined
#endif
#ifndef FE_UNDERFLOW
#error FE_UNDERFLOW not defined
#endif
#ifndef FE_ALL_EXCEPT
#error FE_ALL_EXCEPT not defined
#endif
#ifndef FE_DOWNWARD
#error FE_DOWNWARD not defined
#endif
#ifndef FE_TONEAREST
#error FE_TONEAREST not defined
#endif
#ifndef FE_TOWARDZERO
#error FE_TOWARDZERO not defined
#endif
#ifndef FE_UPWARD
#error FE_UPWARD not defined
#endif
#ifndef FE_DFL_ENV
#error FE_DFL_ENV not defined
#endif
int main()
{
fenv_t fenv = {0};
fexcept_t fex = 0;
static_assert((std::is_same<decltype(feclearexcept(0)), int>::value), "");
static_assert((std::is_same<decltype(fegetexceptflag(&fex, 0)), int>::value), "");
static_assert((std::is_same<decltype(feraiseexcept(0)), int>::value), "");
static_assert((std::is_same<decltype(fesetexceptflag(&fex, 0)), int>::value), "");
static_assert((std::is_same<decltype(fetestexcept(0)), int>::value), "");
static_assert((std::is_same<decltype(fegetround()), int>::value), "");
static_assert((std::is_same<decltype(fesetround(0)), int>::value), "");
static_assert((std::is_same<decltype(fegetenv(&fenv)), int>::value), "");
static_assert((std::is_same<decltype(feholdexcept(&fenv)), int>::value), "");
static_assert((std::is_same<decltype(fesetenv(&fenv)), int>::value), "");
static_assert((std::is_same<decltype(feupdateenv(&fenv)), int>::value), "");
}

View File

@@ -0,0 +1,140 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <float.h>
#include <float.h>
#ifndef FLT_ROUNDS
#error FLT_ROUNDS not defined
#endif
#ifndef FLT_EVAL_METHOD
#error FLT_EVAL_METHOD not defined
#endif
#ifndef FLT_RADIX
#error FLT_RADIX not defined
#endif
#ifndef FLT_MANT_DIG
#error FLT_MANT_DIG not defined
#endif
#ifndef DBL_MANT_DIG
#error DBL_MANT_DIG not defined
#endif
#ifndef LDBL_MANT_DIG
#error LDBL_MANT_DIG not defined
#endif
#ifndef DECIMAL_DIG
#error DECIMAL_DIG not defined
#endif
#ifndef FLT_DIG
#error FLT_DIG not defined
#endif
#ifndef DBL_DIG
#error DBL_DIG not defined
#endif
#ifndef LDBL_DIG
#error LDBL_DIG not defined
#endif
#ifndef FLT_MIN_EXP
#error FLT_MIN_EXP not defined
#endif
#ifndef DBL_MIN_EXP
#error DBL_MIN_EXP not defined
#endif
#ifndef LDBL_MIN_EXP
#error LDBL_MIN_EXP not defined
#endif
#ifndef FLT_MIN_10_EXP
#error FLT_MIN_10_EXP not defined
#endif
#ifndef DBL_MIN_10_EXP
#error DBL_MIN_10_EXP not defined
#endif
#ifndef LDBL_MIN_10_EXP
#error LDBL_MIN_10_EXP not defined
#endif
#ifndef FLT_MAX_EXP
#error FLT_MAX_EXP not defined
#endif
#ifndef DBL_MAX_EXP
#error DBL_MAX_EXP not defined
#endif
#ifndef LDBL_MAX_EXP
#error LDBL_MAX_EXP not defined
#endif
#ifndef FLT_MAX_10_EXP
#error FLT_MAX_10_EXP not defined
#endif
#ifndef DBL_MAX_10_EXP
#error DBL_MAX_10_EXP not defined
#endif
#ifndef LDBL_MAX_10_EXP
#error LDBL_MAX_10_EXP not defined
#endif
#ifndef FLT_MAX
#error FLT_MAX not defined
#endif
#ifndef DBL_MAX
#error DBL_MAX not defined
#endif
#ifndef LDBL_MAX
#error LDBL_MAX not defined
#endif
#ifndef FLT_EPSILON
#error FLT_EPSILON not defined
#endif
#ifndef DBL_EPSILON
#error DBL_EPSILON not defined
#endif
#ifndef LDBL_EPSILON
#error LDBL_EPSILON not defined
#endif
#ifndef FLT_MIN
#error FLT_MIN not defined
#endif
#ifndef DBL_MIN
#error DBL_MIN not defined
#endif
#ifndef LDBL_MIN
#error LDBL_MIN not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,643 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <inttypes.h>
#include <inttypes.h>
#include <type_traits>
#ifndef PRId8
#error PRId8 not defined
#endif
#ifndef PRId16
#error PRId16 not defined
#endif
#ifndef PRId32
#error PRId32 not defined
#endif
#ifndef PRId64
#error PRId64 not defined
#endif
#ifndef PRIdLEAST8
#error PRIdLEAST8 not defined
#endif
#ifndef PRIdLEAST16
#error PRIdLEAST16 not defined
#endif
#ifndef PRIdLEAST32
#error PRIdLEAST32 not defined
#endif
#ifndef PRIdLEAST64
#error PRIdLEAST64 not defined
#endif
#ifndef PRIdFAST8
#error PRIdFAST8 not defined
#endif
#ifndef PRIdFAST16
#error PRIdFAST16 not defined
#endif
#ifndef PRIdFAST32
#error PRIdFAST32 not defined
#endif
#ifndef PRIdFAST64
#error PRIdFAST64 not defined
#endif
#ifndef PRIdMAX
#error PRIdMAX not defined
#endif
#ifndef PRIdPTR
#error PRIdPTR not defined
#endif
#ifndef PRIi8
#error PRIi8 not defined
#endif
#ifndef PRIi16
#error PRIi16 not defined
#endif
#ifndef PRIi32
#error PRIi32 not defined
#endif
#ifndef PRIi64
#error PRIi64 not defined
#endif
#ifndef PRIiLEAST8
#error PRIiLEAST8 not defined
#endif
#ifndef PRIiLEAST16
#error PRIiLEAST16 not defined
#endif
#ifndef PRIiLEAST32
#error PRIiLEAST32 not defined
#endif
#ifndef PRIiLEAST64
#error PRIiLEAST64 not defined
#endif
#ifndef PRIiFAST8
#error PRIiFAST8 not defined
#endif
#ifndef PRIiFAST16
#error PRIiFAST16 not defined
#endif
#ifndef PRIiFAST32
#error PRIiFAST32 not defined
#endif
#ifndef PRIiFAST64
#error PRIiFAST64 not defined
#endif
#ifndef PRIiMAX
#error PRIiMAX not defined
#endif
#ifndef PRIiPTR
#error PRIiPTR not defined
#endif
#ifndef PRIo8
#error PRIo8 not defined
#endif
#ifndef PRIo16
#error PRIo16 not defined
#endif
#ifndef PRIo32
#error PRIo32 not defined
#endif
#ifndef PRIo64
#error PRIo64 not defined
#endif
#ifndef PRIoLEAST8
#error PRIoLEAST8 not defined
#endif
#ifndef PRIoLEAST16
#error PRIoLEAST16 not defined
#endif
#ifndef PRIoLEAST32
#error PRIoLEAST32 not defined
#endif
#ifndef PRIoLEAST64
#error PRIoLEAST64 not defined
#endif
#ifndef PRIoFAST8
#error PRIoFAST8 not defined
#endif
#ifndef PRIoFAST16
#error PRIoFAST16 not defined
#endif
#ifndef PRIoFAST32
#error PRIoFAST32 not defined
#endif
#ifndef PRIoFAST64
#error PRIoFAST64 not defined
#endif
#ifndef PRIoMAX
#error PRIoMAX not defined
#endif
#ifndef PRIoPTR
#error PRIoPTR not defined
#endif
#ifndef PRIu8
#error PRIu8 not defined
#endif
#ifndef PRIu16
#error PRIu16 not defined
#endif
#ifndef PRIu32
#error PRIu32 not defined
#endif
#ifndef PRIu64
#error PRIu64 not defined
#endif
#ifndef PRIuLEAST8
#error PRIuLEAST8 not defined
#endif
#ifndef PRIuLEAST16
#error PRIuLEAST16 not defined
#endif
#ifndef PRIuLEAST32
#error PRIuLEAST32 not defined
#endif
#ifndef PRIuLEAST64
#error PRIuLEAST64 not defined
#endif
#ifndef PRIuFAST8
#error PRIuFAST8 not defined
#endif
#ifndef PRIuFAST16
#error PRIuFAST16 not defined
#endif
#ifndef PRIuFAST32
#error PRIuFAST32 not defined
#endif
#ifndef PRIuFAST64
#error PRIuFAST64 not defined
#endif
#ifndef PRIuMAX
#error PRIuMAX not defined
#endif
#ifndef PRIuPTR
#error PRIuPTR not defined
#endif
#ifndef PRIx8
#error PRIx8 not defined
#endif
#ifndef PRIx16
#error PRIx16 not defined
#endif
#ifndef PRIx32
#error PRIx32 not defined
#endif
#ifndef PRIx64
#error PRIx64 not defined
#endif
#ifndef PRIxLEAST8
#error PRIxLEAST8 not defined
#endif
#ifndef PRIxLEAST16
#error PRIxLEAST16 not defined
#endif
#ifndef PRIxLEAST32
#error PRIxLEAST32 not defined
#endif
#ifndef PRIxLEAST64
#error PRIxLEAST64 not defined
#endif
#ifndef PRIxFAST8
#error PRIxFAST8 not defined
#endif
#ifndef PRIxFAST16
#error PRIxFAST16 not defined
#endif
#ifndef PRIxFAST32
#error PRIxFAST32 not defined
#endif
#ifndef PRIxFAST64
#error PRIxFAST64 not defined
#endif
#ifndef PRIxMAX
#error PRIxMAX not defined
#endif
#ifndef PRIxPTR
#error PRIxPTR not defined
#endif
#ifndef PRIX8
#error PRIX8 not defined
#endif
#ifndef PRIX16
#error PRIX16 not defined
#endif
#ifndef PRIX32
#error PRIX32 not defined
#endif
#ifndef PRIX64
#error PRIX64 not defined
#endif
#ifndef PRIXLEAST8
#error PRIXLEAST8 not defined
#endif
#ifndef PRIXLEAST16
#error PRIXLEAST16 not defined
#endif
#ifndef PRIXLEAST32
#error PRIXLEAST32 not defined
#endif
#ifndef PRIXLEAST64
#error PRIXLEAST64 not defined
#endif
#ifndef PRIXFAST8
#error PRIXFAST8 not defined
#endif
#ifndef PRIXFAST16
#error PRIXFAST16 not defined
#endif
#ifndef PRIXFAST32
#error PRIXFAST32 not defined
#endif
#ifndef PRIXFAST64
#error PRIXFAST64 not defined
#endif
#ifndef PRIXMAX
#error PRIXMAX not defined
#endif
#ifndef PRIXPTR
#error PRIXPTR not defined
#endif
#ifndef SCNd8
#error SCNd8 not defined
#endif
#ifndef SCNd16
#error SCNd16 not defined
#endif
#ifndef SCNd32
#error SCNd32 not defined
#endif
#ifndef SCNd64
#error SCNd64 not defined
#endif
#ifndef SCNdLEAST8
#error SCNdLEAST8 not defined
#endif
#ifndef SCNdLEAST16
#error SCNdLEAST16 not defined
#endif
#ifndef SCNdLEAST32
#error SCNdLEAST32 not defined
#endif
#ifndef SCNdLEAST64
#error SCNdLEAST64 not defined
#endif
#ifndef SCNdFAST8
#error SCNdFAST8 not defined
#endif
#ifndef SCNdFAST16
#error SCNdFAST16 not defined
#endif
#ifndef SCNdFAST32
#error SCNdFAST32 not defined
#endif
#ifndef SCNdFAST64
#error SCNdFAST64 not defined
#endif
#ifndef SCNdMAX
#error SCNdMAX not defined
#endif
#ifndef SCNdPTR
#error SCNdPTR not defined
#endif
#ifndef SCNi8
#error SCNi8 not defined
#endif
#ifndef SCNi16
#error SCNi16 not defined
#endif
#ifndef SCNi32
#error SCNi32 not defined
#endif
#ifndef SCNi64
#error SCNi64 not defined
#endif
#ifndef SCNiLEAST8
#error SCNiLEAST8 not defined
#endif
#ifndef SCNiLEAST16
#error SCNiLEAST16 not defined
#endif
#ifndef SCNiLEAST32
#error SCNiLEAST32 not defined
#endif
#ifndef SCNiLEAST64
#error SCNiLEAST64 not defined
#endif
#ifndef SCNiFAST8
#error SCNiFAST8 not defined
#endif
#ifndef SCNiFAST16
#error SCNiFAST16 not defined
#endif
#ifndef SCNiFAST32
#error SCNiFAST32 not defined
#endif
#ifndef SCNiFAST64
#error SCNiFAST64 not defined
#endif
#ifndef SCNiMAX
#error SCNiMAX not defined
#endif
#ifndef SCNiPTR
#error SCNiPTR not defined
#endif
#ifndef SCNo8
#error SCNo8 not defined
#endif
#ifndef SCNo16
#error SCNo16 not defined
#endif
#ifndef SCNo32
#error SCNo32 not defined
#endif
#ifndef SCNo64
#error SCNo64 not defined
#endif
#ifndef SCNoLEAST8
#error SCNoLEAST8 not defined
#endif
#ifndef SCNoLEAST16
#error SCNoLEAST16 not defined
#endif
#ifndef SCNoLEAST32
#error SCNoLEAST32 not defined
#endif
#ifndef SCNoLEAST64
#error SCNoLEAST64 not defined
#endif
#ifndef SCNoFAST8
#error SCNoFAST8 not defined
#endif
#ifndef SCNoFAST16
#error SCNoFAST16 not defined
#endif
#ifndef SCNoFAST32
#error SCNoFAST32 not defined
#endif
#ifndef SCNoFAST64
#error SCNoFAST64 not defined
#endif
#ifndef SCNoMAX
#error SCNoMAX not defined
#endif
#ifndef SCNoPTR
#error SCNoPTR not defined
#endif
#ifndef SCNu8
#error SCNu8 not defined
#endif
#ifndef SCNu16
#error SCNu16 not defined
#endif
#ifndef SCNu32
#error SCNu32 not defined
#endif
#ifndef SCNu64
#error SCNu64 not defined
#endif
#ifndef SCNuLEAST8
#error SCNuLEAST8 not defined
#endif
#ifndef SCNuLEAST16
#error SCNuLEAST16 not defined
#endif
#ifndef SCNuLEAST32
#error SCNuLEAST32 not defined
#endif
#ifndef SCNuLEAST64
#error SCNuLEAST64 not defined
#endif
#ifndef SCNuFAST8
#error SCNuFAST8 not defined
#endif
#ifndef SCNuFAST16
#error SCNuFAST16 not defined
#endif
#ifndef SCNuFAST32
#error SCNuFAST32 not defined
#endif
#ifndef SCNuFAST64
#error SCNuFAST64 not defined
#endif
#ifndef SCNuMAX
#error SCNuMAX not defined
#endif
#ifndef SCNuPTR
#error SCNuPTR not defined
#endif
#ifndef SCNx8
#error SCNx8 not defined
#endif
#ifndef SCNx16
#error SCNx16 not defined
#endif
#ifndef SCNx32
#error SCNx32 not defined
#endif
#ifndef SCNx64
#error SCNx64 not defined
#endif
#ifndef SCNxLEAST8
#error SCNxLEAST8 not defined
#endif
#ifndef SCNxLEAST16
#error SCNxLEAST16 not defined
#endif
#ifndef SCNxLEAST32
#error SCNxLEAST32 not defined
#endif
#ifndef SCNxLEAST64
#error SCNxLEAST64 not defined
#endif
#ifndef SCNxFAST8
#error SCNxFAST8 not defined
#endif
#ifndef SCNxFAST16
#error SCNxFAST16 not defined
#endif
#ifndef SCNxFAST32
#error SCNxFAST32 not defined
#endif
#ifndef SCNxFAST64
#error SCNxFAST64 not defined
#endif
#ifndef SCNxMAX
#error SCNxMAX not defined
#endif
#ifndef SCNxPTR
#error SCNxPTR not defined
#endif
int main()
{
{
imaxdiv_t i1 = {0};
}
intmax_t i = 0;
static_assert((std::is_same<decltype(imaxabs(i)), intmax_t>::value), "");
static_assert((std::is_same<decltype(imaxdiv(i, i)), imaxdiv_t>::value), "");
static_assert((std::is_same<decltype(strtoimax("", (char**)0, 0)), intmax_t>::value), "");
static_assert((std::is_same<decltype(strtoumax("", (char**)0, 0)), uintmax_t>::value), "");
static_assert((std::is_same<decltype(wcstoimax(L"", (wchar_t**)0, 0)), intmax_t>::value), "");
static_assert((std::is_same<decltype(wcstoumax(L"", (wchar_t**)0, 0)), uintmax_t>::value), "");
}

View File

@@ -0,0 +1,17 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iso646.h>
#include <iso646.h>
int main()
{
// Nothing to test
}

View File

@@ -0,0 +1,92 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test limits.h
#include <limits.h>
#ifndef CHAR_BIT
#error CHAR_BIT not defined
#endif
#ifndef SCHAR_MIN
#error SCHAR_MIN not defined
#endif
#ifndef SCHAR_MAX
#error SCHAR_MAX not defined
#endif
#ifndef UCHAR_MAX
#error UCHAR_MAX not defined
#endif
#ifndef CHAR_MIN
#error CHAR_MIN not defined
#endif
#ifndef CHAR_MAX
#error CHAR_MAX not defined
#endif
#ifndef MB_LEN_MAX
#error MB_LEN_MAX not defined
#endif
#ifndef SHRT_MIN
#error SHRT_MIN not defined
#endif
#ifndef SHRT_MAX
#error SHRT_MAX not defined
#endif
#ifndef USHRT_MAX
#error USHRT_MAX not defined
#endif
#ifndef INT_MIN
#error INT_MIN not defined
#endif
#ifndef INT_MAX
#error INT_MAX not defined
#endif
#ifndef UINT_MAX
#error UINT_MAX not defined
#endif
#ifndef LONG_MIN
#error LONG_MIN not defined
#endif
#ifndef LONG_MAX
#error LONG_MAX not defined
#endif
#ifndef ULONG_MAX
#error ULONG_MAX not defined
#endif
#ifndef LLONG_MIN
#error LLONG_MIN not defined
#endif
#ifndef LLONG_MAX
#error LLONG_MAX not defined
#endif
#ifndef ULLONG_MAX
#error ULLONG_MAX not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale.h>
#include <locale.h>
#include <type_traits>
#ifndef LC_ALL
#error LC_ALL not defined
#endif
#ifndef LC_COLLATE
#error LC_COLLATE not defined
#endif
#ifndef LC_CTYPE
#error LC_CTYPE not defined
#endif
#ifndef LC_MONETARY
#error LC_MONETARY not defined
#endif
#ifndef LC_NUMERIC
#error LC_NUMERIC not defined
#endif
#ifndef LC_TIME
#error LC_TIME not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
int main()
{
lconv lc;
static_assert((std::is_same<decltype(setlocale(0, "")), char*>::value), "");
static_assert((std::is_same<decltype(localeconv()), lconv*>::value), "");
}

View File

@@ -0,0 +1,683 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <math.h>
// XFAIL: linux
#include <math.h>
#include <type_traits>
#include <cassert>
#include "hexfloat.h"
void test_acos()
{
static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
assert(acos(1) == 0);
}
void test_asin()
{
static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
assert(asin(0) == 0);
}
void test_atan()
{
static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
assert(atan(0) == 0);
}
void test_atan2()
{
static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
assert(atan2(0,1) == 0);
}
void test_ceil()
{
static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
assert(ceil(0) == 0);
}
void test_cos()
{
static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
assert(cos(0) == 1);
}
void test_cosh()
{
static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
assert(cosh(0) == 1);
}
void test_exp()
{
static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
static_assert((std::is_same<decltype(expf(0)), float>::value), "");
static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
assert(exp(0) == 1);
}
void test_fabs()
{
static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
static_assert((std::is_same<decltype(fabsf(0.f)), float>::value), "");
static_assert((std::is_same<decltype(fabsl(0.L)), long double>::value), "");
assert(fabs(-1.f) == 1);
}
void test_floor()
{
static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
assert(floor(1) == 1);
}
void test_fmod()
{
static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
assert(fmod(1.5,1) == .5);
}
void test_frexp()
{
int ip;
static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
assert(frexp(0, &ip) == 0);
}
void test_ldexp()
{
int ip = 1;
static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
assert(ldexp(1, ip) == 2);
}
void test_log()
{
static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
static_assert((std::is_same<decltype(logf(0)), float>::value), "");
static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
assert(log(1) == 0);
}
void test_log10()
{
static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
assert(log10(1) == 0);
}
void test_modf()
{
static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
double i;
assert(modf(1., &i) == 0);
}
void test_pow()
{
static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
assert(pow(1,1) == 1);
}
void test_sin()
{
static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
assert(sin(0) == 0);
}
void test_sinh()
{
static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
assert(sinh(0) == 0);
}
void test_sqrt()
{
static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
assert(sqrt(4) == 2);
}
void test_tan()
{
static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
assert(tan(0) == 0);
}
void test_tanh()
{
static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
assert(tanh(0) == 0);
}
void test_signbit()
{
static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
assert(signbit(-1.0) == true);
}
void test_fpclassify()
{
static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
assert(fpclassify(-1.0) == FP_NORMAL);
}
void test_isfinite()
{
static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
assert(isfinite(-1.0) == true);
}
void test_isinf()
{
static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isinf((double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
assert(isinf(-1.0) == false);
}
void test_isnan()
{
static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isnan((double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
assert(isnan(-1.0) == false);
}
void test_isnormal()
{
static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
assert(isnormal(-1.0) == true);
}
void test_isgreater()
{
static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
assert(isgreater(-1.0, 0.F) == false);
}
void test_isgreaterequal()
{
static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
assert(isgreaterequal(-1.0, 0.F) == false);
}
void test_isless()
{
static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
assert(isless(-1.0, 0.F) == true);
}
void test_islessequal()
{
static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
assert(islessequal(-1.0, 0.F) == true);
}
void test_islessgreater()
{
static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
assert(islessgreater(-1.0, 0.F) == true);
}
void test_isunordered()
{
static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
assert(isunordered(-1.0, 0.F) == false);
}
void test_acosh()
{
static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
assert(acosh(1) == 0);
}
void test_asinh()
{
static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
assert(asinh(0) == 0);
}
void test_atanh()
{
static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
assert(atanh(0) == 0);
}
void test_cbrt()
{
static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
assert(cbrt(1) == 1);
}
void test_copysign()
{
static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
assert(copysign(1,1) == 1);
}
void test_erf()
{
static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
static_assert((std::is_same<decltype(erff(0)), float>::value), "");
static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
assert(erf(0) == 0);
}
void test_erfc()
{
static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
assert(erfc(0) == 1);
}
void test_exp2()
{
static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
assert(exp2(1) == 2);
}
void test_expm1()
{
static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
assert(expm1(0) == 0);
}
void test_fdim()
{
static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
assert(fdim(1,0) == 1);
}
void test_fma()
{
static_assert((std::is_same<decltype(fma((double)0, (double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
assert(fma(1,1,1) == 2);
}
void test_fmax()
{
static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
assert(fmax(1,0) == 1);
}
void test_fmin()
{
static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
assert(fmin(1,0) == 0);
}
void test_hypot()
{
static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
assert(hypot(3,4) == 5);
}
void test_ilogb()
{
static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
assert(ilogb(1) == 0);
}
void test_lgamma()
{
static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
assert(lgamma(1) == 0);
}
void test_llrint()
{
static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
assert(llrint(1) == 1LL);
}
void test_llround()
{
static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
assert(llround(1) == 1LL);
}
void test_log1p()
{
static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
assert(log1p(0) == 0);
}
void test_log2()
{
static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
assert(log2(1) == 0);
}
void test_logb()
{
static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
assert(logb(1) == 0);
}
void test_lrint()
{
static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
assert(lrint(1) == 1L);
}
void test_lround()
{
static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
assert(lround(1) == 1L);
}
void test_nan()
{
static_assert((std::is_same<decltype(nan("")), double>::value), "");
static_assert((std::is_same<decltype(nanf("")), float>::value), "");
static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
}
void test_nearbyint()
{
static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
assert(nearbyint(1) == 1);
}
void test_nextafter()
{
static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
}
void test_nexttoward()
{
static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
}
void test_remainder()
{
static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
assert(remainder(0.5,1) == 0.5);
}
void test_remquo()
{
int ip;
static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
assert(remquo(0.5,1, &ip) == 0.5);
}
void test_rint()
{
static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
assert(rint(1) == 1);
}
void test_round()
{
static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
assert(round(1) == 1);
}
void test_scalbln()
{
static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
assert(scalbln(1, 1) == 2);
}
void test_scalbn()
{
static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
assert(scalbn(1, 1) == 2);
}
void test_tgamma()
{
static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
assert(tgamma(1) == 1);
}
void test_trunc()
{
static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
assert(trunc(1) == 1);
}
int main()
{
test_acos();
test_asin();
test_atan();
test_atan2();
test_ceil();
test_cos();
test_cosh();
test_exp();
test_fabs();
test_floor();
test_fmod();
test_frexp();
test_ldexp();
test_log();
test_log10();
test_modf();
test_pow();
test_sin();
test_sinh();
test_sqrt();
test_tan();
test_tanh();
test_signbit();
test_fpclassify();
test_isfinite();
test_isinf();
test_isnan();
test_isnormal();
test_isgreater();
test_isgreaterequal();
test_isless();
test_islessequal();
test_islessgreater();
test_isunordered();
test_acosh();
test_asinh();
test_atanh();
test_cbrt();
test_copysign();
test_erf();
test_erfc();
test_exp2();
test_expm1();
test_fdim();
test_fma();
test_fmax();
test_fmin();
test_hypot();
test_ilogb();
test_lgamma();
test_llrint();
test_llround();
test_log1p();
test_log2();
test_logb();
test_lrint();
test_lround();
test_nan();
test_nearbyint();
test_nextafter();
test_nexttoward();
test_remainder();
test_remquo();
test_rint();
test_round();
test_scalbln();
test_scalbn();
test_tgamma();
test_trunc();
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <setjmp.h>
#include <setjmp.h>
#include <type_traits>
int main()
{
jmp_buf jb;
static_assert((std::is_same<decltype(longjmp(jb, 0)), void>::value),
"std::is_same<decltype(longjmp(jb, 0)), void>::value");
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <signal.h>
#include <signal.h>
#include <type_traits>
#ifndef SIG_DFL
#error SIG_DFL not defined
#endif
#ifndef SIG_ERR
#error SIG_ERR not defined
#endif
#ifndef SIG_IGN
#error SIG_IGN not defined
#endif
#ifndef SIGABRT
#error SIGABRT not defined
#endif
#ifndef SIGFPE
#error SIGFPE not defined
#endif
#ifndef SIGILL
#error SIGILL not defined
#endif
#ifndef SIGINT
#error SIGINT not defined
#endif
#ifndef SIGSEGV
#error SIGSEGV not defined
#endif
#ifndef SIGTERM
#error SIGTERM not defined
#endif
int main()
{
sig_atomic_t sig;
typedef void (*func)(int);
static_assert((std::is_same<decltype(signal(0, (func)0)), func>::value), "");
static_assert((std::is_same<decltype(raise(0)), int>::value), "");
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdarg.h>
#include <stdarg.h>
#ifndef va_arg
#error va_arg not defined
#endif
#if __cplusplus >= 201103L
# ifndef va_copy
# error va_copy is not defined when c++ >= 11
# endif
#endif
#ifndef va_end
#error va_end not defined
#endif
#ifndef va_start
#error va_start not defined
#endif
int main()
{
va_list va;
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdbool.h>
#include <stdbool.h>
#ifndef __bool_true_false_are_defined
#error __bool_true_false_are_defined not defined
#endif
#ifdef bool
#error bool should not be defined
#endif
#ifdef true
#error true should not be defined
#endif
#ifdef false
#error false should not be defined
#endif
int main()
{
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stddef.h>
#include <stddef.h>
#include <type_traits>
#ifndef NULL
#error NULL not defined
#endif
#ifndef offsetof
#error offsetof not defined
#endif
int main()
{
static_assert(sizeof(size_t) == sizeof(void*),
"sizeof(size_t) == sizeof(void*)");
static_assert(std::is_unsigned<size_t>::value,
"std::is_unsigned<size_t>::value");
static_assert(std::is_integral<size_t>::value,
"std::is_integral<size_t>::value");
static_assert(sizeof(ptrdiff_t) == sizeof(void*),
"sizeof(ptrdiff_t) == sizeof(void*)");
static_assert(std::is_signed<ptrdiff_t>::value,
"std::is_signed<ptrdiff_t>::value");
static_assert(std::is_integral<ptrdiff_t>::value,
"std::is_integral<ptrdiff_t>::value");
}

View File

@@ -0,0 +1,290 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdint.h>
#include <stdint.h>
#include <csignal>
#include <cwctype>
#include <climits>
#include <type_traits>
#include <limits>
#include <cassert>
int main()
{
// typedef int8_t
static_assert(sizeof(int8_t)*CHAR_BIT == 8,
"sizeof(int8_t)*CHAR_BIT == 8");
static_assert(std::is_signed<int8_t>::value,
"std::is_signed<int8_t>::value");
// typedef int16_t
static_assert(sizeof(int16_t)*CHAR_BIT == 16,
"sizeof(int16_t)*CHAR_BIT == 16");
static_assert(std::is_signed<int16_t>::value,
"std::is_signed<int16_t>::value");
// typedef int32_t
static_assert(sizeof(int32_t)*CHAR_BIT == 32,
"sizeof(int32_t)*CHAR_BIT == 32");
static_assert(std::is_signed<int32_t>::value,
"std::is_signed<int32_t>::value");
// typedef int64_t
static_assert(sizeof(int64_t)*CHAR_BIT == 64,
"sizeof(int64_t)*CHAR_BIT == 64");
static_assert(std::is_signed<int64_t>::value,
"std::is_signed<int64_t>::value");
// typedef uint8_t
static_assert(sizeof(uint8_t)*CHAR_BIT == 8,
"sizeof(uint8_t)*CHAR_BIT == 8");
static_assert(std::is_unsigned<uint8_t>::value,
"std::is_unsigned<uint8_t>::value");
// typedef uint16_t
static_assert(sizeof(uint16_t)*CHAR_BIT == 16,
"sizeof(uint16_t)*CHAR_BIT == 16");
static_assert(std::is_unsigned<uint16_t>::value,
"std::is_unsigned<uint16_t>::value");
// typedef uint32_t
static_assert(sizeof(uint32_t)*CHAR_BIT == 32,
"sizeof(uint32_t)*CHAR_BIT == 32");
static_assert(std::is_unsigned<uint32_t>::value,
"std::is_unsigned<uint32_t>::value");
// typedef uint64_t
static_assert(sizeof(uint64_t)*CHAR_BIT == 64,
"sizeof(uint64_t)*CHAR_BIT == 64");
static_assert(std::is_unsigned<uint64_t>::value,
"std::is_unsigned<uint64_t>::value");
// typedef int_least8_t
static_assert(sizeof(int_least8_t)*CHAR_BIT >= 8,
"sizeof(int_least8_t)*CHAR_BIT >= 8");
static_assert(std::is_signed<int_least8_t>::value,
"std::is_signed<int_least8_t>::value");
// typedef int_least16_t
static_assert(sizeof(int_least16_t)*CHAR_BIT >= 16,
"sizeof(int_least16_t)*CHAR_BIT >= 16");
static_assert(std::is_signed<int_least16_t>::value,
"std::is_signed<int_least16_t>::value");
// typedef int_least32_t
static_assert(sizeof(int_least32_t)*CHAR_BIT >= 32,
"sizeof(int_least32_t)*CHAR_BIT >= 32");
static_assert(std::is_signed<int_least32_t>::value,
"std::is_signed<int_least32_t>::value");
// typedef int_least64_t
static_assert(sizeof(int_least64_t)*CHAR_BIT >= 64,
"sizeof(int_least64_t)*CHAR_BIT >= 64");
static_assert(std::is_signed<int_least64_t>::value,
"std::is_signed<int_least64_t>::value");
// typedef uint_least8_t
static_assert(sizeof(uint_least8_t)*CHAR_BIT >= 8,
"sizeof(uint_least8_t)*CHAR_BIT >= 8");
static_assert(std::is_unsigned<uint_least8_t>::value,
"std::is_unsigned<uint_least8_t>::value");
// typedef uint_least16_t
static_assert(sizeof(uint_least16_t)*CHAR_BIT >= 16,
"sizeof(uint_least16_t)*CHAR_BIT >= 16");
static_assert(std::is_unsigned<uint_least16_t>::value,
"std::is_unsigned<uint_least16_t>::value");
// typedef uint_least32_t
static_assert(sizeof(uint_least32_t)*CHAR_BIT >= 32,
"sizeof(uint_least32_t)*CHAR_BIT >= 32");
static_assert(std::is_unsigned<uint_least32_t>::value,
"std::is_unsigned<uint_least32_t>::value");
// typedef uint_least64_t
static_assert(sizeof(uint_least64_t)*CHAR_BIT >= 64,
"sizeof(uint_least64_t)*CHAR_BIT >= 64");
static_assert(std::is_unsigned<uint_least64_t>::value,
"std::is_unsigned<uint_least64_t>::value");
// typedef int_fast8_t
static_assert(sizeof(int_fast8_t)*CHAR_BIT >= 8,
"sizeof(int_fast8_t)*CHAR_BIT >= 8");
static_assert(std::is_signed<int_fast8_t>::value,
"std::is_signed<int_fast8_t>::value");
// typedef int_fast16_t
static_assert(sizeof(int_fast16_t)*CHAR_BIT >= 16,
"sizeof(int_fast16_t)*CHAR_BIT >= 16");
static_assert(std::is_signed<int_fast16_t>::value,
"std::is_signed<int_fast16_t>::value");
// typedef int_fast32_t
static_assert(sizeof(int_fast32_t)*CHAR_BIT >= 32,
"sizeof(int_fast32_t)*CHAR_BIT >= 32");
static_assert(std::is_signed<int_fast32_t>::value,
"std::is_signed<int_fast32_t>::value");
// typedef int_fast64_t
static_assert(sizeof(int_fast64_t)*CHAR_BIT >= 64,
"sizeof(int_fast64_t)*CHAR_BIT >= 64");
static_assert(std::is_signed<int_fast64_t>::value,
"std::is_signed<int_fast64_t>::value");
// typedef uint_fast8_t
static_assert(sizeof(uint_fast8_t)*CHAR_BIT >= 8,
"sizeof(uint_fast8_t)*CHAR_BIT >= 8");
static_assert(std::is_unsigned<uint_fast8_t>::value,
"std::is_unsigned<uint_fast8_t>::value");
// typedef uint_fast16_t
static_assert(sizeof(uint_fast16_t)*CHAR_BIT >= 16,
"sizeof(uint_fast16_t)*CHAR_BIT >= 16");
static_assert(std::is_unsigned<uint_fast16_t>::value,
"std::is_unsigned<uint_fast16_t>::value");
// typedef uint_fast32_t
static_assert(sizeof(uint_fast32_t)*CHAR_BIT >= 32,
"sizeof(uint_fast32_t)*CHAR_BIT >= 32");
static_assert(std::is_unsigned<uint_fast32_t>::value,
"std::is_unsigned<uint_fast32_t>::value");
// typedef uint_fast64_t
static_assert(sizeof(uint_fast64_t)*CHAR_BIT >= 64,
"sizeof(uint_fast64_t)*CHAR_BIT >= 64");
static_assert(std::is_unsigned<uint_fast64_t>::value,
"std::is_unsigned<uint_fast64_t>::value");
// typedef intptr_t
static_assert(sizeof(intptr_t) >= sizeof(void*),
"sizeof(intptr_t) >= sizeof(void*)");
static_assert(std::is_signed<intptr_t>::value,
"std::is_signed<intptr_t>::value");
// typedef uintptr_t
static_assert(sizeof(uintptr_t) >= sizeof(void*),
"sizeof(uintptr_t) >= sizeof(void*)");
static_assert(std::is_unsigned<uintptr_t>::value,
"std::is_unsigned<uintptr_t>::value");
// typedef intmax_t
static_assert(sizeof(intmax_t) >= sizeof(long long),
"sizeof(intmax_t) >= sizeof(long long)");
static_assert(std::is_signed<intmax_t>::value,
"std::is_signed<intmax_t>::value");
// typedef uintmax_t
static_assert(sizeof(uintmax_t) >= sizeof(unsigned long long),
"sizeof(uintmax_t) >= sizeof(unsigned long long)");
static_assert(std::is_unsigned<uintmax_t>::value,
"std::is_unsigned<uintmax_t>::value");
// INTN_MIN
static_assert(INT8_MIN == -128, "INT8_MIN == -128");
static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
// INTN_MAX
static_assert(INT8_MAX == 127, "INT8_MAX == 127");
static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
// UINTN_MAX
static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
// INT_FASTN_MIN
static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
// INT_FASTN_MAX
static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
// UINT_FASTN_MAX
static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
// INTPTR_MIN
assert(INTPTR_MIN == std::numeric_limits<intptr_t>::min());
// INTPTR_MAX
assert(INTPTR_MAX == std::numeric_limits<intptr_t>::max());
// UINTPTR_MAX
assert(UINTPTR_MAX == std::numeric_limits<uintptr_t>::max());
// INTMAX_MIN
assert(INTMAX_MIN == std::numeric_limits<intmax_t>::min());
// INTMAX_MAX
assert(INTMAX_MAX == std::numeric_limits<intmax_t>::max());
// UINTMAX_MAX
assert(UINTMAX_MAX == std::numeric_limits<uintmax_t>::max());
// PTRDIFF_MIN
assert(PTRDIFF_MIN == std::numeric_limits<ptrdiff_t>::min());
// PTRDIFF_MAX
assert(PTRDIFF_MAX == std::numeric_limits<ptrdiff_t>::max());
// SIG_ATOMIC_MIN
assert(SIG_ATOMIC_MIN == std::numeric_limits<sig_atomic_t>::min());
// SIG_ATOMIC_MAX
assert(SIG_ATOMIC_MAX == std::numeric_limits<sig_atomic_t>::max());
// SIZE_MAX
assert(SIZE_MAX == std::numeric_limits<size_t>::max());
// WCHAR_MIN
assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
// WCHAR_MAX
assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
// WINT_MIN
assert(WINT_MIN == std::numeric_limits<wint_t>::min());
// WINT_MAX
assert(WINT_MAX == std::numeric_limits<wint_t>::max());
#ifndef INT8_C
#error INT8_C not defined
#endif
#ifndef INT16_C
#error INT16_C not defined
#endif
#ifndef INT32_C
#error INT32_C not defined
#endif
#ifndef INT64_C
#error INT64_C not defined
#endif
#ifndef UINT8_C
#error UINT8_C not defined
#endif
#ifndef UINT16_C
#error UINT16_C not defined
#endif
#ifndef UINT32_C
#error UINT32_C not defined
#endif
#ifndef UINT64_C
#error UINT64_C not defined
#endif
#ifndef INTMAX_C
#error INTMAX_C not defined
#endif
#ifndef UINTMAX_C
#error UINTMAX_C not defined
#endif
}

View File

@@ -0,0 +1,138 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdio.h>
#include <stdio.h>
#include <type_traits>
#ifndef BUFSIZ
#error BUFSIZ not defined
#endif
#ifndef EOF
#error EOF not defined
#endif
#ifndef FILENAME_MAX
#error FILENAME_MAX not defined
#endif
#ifndef FOPEN_MAX
#error FOPEN_MAX not defined
#endif
#ifndef L_tmpnam
#error L_tmpnam not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
#ifndef SEEK_CUR
#error SEEK_CUR not defined
#endif
#ifndef SEEK_END
#error SEEK_END not defined
#endif
#ifndef SEEK_SET
#error SEEK_SET not defined
#endif
#ifndef TMP_MAX
#error TMP_MAX not defined
#endif
#ifndef _IOFBF
#error _IOFBF not defined
#endif
#ifndef _IOLBF
#error _IOLBF not defined
#endif
#ifndef _IONBF
#error _IONBF not defined
#endif
#ifndef stderr
#error stderr not defined
#endif
#ifndef stdin
#error stdin not defined
#endif
#ifndef stdout
#error stdout not defined
#endif
#include <cstdarg>
#pragma clang diagnostic ignored "-Wformat-zero-length"
int main()
{
FILE* fp = 0;
fpos_t fpos = {0};
size_t s = 0;
char* cp = 0;
va_list va;
static_assert((std::is_same<decltype(remove("")), int>::value), "");
static_assert((std::is_same<decltype(rename("","")), int>::value), "");
static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
static_assert((std::is_same<decltype(getchar()), int>::value), "");
#if _LIBCPP_STD_VER < 14
static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
#endif
static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
static_assert((std::is_same<decltype(puts("")), int>::value), "");
static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
static_assert((std::is_same<decltype(fwrite((const void*)0,0,0,fp)), size_t>::value), "");
static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
static_assert((std::is_same<decltype(perror("")), void>::value), "");
}

View File

@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdlib.h>
#include <stdlib.h>
#include <type_traits>
#ifndef EXIT_FAILURE
#error EXIT_FAILURE not defined
#endif
#ifndef EXIT_SUCCESS
#error EXIT_SUCCESS not defined
#endif
#ifndef MB_CUR_MAX
#error MB_CUR_MAX not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
#ifndef RAND_MAX
#error RAND_MAX not defined
#endif
int main()
{
size_t s = 0;
div_t d;
ldiv_t ld;
lldiv_t lld;
char** endptr = 0;
static_assert((std::is_same<decltype(atof("")), double>::value), "");
static_assert((std::is_same<decltype(atoi("")), int>::value), "");
static_assert((std::is_same<decltype(atol("")), long>::value), "");
static_assert((std::is_same<decltype(atoll("")), long long>::value), "");
static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
static_assert((std::is_same<decltype(strtod("", endptr)), double>::value), "");
static_assert((std::is_same<decltype(strtof("", endptr)), float>::value), "");
static_assert((std::is_same<decltype(strtold("", endptr)), long double>::value), "");
static_assert((std::is_same<decltype(strtol("", endptr,0)), long>::value), "");
static_assert((std::is_same<decltype(strtoll("", endptr,0)), long long>::value), "");
static_assert((std::is_same<decltype(strtoul("", endptr,0)), unsigned long>::value), "");
static_assert((std::is_same<decltype(strtoull("", endptr,0)), unsigned long long>::value), "");
static_assert((std::is_same<decltype(rand()), int>::value), "");
static_assert((std::is_same<decltype(srand(0)), void>::value), "");
static_assert((std::is_same<decltype(calloc(0,0)), void*>::value), "");
static_assert((std::is_same<decltype(free(0)), void>::value), "");
static_assert((std::is_same<decltype(malloc(0)), void*>::value), "");
static_assert((std::is_same<decltype(realloc(0,0)), void*>::value), "");
static_assert((std::is_same<decltype(abort()), void>::value), "");
static_assert((std::is_same<decltype(atexit(0)), int>::value), "");
static_assert((std::is_same<decltype(exit(0)), void>::value), "");
static_assert((std::is_same<decltype(_Exit(0)), void>::value), "");
static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
static_assert((std::is_same<decltype(system("")), int>::value), "");
static_assert((std::is_same<decltype(bsearch(0,0,0,0,0)), void*>::value), "");
static_assert((std::is_same<decltype(qsort(0,0,0,0)), void>::value), "");
static_assert((std::is_same<decltype(abs(0)), int>::value), "");
static_assert((std::is_same<decltype(labs((long)0)), long>::value), "");
static_assert((std::is_same<decltype(llabs((long long)0)), long long>::value), "");
static_assert((std::is_same<decltype(div(0,0)), div_t>::value), "");
static_assert((std::is_same<decltype(ldiv(0L,0L)), ldiv_t>::value), "");
static_assert((std::is_same<decltype(lldiv(0LL,0LL)), lldiv_t>::value), "");
static_assert((std::is_same<decltype(mblen("",0)), int>::value), "");
wchar_t* pw = 0;
const wchar_t* pwc = 0;
char* pc = 0;
static_assert((std::is_same<decltype(mbtowc(pw,"",0)), int>::value), "");
static_assert((std::is_same<decltype(wctomb(pc,L' ')), int>::value), "");
static_assert((std::is_same<decltype(mbstowcs(pw,"",0)), size_t>::value), "");
static_assert((std::is_same<decltype(wcstombs(pc,pwc,0)), size_t>::value), "");
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string.h>
#include <string.h>
#include <type_traits>
#ifndef NULL
#error NULL not defined
#endif
int main()
{
size_t s = 0;
void* vp = 0;
const void* vpc = 0;
char* cp = 0;
const char* cpc = 0;
static_assert((std::is_same<decltype(memcpy(vp, vpc, s)), void*>::value), "");
static_assert((std::is_same<decltype(memmove(vp, vpc, s)), void*>::value), "");
static_assert((std::is_same<decltype(strcpy(cp, cpc)), char*>::value), "");
static_assert((std::is_same<decltype(strncpy(cp, cpc, s)), char*>::value), "");
static_assert((std::is_same<decltype(strcat(cp, cpc)), char*>::value), "");
static_assert((std::is_same<decltype(strncat(cp, cpc, s)), char*>::value), "");
static_assert((std::is_same<decltype(memcmp(vpc, vpc, s)), int>::value), "");
static_assert((std::is_same<decltype(strcmp(cpc, cpc)), int>::value), "");
static_assert((std::is_same<decltype(strncmp(cpc, cpc, s)), int>::value), "");
static_assert((std::is_same<decltype(strcoll(cpc, cpc)), int>::value), "");
static_assert((std::is_same<decltype(strxfrm(cp, cpc, s)), size_t>::value), "");
static_assert((std::is_same<decltype(memchr(vp, 0, s)), void*>::value), "");
static_assert((std::is_same<decltype(strchr(cp, 0)), char*>::value), "");
static_assert((std::is_same<decltype(strcspn(cpc, cpc)), size_t>::value), "");
static_assert((std::is_same<decltype(strpbrk(cp, cpc)), char*>::value), "");
static_assert((std::is_same<decltype(strrchr(cp, 0)), char*>::value), "");
static_assert((std::is_same<decltype(strspn(cpc, cpc)), size_t>::value), "");
static_assert((std::is_same<decltype(strstr(cp, cpc)), char*>::value), "");
static_assert((std::is_same<decltype(strtok(cp, cpc)), char*>::value), "");
static_assert((std::is_same<decltype(memset(vp, 0, s)), void*>::value), "");
static_assert((std::is_same<decltype(strerror(0)), char*>::value), "");
static_assert((std::is_same<decltype(strlen(cpc)), size_t>::value), "");
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <tgmath.h>
#include <tgmath.h>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
std::complex<double> cd;
double x = sin(1.0);
(void)x; // to placate scan-build
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <time.h>
#include <time.h>
#include <type_traits>
#ifndef NULL
#error NULL not defined
#endif
#ifndef CLOCKS_PER_SEC
#error CLOCKS_PER_SEC not defined
#endif
int main()
{
clock_t c = 0;
size_t s = 0;
time_t t = 0;
tm tmv = {0};
static_assert((std::is_same<decltype(clock()), clock_t>::value), "");
static_assert((std::is_same<decltype(difftime(t,t)), double>::value), "");
static_assert((std::is_same<decltype(mktime(&tmv)), time_t>::value), "");
static_assert((std::is_same<decltype(time(&t)), time_t>::value), "");
static_assert((std::is_same<decltype(asctime(&tmv)), char*>::value), "");
static_assert((std::is_same<decltype(ctime(&t)), char*>::value), "");
static_assert((std::is_same<decltype(gmtime(&t)), tm*>::value), "");
static_assert((std::is_same<decltype(localtime(&t)), tm*>::value), "");
char* c1 = 0;
const char* c2 = 0;
static_assert((std::is_same<decltype(strftime(c1,s,c2,&tmv)), size_t>::value), "");
}

View File

@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// XFAIL: apple-darwin
// XFAIL: newlib
// <uchar.h>
#include <uchar.h>
int main()
{
}

View File

@@ -0,0 +1,104 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <wchar.h>
#include <wchar.h>
#include <type_traits>
#ifndef NULL
#error NULL not defined
#endif
#ifndef WCHAR_MAX
#error WCHAR_MAX not defined
#endif
#ifndef WCHAR_MIN
#error WCHAR_MIN not defined
#endif
#ifndef WEOF
#error WEOF not defined
#endif
int main()
{
mbstate_t mb = {0};
size_t s = 0;
tm *tm = 0;
wint_t w = 0;
::FILE* fp = 0;
#ifdef __APPLE__
__darwin_va_list va;
#else
__builtin_va_list va;
#endif
char* ns = 0;
wchar_t* ws = 0;
static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), "");
static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), "");
static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), "");
static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), "");
static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), "");
static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), "");
static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), "");
static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), "");
static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), "");
static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), "");
static_assert((std::is_same<decltype(wprintf(L"")), int>::value), "");
static_assert((std::is_same<decltype(wscanf(L"")), int>::value), "");
static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), "");
static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), "");
static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), "");
static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), "");
static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), "");
static_assert((std::is_same<decltype(getwchar()), wint_t>::value), "");
static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), "");
static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), "");
static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), "");
static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), "");
static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), "");
static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), "");
static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), "");
static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), "");
static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), "");
static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), "");
static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), "");
static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), "");
static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), "");
static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), "");
static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(wcsftime(ws, s, L"", tm)), size_t>::value), "");
static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), "");
static_assert((std::is_same<decltype(wctob(w)), int>::value), "");
static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), "");
static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), "");
static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), "");
static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), "");
static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), "");
static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), "");
}

View File

@@ -0,0 +1,114 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <wctype.h>
#include <wctype.h>
#include <type_traits>
#ifndef WEOF
#error WEOF not defined
#endif
#ifdef iswalnum
#error iswalnum defined
#endif
#ifdef iswalpha
#error iswalpha defined
#endif
#ifdef iswblank
#error iswblank defined
#endif
#ifdef iswcntrl
#error iswcntrl defined
#endif
#ifdef iswdigit
#error iswdigit defined
#endif
#ifdef iswgraph
#error iswgraph defined
#endif
#ifdef iswlower
#error iswlower defined
#endif
#ifdef iswprint
#error iswprint defined
#endif
#ifdef iswpunct
#error iswpunct defined
#endif
#ifdef iswspace
#error iswspace defined
#endif
#ifdef iswupper
#error iswupper defined
#endif
#ifdef iswxdigit
#error iswxdigit defined
#endif
#ifdef iswctype
#error iswctype defined
#endif
#ifdef wctype
#error wctype defined
#endif
#ifdef towlower
#error towlower defined
#endif
#ifdef towupper
#error towupper defined
#endif
#ifdef towctrans
#error towctrans defined
#endif
#ifdef wctrans
#error wctrans defined
#endif
int main()
{
wint_t w = 0;
wctrans_t wctr = 0;
wctype_t wct = 0;
static_assert((std::is_same<decltype(iswalnum(w)), int>::value), "");
static_assert((std::is_same<decltype(iswalpha(w)), int>::value), "");
static_assert((std::is_same<decltype(iswblank(w)), int>::value), "");
static_assert((std::is_same<decltype(iswcntrl(w)), int>::value), "");
static_assert((std::is_same<decltype(iswdigit(w)), int>::value), "");
static_assert((std::is_same<decltype(iswgraph(w)), int>::value), "");
static_assert((std::is_same<decltype(iswlower(w)), int>::value), "");
static_assert((std::is_same<decltype(iswprint(w)), int>::value), "");
static_assert((std::is_same<decltype(iswpunct(w)), int>::value), "");
static_assert((std::is_same<decltype(iswspace(w)), int>::value), "");
static_assert((std::is_same<decltype(iswupper(w)), int>::value), "");
static_assert((std::is_same<decltype(iswxdigit(w)), int>::value), "");
static_assert((std::is_same<decltype(iswctype(w, wct)), int>::value), "");
static_assert((std::is_same<decltype(wctype("")), wctype_t>::value), "");
static_assert((std::is_same<decltype(towlower(w)), wint_t>::value), "");
static_assert((std::is_same<decltype(towupper(w)), wint_t>::value), "");
static_assert((std::is_same<decltype(towctrans(w, wctr)), wint_t>::value), "");
static_assert((std::is_same<decltype(wctrans("")), wctrans_t>::value), "");
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// pointer_to_binary_function
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
typedef std::pointer_to_binary_function<int, short, double> F;
static_assert((std::is_base_of<std::binary_function<int, short, double>, F>::value), "");
const F f(binary_f);
assert(f(36, 27) == 9.75);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// pointer_to_unary_function
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
typedef std::pointer_to_unary_function<int, double> F;
static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
const F f(unary_f);
assert(f(36) == -35.5);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <CopyConstructible Arg, Returnable Result>
// pointer_to_unary_function<Arg, Result>
// ptr_fun(Result (*f)(Arg));
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
assert(std::ptr_fun(unary_f)(36) == -35.5);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result>
// pointer_to_binary_function<Arg1,Arg2,Result>
// ptr_fun(Result (*f)(Arg1, Arg2));
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
assert(std::ptr_fun(binary_f)(36, 27) == 9.75);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<cReturnable S, ClassType T>
// const_mem_fun_t<S,T>
// mem_fun(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a3)(&a) == 1);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a4)(&a, 6) == 5);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// const_mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(a, 6) == 5);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// const_mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<const A*, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(&a, 6) == 5);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T>
// const_mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a3)(a) == 1);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a4)(a, 6) == 5);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// const_mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_ref_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<A, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(a) == 1);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// const_mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<const A*, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(&a) == 1);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T>
// mem_fun_t<S,T>
// mem_fun(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a1)(&a) == 5);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a2)(&a, 5) == 6);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_ref_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(a, 5) == 6);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(&a, 5) == 6);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T>
// mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a1)(a) == 5);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a2)(a, 5) == 6);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_ref_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(a) == 5);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(&a) == 5);
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Arg1, class Arg2, class Result>
// struct binary_function
// {
// typedef Arg1 first_argument_type;
// typedef Arg2 second_argument_type;
// typedef Result result_type;
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::binary_function<int, unsigned, char>::first_argument_type, int>::value), "");
static_assert((std::is_same<std::binary_function<int, unsigned, char>::second_argument_type, unsigned>::value), "");
static_assert((std::is_same<std::binary_function<int, unsigned, char>::result_type, char>::value), "");
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Arg, class Result>
// struct unary_function
// {
// typedef Arg argument_type;
// typedef Result result_type;
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::unary_function<unsigned, char>::argument_type, unsigned>::value), "");
static_assert((std::is_same<std::unary_function<unsigned, char>::result_type, char>::value), "");
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ios>
//
// class ios_base
// {
// public:
// typedef T1 io_state;
// };
#include <strstream>
#include <cassert>
int main()
{
std::strstream::io_state b = std::strstream::eofbit;
assert(b == std::ios::eofbit);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ios>
//
// class ios_base
// {
// public:
// typedef T2 open_mode;
// };
#include <strstream>
#include <cassert>
int main()
{
std::strstream::open_mode b = std::strstream::app;
assert(b == std::ios::app);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ios>
//
// class ios_base
// {
// public:
// typedef T3 seek_dir;
// };
#include <strstream>
#include <cassert>
int main()
{
std::strstream::seek_dir b = std::strstream::cur;
assert(b == std::ios::cur);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ios>
//
// class ios_base
// {
// public:
// typedef OFF_T streamoff;
// };
#include <ios>
#include <type_traits>
int main()
{
static_assert((std::is_integral<std::ios_base::streamoff>::value), "");
static_assert((std::is_signed<std::ios_base::streamoff>::value), "");
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ios>
//
// class ios_base
// {
// public:
// typedef POS_T streampos;
// };
#include <ios>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::ios_base::streampos, std::streampos>::value), "");
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Fn, class T>
// binder1st<Fn>
// bind1st(const Fn& fn, const T& x);
#include <functional>
#include <cassert>
#include "../test_func.h"
int main()
{
assert(std::bind1st(test_func(1), 5)(10.) == -5.);
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Fn, class T>
// binder2nd<Fn>
// bind2nd(const Fn& op, const T& x);
#include <functional>
#include <cassert>
#include "../test_func.h"
int main()
{
assert(std::bind2nd(test_func(1), 5)(10) == 5.);
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Fn>
// class binder1st
// : public unary_function<typename Fn::second_argument_type, typename Fn::result_type>
// {
// protected:
// Fn op;
// typename Fn::first_argument_type value;
// public:
// binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
//
// typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
// typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
// };
#include <functional>
#include <type_traits>
#include <cassert>
#include "../test_func.h"
class test
: public std::binder1st<test_func>
{
typedef std::binder1st<test_func> base;
public:
test() : std::binder1st<test_func>(test_func(2), 30) {}
void do_test()
{
static_assert((std::is_base_of<
std::unary_function<test_func::second_argument_type,
test_func::result_type>,
test>::value), "");
assert(op.id() == 2);
assert(value == 30);
double d = 5;
assert((*this)(d) == 35);
assert((*this)(5) == 25);
}
};
int main()
{
test t;
t.do_test();
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Fn>
// class binder2nd
// : public unary_function<typename Fn::first_argument_type, typename Fn::result_type>
// {
// protected:
// Fn op;
// typename Fn::second_argument_type value;
// public:
// binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
//
// typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
// typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
// };
#include <functional>
#include <type_traits>
#include <cassert>
#include "../test_func.h"
class test
: public std::binder2nd<test_func>
{
typedef std::binder2nd<test_func> base;
public:
test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
void do_test()
{
static_assert((std::is_base_of<
std::unary_function<test_func::first_argument_type,
test_func::result_type>,
test>::value), "");
assert(op.id() == 3);
assert(value == 4.5);
int i = 5;
assert((*this)(i) == 22.5);
assert((*this)(5) == 0.5);
}
};
int main()
{
test t;
t.do_test();
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef TEST_FUNC_H
#define TEST_FUNC_H
class test_func
{
int id_;
public:
typedef int first_argument_type;
typedef double second_argument_type;
typedef long double result_type;
explicit test_func(int id) : id_(id) {}
int id() const {return id_;}
result_type operator() (const first_argument_type& x, second_argument_type& y) const
{return x+y;}
result_type operator() (const first_argument_type& x, const second_argument_type& y) const
{return x-y;}
result_type operator() (first_argument_type& x, const second_argument_type& y) const
{return x*y;}
};
#endif // TEST_FUNC_H

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// explicit istrstream(const char* s);
#include <strstream>
#include <cassert>
int main()
{
{
const char buf[] = "123 4.5 dog";
std::istrstream in(buf);
int i;
in >> i;
assert(i == 123);
double d;
in >> d;
assert(d == 4.5);
std::string s;
in >> s;
assert(s == "dog");
assert(in.eof());
assert(!in.fail());
in.clear();
in.putback('g');
assert(!in.fail());
in.putback('g');
assert(in.fail());
assert(buf[9] == 'o');
assert(buf[10] == 'g');
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// explicit istrstream(const char* s, streamsize n);
#include <strstream>
#include <cassert>
int main()
{
{
const char buf[] = "123 4.5 dog";
std::istrstream in(buf, 7);
int i;
in >> i;
assert(i == 123);
double d;
in >> d;
assert(d == 4.5);
std::string s;
in >> s;
assert(s == "");
assert(in.eof());
assert(in.fail());
in.clear();
in.putback('5');
assert(!in.fail());
in.putback('5');
assert(in.fail());
assert(buf[5] == '.');
assert(buf[6] == '5');
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// explicit istrstream(char* s);
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
std::istrstream in(buf);
int i;
in >> i;
assert(i == 123);
double d;
in >> d;
assert(d == 4.5);
std::string s;
in >> s;
assert(s == "dog");
assert(in.eof());
assert(!in.fail());
in.clear();
in.putback('g');
assert(!in.fail());
in.putback('g');
assert(!in.fail());
assert(buf[9] == 'g');
assert(buf[10] == 'g');
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// explicit istrstream(char* s, streamsize n);
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
std::istrstream in(buf, 7);
int i;
in >> i;
assert(i == 123);
double d;
in >> d;
assert(d == 4.5);
std::string s;
in >> s;
assert(s == "");
assert(in.eof());
assert(in.fail());
in.clear();
in.putback('5');
assert(!in.fail());
in.putback('5');
assert(!in.fail());
assert(buf[5] == '5');
assert(buf[6] == '5');
}
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// strstreambuf* rdbuf() const;
#include <strstream>
#include <cassert>
int main()
{
{
const char buf[] = "123 4.5 dog";
const std::istrstream in(buf);
std::strstreambuf* sb = in.rdbuf();
assert(sb->sgetc() == '1');
}
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// char* str();
#include <strstream>
#include <cassert>
int main()
{
{
const char buf[] = "123 4.5 dog";
std::istrstream in(buf);
assert(in.str() == std::string("123 4.5 dog"));
}
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class istrstream
// : public basic_istream<char>
// {
// ...
#include <strstream>
#include <type_traits>
int main()
{
static_assert((std::is_base_of<std::istream, std::istrstream>::value), "");
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
std::ostrstream out(buf, 0);
assert(out.str() == std::string("123 4.5 dog"));
int i = 321;
double d = 5.5;
std::string s("cat");
out << i << ' ' << d << ' ' << s << std::ends;
assert(out.str() == std::string("321 5.5 cat"));
}
{
char buf[23] = "123 4.5 dog";
std::ostrstream out(buf, 11, std::ios::app);
assert(out.str() == std::string("123 4.5 dog"));
int i = 321;
double d = 5.5;
std::string s("cat");
out << i << ' ' << d << ' ' << s << std::ends;
assert(out.str() == std::string("123 4.5 dog321 5.5 cat"));
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// ostrstream();
#include <strstream>
#include <cassert>
int main()
{
std::ostrstream out;
int i = 123;
double d = 4.5;
std::string s("dog");
out << i << ' ' << d << ' ' << s << std::ends;
assert(out.str() == std::string("123 4.5 dog"));
out.freeze(false);
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// void freeze(bool freezefl = true);
#include <strstream>
#include <cassert>
int main()
{
{
std::ostrstream out;
out.freeze();
assert(!out.fail());
out << 'a';
assert(out.fail());
out.clear();
out.freeze(false);
out << 'a';
out << char(0);
assert(out.str() == std::string("a"));
out.freeze(false);
}
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// int pcount() const;
#include <strstream>
#include <cassert>
int main()
{
{
std::ostrstream out;
assert(out.pcount() == 0);
out << 123 << ' ' << 4.5 << ' ' << "dog";
assert(out.pcount() == 11);
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// strstreambuf* rdbuf() const;
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
const std::ostrstream out(buf, 0);
std::strstreambuf* sb = out.rdbuf();
assert(sb->sputc('a') == 'a');
assert(buf == std::string("a23 4.5 dog"));
}
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// char* str();
#include <strstream>
#include <cassert>
int main()
{
{
std::ostrstream out;
out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
assert(out.str() == std::string("123 4.5 dog"));
out.freeze(false);
}
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class ostrstream
// : public basic_ostream<char>
// {
// ...
#include <strstream>
#include <type_traits>
int main()
{
static_assert((std::is_base_of<std::ostream, std::ostrstream>::value), "");
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class strstream
// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
std::strstream inout(buf, 0);
assert(inout.str() == std::string("123 4.5 dog"));
int i = 321;
double d = 5.5;
std::string s("cat");
inout >> i;
assert(inout.fail());
inout.clear();
inout << i << ' ' << d << ' ' << s;
assert(inout.str() == std::string("321 5.5 cat"));
i = 0;
d = 0;
s = "";
inout >> i >> d >> s;
assert(i == 321);
assert(d == 5.5);
assert(s == "cat");
}
{
char buf[23] = "123 4.5 dog";
std::strstream inout(buf, 11, std::ios::app);
assert(inout.str() == std::string("123 4.5 dog"));
int i = 0;
double d = 0;
std::string s;
inout >> i >> d >> s;
assert(i == 123);
assert(d == 4.5);
assert(s == "dog");
i = 321;
d = 5.5;
s = "cat";
inout.clear();
inout << i << ' ' << d << ' ' << s;
assert(inout.str() == std::string("123 4.5 dog321 5.5 cat"));
}
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class strstream
// strstream();
#include <strstream>
#include <cassert>
int main()
{
std::strstream inout;
int i = 123;
double d = 4.5;
std::string s("dog");
inout << i << ' ' << d << ' ' << s << std::ends;
assert(inout.str() == std::string("123 4.5 dog"));
i = 0;
d = 0;
s = "";
inout >> i >> d >> s;
assert(i == 123);
assert(d == 4.5);
assert(strcmp(s.c_str(), "dog") == 0);
inout.freeze(false);
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class strstream
// strstreambuf* rdbuf() const;
#include <strstream>
#include <cassert>
int main()
{
{
char buf[] = "123 4.5 dog";
const std::strstream out(buf, 0);
std::strstreambuf* sb = out.rdbuf();
assert(sb->sputc('a') == 'a');
assert(buf == std::string("a23 4.5 dog"));
}
}

Some files were not shown because too many files have changed in this diff Show More