2010-06-17 02:34:59 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-06-17 02:34:59 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <regex>
|
|
|
|
|
|
|
|
// template <class charT> struct regex_traits;
|
|
|
|
|
|
|
|
// int value(charT ch, int radix) const;
|
|
|
|
|
|
|
|
#include <regex>
|
2010-06-21 23:01:43 +02:00
|
|
|
#include <cassert>
|
2010-06-17 02:34:59 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2010-06-21 23:01:43 +02:00
|
|
|
{
|
|
|
|
std::regex_traits<char> t;
|
|
|
|
|
|
|
|
for (char c = 0; c < '0'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (char c = '0'; c < '8'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == c - '0');
|
|
|
|
assert(t.value(c, 10) == c - '0');
|
|
|
|
assert(t.value(c, 16) == c - '0');
|
|
|
|
}
|
|
|
|
for (char c = '8'; c < ':'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == c - '0');
|
|
|
|
assert(t.value(c, 16) == c - '0');
|
|
|
|
}
|
|
|
|
for (char c = ':'; c < 'A'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (char c = 'A'; c < 'G'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == c - 'A' +10);
|
|
|
|
}
|
|
|
|
for (char c = 'G'; c < 'a'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (char c = 'a'; c < 'g'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == c - 'a' +10);
|
|
|
|
}
|
|
|
|
for (int c = 'g'; c < 256; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(char(c), 8) == -1);
|
|
|
|
assert(t.value(char(c), 10) == -1);
|
|
|
|
assert(t.value(char(c), 16) == -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_traits<wchar_t> t;
|
|
|
|
|
|
|
|
for (wchar_t c = 0; c < '0'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (wchar_t c = '0'; c < '8'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == c - '0');
|
|
|
|
assert(t.value(c, 10) == c - '0');
|
|
|
|
assert(t.value(c, 16) == c - '0');
|
|
|
|
}
|
|
|
|
for (wchar_t c = '8'; c < ':'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == c - '0');
|
|
|
|
assert(t.value(c, 16) == c - '0');
|
|
|
|
}
|
|
|
|
for (wchar_t c = ':'; c < 'A'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (wchar_t c = 'A'; c < 'G'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == c - 'A' +10);
|
|
|
|
}
|
|
|
|
for (wchar_t c = 'G'; c < 'a'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
for (wchar_t c = 'a'; c < 'g'; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == c - 'a' +10);
|
|
|
|
}
|
|
|
|
for (int c = 'g'; c < 0xFFFF; ++c)
|
|
|
|
{
|
|
|
|
assert(t.value(c, 8) == -1);
|
|
|
|
assert(t.value(c, 10) == -1);
|
|
|
|
assert(t.value(c, 16) == -1);
|
|
|
|
}
|
|
|
|
}
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|