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 27 matching lines...) Expand all Loading... |
38 template<> struct PrintfFormatTrait<short> { static const char format[]; }; | 38 template<> struct PrintfFormatTrait<short> { static const char format[]; }; |
39 const char PrintfFormatTrait<short>::format[] = "%hd"; | 39 const char PrintfFormatTrait<short>::format[] = "%hd"; |
40 | 40 |
41 template<> struct PrintfFormatTrait<int> { static const char format[]; }; | 41 template<> struct PrintfFormatTrait<int> { static const char format[]; }; |
42 const char PrintfFormatTrait<int>::format[] = "%d"; | 42 const char PrintfFormatTrait<int>::format[] = "%d"; |
43 | 43 |
44 template<> struct PrintfFormatTrait<long> { static const char format[]; }; | 44 template<> struct PrintfFormatTrait<long> { static const char format[]; }; |
45 const char PrintfFormatTrait<long>::format[] = "%ld"; | 45 const char PrintfFormatTrait<long>::format[] = "%ld"; |
46 | 46 |
47 template<> struct PrintfFormatTrait<long long> { static const char format[]; }; | 47 template<> struct PrintfFormatTrait<long long> { static const char format[]; }; |
48 #if OS(WINDOWS) | 48 #if OS(WIN) |
49 const char PrintfFormatTrait<long long>::format[] = "%I64i"; | 49 const char PrintfFormatTrait<long long>::format[] = "%I64i"; |
50 #else | 50 #else |
51 const char PrintfFormatTrait<long long>::format[] = "%lli"; | 51 const char PrintfFormatTrait<long long>::format[] = "%lli"; |
52 #endif // OS(WINDOWS) | 52 #endif // OS(WIN) |
53 | 53 |
54 template<> struct PrintfFormatTrait<unsigned short> { static const char format[]
; }; | 54 template<> struct PrintfFormatTrait<unsigned short> { static const char format[]
; }; |
55 const char PrintfFormatTrait<unsigned short>::format[] = "%hu"; | 55 const char PrintfFormatTrait<unsigned short>::format[] = "%hu"; |
56 | 56 |
57 template<> struct PrintfFormatTrait<unsigned> { static const char format[]; }; | 57 template<> struct PrintfFormatTrait<unsigned> { static const char format[]; }; |
58 const char PrintfFormatTrait<unsigned>::format[] = "%u"; | 58 const char PrintfFormatTrait<unsigned>::format[] = "%u"; |
59 | 59 |
60 template<> struct PrintfFormatTrait<unsigned long> { static const char format[];
}; | 60 template<> struct PrintfFormatTrait<unsigned long> { static const char format[];
}; |
61 const char PrintfFormatTrait<unsigned long>::format[] = "%lu"; | 61 const char PrintfFormatTrait<unsigned long>::format[] = "%lu"; |
62 | 62 |
63 template<> struct PrintfFormatTrait<unsigned long long> { static const char form
at[]; }; | 63 template<> struct PrintfFormatTrait<unsigned long long> { static const char form
at[]; }; |
64 #if OS(WINDOWS) | 64 #if OS(WIN) |
65 const char PrintfFormatTrait<unsigned long long>::format[] = "%I64u"; | 65 const char PrintfFormatTrait<unsigned long long>::format[] = "%I64u"; |
66 #else | 66 #else |
67 const char PrintfFormatTrait<unsigned long long>::format[] = "%llu"; | 67 const char PrintfFormatTrait<unsigned long long>::format[] = "%llu"; |
68 #endif // OS(WINDOWS) | 68 #endif // OS(WIN) |
69 | 69 |
70 | 70 |
71 // FIXME: use snprintf from StringExtras.h | 71 // FIXME: use snprintf from StringExtras.h |
72 template<typename IntegerType> | 72 template<typename IntegerType> |
73 void testBoundaries() | 73 void testBoundaries() |
74 { | 74 { |
75 const unsigned bufferSize = 256; | 75 const unsigned bufferSize = 256; |
76 Vector<char, bufferSize> buffer; | 76 Vector<char, bufferSize> buffer; |
77 buffer.resize(bufferSize); | 77 buffer.resize(bufferSize); |
78 | 78 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 TEST(WTF, IntegerToStringConversionUnsignedIntegerRegularNumbers) | 129 TEST(WTF, IntegerToStringConversionUnsignedIntegerRegularNumbers) |
130 { | 130 { |
131 testNumbers<unsigned short>(); | 131 testNumbers<unsigned short>(); |
132 testNumbers<unsigned int>(); | 132 testNumbers<unsigned int>(); |
133 testNumbers<unsigned long>(); | 133 testNumbers<unsigned long>(); |
134 testNumbers<unsigned long long>(); | 134 testNumbers<unsigned long long>(); |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
OLD | NEW |