OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 unsigned char data = buffer[index]; | 106 unsigned char data = buffer[index]; |
107 data = TwoBits::encode(data, i, i % 4); | 107 data = TwoBits::encode(data, i, i % 4); |
108 buffer[index] = data; | 108 buffer[index] = data; |
109 } | 109 } |
110 | 110 |
111 for (int i = 0; i < words; i++) { | 111 for (int i = 0; i < words; i++) { |
112 const int index = TwoBits::index(offset, i); | 112 const int index = TwoBits::index(offset, i); |
113 unsigned char data = buffer[index]; | 113 unsigned char data = buffer[index]; |
114 CHECK_EQ(i % 4, TwoBits::decode(data, i)); | 114 CHECK_EQ(i % 4, TwoBits::decode(data, i)); |
115 } | 115 } |
| 116 buffer.Dispose(); |
116 } | 117 } |
117 | 118 |
118 | 119 |
119 TEST(SNPrintF) { | 120 TEST(SNPrintF) { |
120 // Make sure that strings that are truncated because of too small | 121 // Make sure that strings that are truncated because of too small |
121 // buffers are zero-terminated anyway. | 122 // buffers are zero-terminated anyway. |
122 const char* s = "the quick lazy .... oh forget it!"; | 123 const char* s = "the quick lazy .... oh forget it!"; |
123 int length = StrLength(s); | 124 int length = StrLength(s); |
124 for (int i = 1; i < length * 2; i++) { | 125 for (int i = 1; i < length * 2; i++) { |
125 static const char kMarker = static_cast<char>(42); | 126 static const char kMarker = static_cast<char>(42); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 vec.push_back(66); | 288 vec.push_back(66); |
288 for (auto& i : vec) { | 289 for (auto& i : vec) { |
289 ++i; | 290 ++i; |
290 } | 291 } |
291 int j = 12; | 292 int j = 12; |
292 for (auto i : vec) { | 293 for (auto i : vec) { |
293 CHECK_EQ(j, i); | 294 CHECK_EQ(j, i); |
294 j += 11; | 295 j += 11; |
295 } | 296 } |
296 } | 297 } |
OLD | NEW |