OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 24 matching lines...) Expand all Loading... |
35 template<> struct PrintfFormatTrait<short> { static const char format[]; }; | 35 template<> struct PrintfFormatTrait<short> { static const char format[]; }; |
36 const char PrintfFormatTrait<short>::format[] = "%hd"; | 36 const char PrintfFormatTrait<short>::format[] = "%hd"; |
37 | 37 |
38 template<> struct PrintfFormatTrait<int> { static const char format[]; }; | 38 template<> struct PrintfFormatTrait<int> { static const char format[]; }; |
39 const char PrintfFormatTrait<int>::format[] = "%d"; | 39 const char PrintfFormatTrait<int>::format[] = "%d"; |
40 | 40 |
41 template<> struct PrintfFormatTrait<long> { static const char format[]; }; | 41 template<> struct PrintfFormatTrait<long> { static const char format[]; }; |
42 const char PrintfFormatTrait<long>::format[] = "%ld"; | 42 const char PrintfFormatTrait<long>::format[] = "%ld"; |
43 | 43 |
44 template<> struct PrintfFormatTrait<long long> { static const char format[]; }; | 44 template<> struct PrintfFormatTrait<long long> { static const char format[]; }; |
45 #if OS(WINDOWS) && !PLATFORM(QT) | 45 #if OS(WINDOWS) |
46 const char PrintfFormatTrait<long long>::format[] = "%I64i"; | 46 const char PrintfFormatTrait<long long>::format[] = "%I64i"; |
47 #else | 47 #else |
48 const char PrintfFormatTrait<long long>::format[] = "%lli"; | 48 const char PrintfFormatTrait<long long>::format[] = "%lli"; |
49 #endif // OS(WINDOWS) && !PLATFORM(QT) | 49 #endif // OS(WINDOWS) |
50 | 50 |
51 template<> struct PrintfFormatTrait<unsigned short> { static const char format[]
; }; | 51 template<> struct PrintfFormatTrait<unsigned short> { static const char format[]
; }; |
52 const char PrintfFormatTrait<unsigned short>::format[] = "%hu"; | 52 const char PrintfFormatTrait<unsigned short>::format[] = "%hu"; |
53 | 53 |
54 template<> struct PrintfFormatTrait<unsigned> { static const char format[]; }; | 54 template<> struct PrintfFormatTrait<unsigned> { static const char format[]; }; |
55 const char PrintfFormatTrait<unsigned>::format[] = "%u"; | 55 const char PrintfFormatTrait<unsigned>::format[] = "%u"; |
56 | 56 |
57 template<> struct PrintfFormatTrait<unsigned long> { static const char format[];
}; | 57 template<> struct PrintfFormatTrait<unsigned long> { static const char format[];
}; |
58 const char PrintfFormatTrait<unsigned long>::format[] = "%lu"; | 58 const char PrintfFormatTrait<unsigned long>::format[] = "%lu"; |
59 | 59 |
60 template<> struct PrintfFormatTrait<unsigned long long> { static const char form
at[]; }; | 60 template<> struct PrintfFormatTrait<unsigned long long> { static const char form
at[]; }; |
61 #if OS(WINDOWS) && !PLATFORM(QT) | 61 #if OS(WINDOWS) |
62 const char PrintfFormatTrait<unsigned long long>::format[] = "%I64u"; | 62 const char PrintfFormatTrait<unsigned long long>::format[] = "%I64u"; |
63 #else | 63 #else |
64 const char PrintfFormatTrait<unsigned long long>::format[] = "%llu"; | 64 const char PrintfFormatTrait<unsigned long long>::format[] = "%llu"; |
65 #endif // OS(WINDOWS) && !PLATFORM(QT) | 65 #endif // OS(WINDOWS) |
66 | 66 |
67 | 67 |
68 // FIXME: use snprintf from StringExtras.h | 68 // FIXME: use snprintf from StringExtras.h |
69 template<typename IntegerType> | 69 template<typename IntegerType> |
70 void testBoundaries() | 70 void testBoundaries() |
71 { | 71 { |
72 const unsigned bufferSize = 256; | 72 const unsigned bufferSize = 256; |
73 Vector<char, bufferSize> buffer; | 73 Vector<char, bufferSize> buffer; |
74 buffer.resize(bufferSize); | 74 buffer.resize(bufferSize); |
75 | 75 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 testBoundaries<unsigned long long>(); | 123 testBoundaries<unsigned long long>(); |
124 } | 124 } |
125 | 125 |
126 TEST(WTF, IntegerToStringConversionUnsignedIntegerRegularNumbers) | 126 TEST(WTF, IntegerToStringConversionUnsignedIntegerRegularNumbers) |
127 { | 127 { |
128 testNumbers<unsigned short>(); | 128 testNumbers<unsigned short>(); |
129 testNumbers<unsigned int>(); | 129 testNumbers<unsigned int>(); |
130 testNumbers<unsigned long>(); | 130 testNumbers<unsigned long>(); |
131 testNumbers<unsigned long long>(); | 131 testNumbers<unsigned long long>(); |
132 } | 132 } |
OLD | NEW |