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:
@@ -0,0 +1,142 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type overflow(int_type c = traits::eof());
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
typedef typename base::traits_type traits_type;
|
||||
|
||||
char_type* pbase() const {return base::pbase();}
|
||||
char_type* pptr() const {return base::pptr();}
|
||||
char_type* epptr() const {return base::epptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow('a') == 'a');
|
||||
assert(f.pbase() != 0);
|
||||
assert(f.pptr() == f.pbase());
|
||||
assert(f.epptr() - f.pbase() == 4095);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == 'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<char> f;
|
||||
f.pubsetbuf(0, 0);
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow('a') == 'a');
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == 'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow(L'a') == L'a');
|
||||
assert(f.pbase() != 0);
|
||||
assert(f.pptr() == f.pbase());
|
||||
assert(f.epptr() - f.pbase() == 4095);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == L'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubsetbuf(0, 0);
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow(L'a') == L'a');
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == L'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.sputc(0x4E51) == 0x4E51);
|
||||
assert(f.sputc(0x4E52) == 0x4E52);
|
||||
assert(f.sputc(0x4E53) == 0x4E53);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x91);
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x92);
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x93);
|
||||
assert(f.sbumpc() == -1);
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type pbackfail(int_type c = traits::eof());
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
typedef typename base::traits_type traits_type;
|
||||
|
||||
char_type* eback() const {return base::eback();}
|
||||
char_type* gptr() const {return base::gptr();}
|
||||
char_type* egptr() const {return base::egptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == '1');
|
||||
assert(f.sgetc() == '2');
|
||||
assert(f.pbackfail('a') == -1);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == '1');
|
||||
assert(f.sgetc() == '2');
|
||||
assert(f.pbackfail('a') == 'a');
|
||||
assert(f.sbumpc() == 'a');
|
||||
assert(f.sgetc() == '2');
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
// pos_type seekpos(pos_type sp,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
char buf[10];
|
||||
typedef std::filebuf::pos_type pos_type;
|
||||
std::filebuf f;
|
||||
f.pubsetbuf(buf, sizeof(buf));
|
||||
assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
|
||||
assert(buf[0] == 'v');
|
||||
pos_type p = f.pubseekoff(-15, std::ios_base::cur);
|
||||
assert(p == 11);
|
||||
assert(f.sgetc() == 'l');
|
||||
f.pubseekoff(0, std::ios_base::beg);
|
||||
assert(f.sgetc() == 'a');
|
||||
f.pubseekoff(-1, std::ios_base::end);
|
||||
assert(f.sgetc() == 'z');
|
||||
assert(f.pubseekpos(p) == p);
|
||||
assert(f.sgetc() == 'l');
|
||||
}
|
||||
std::remove("seekoff.dat");
|
||||
{
|
||||
wchar_t buf[10];
|
||||
typedef std::filebuf::pos_type pos_type;
|
||||
std::wfilebuf f;
|
||||
f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
|
||||
assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
|
||||
assert(buf[0] == L'v');
|
||||
pos_type p = f.pubseekoff(-15, std::ios_base::cur);
|
||||
assert(p == 11);
|
||||
assert(f.sgetc() == L'l');
|
||||
f.pubseekoff(0, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'a');
|
||||
f.pubseekoff(-1, std::ios_base::end);
|
||||
assert(f.sgetc() == L'z');
|
||||
assert(f.pubseekpos(p) == p);
|
||||
assert(f.sgetc() == L'l');
|
||||
}
|
||||
std::remove("seekoff.dat");
|
||||
}
|
@@ -0,0 +1 @@
|
||||
123456789
|
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type underflow();
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
|
||||
char_type* eback() const {return base::eback();}
|
||||
char_type* gptr() const {return base::gptr();}
|
||||
char_type* egptr() const {return base::egptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type underflow() {return base::underflow();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == '1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == '1');
|
||||
assert(f.egptr() - f.eback() == 9);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.pubsetbuf(0, 0));
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == '1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == '1');
|
||||
assert(f.egptr() - f.eback() == 8);
|
||||
f.gbump(8);
|
||||
assert(f.sgetc() == '9');
|
||||
assert(f.eback()[0] == '5');
|
||||
assert(f.eback()[1] == '6');
|
||||
assert(f.eback()[2] == '7');
|
||||
assert(f.eback()[3] == '8');
|
||||
assert(f.gptr() - f.eback() == 4);
|
||||
assert(*f.gptr() == '9');
|
||||
assert(f.egptr() - f.gptr() == 1);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == L'1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == L'1');
|
||||
assert(f.egptr() - f.eback() == 9);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.pubsetbuf(0, 0));
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == L'1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == L'1');
|
||||
assert(f.egptr() - f.eback() == 8);
|
||||
f.gbump(8);
|
||||
assert(f.sgetc() == L'9');
|
||||
assert(f.eback()[0] == L'5');
|
||||
assert(f.eback()[1] == L'6');
|
||||
assert(f.eback()[2] == L'7');
|
||||
assert(f.eback()[3] == L'8');
|
||||
assert(f.gptr() - f.eback() == 4);
|
||||
assert(*f.gptr() == L'9');
|
||||
assert(f.egptr() - f.gptr() == 1);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == 0x4E51);
|
||||
assert(f.sbumpc() == 0x4E52);
|
||||
assert(f.sbumpc() == 0x4E53);
|
||||
assert(f.sbumpc() == -1);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
乑乒乓
|
Reference in New Issue
Block a user