#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef istreambuf_iterator<char> iterator_type;
locale loc_c = locale::classic();
const string empty;
iterator_type end;
istringstream iss;
iss.imbue(loc_c);
const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
const tm time_bday = { 0, 0, 12, 4, 3, 71, 0, 93, 0 };
iss.str("Sunday");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
iss.str("Sun");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_weekday(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
iss.str("Sun ");
iterator_type is_it03(iss);
tm time03;
errorstate = good;
tim_get.get_weekday(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == good );
VERIFY( *is_it03 == ' ');
iss.str("San");
iterator_type is_it04(iss);
tm time04;
time04.tm_wday = 4;
errorstate = good;
tim_get.get_weekday(is_it04, end, iss, errorstate, &time04);
VERIFY( time04.tm_wday == 4 );
VERIFY( *is_it04 == 'n');
VERIFY( errorstate == ios_base::failbit );
iss.str("Tuesday ");
iterator_type is_it05(iss);
tm time05;
errorstate = good;
tim_get.get_weekday(is_it05, end, iss, errorstate, &time05);
VERIFY( time05.tm_wday == 2 );
VERIFY( errorstate == good );
VERIFY( *is_it05 == ' ');
iss.str("Tuesducky "); iterator_type is_it06(iss);
tm time06;
time06.tm_wday = 4;
errorstate = good;
tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_wday == 4 );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it05 == 'u');
}
int main()
{
test01();
return 0;
}