Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: vm/os_test.cc

Issue 10696165: Don't allow OS::SNPrint or OS::VSNPrint to return negative values. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/os_macos.cc ('k') | vm/os_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "platform/utils.h" 6 #include "platform/utils.h"
7 #include "vm/globals.h" 7 #include "vm/globals.h"
8 #include "vm/os.h" 8 #include "vm/os.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 20 matching lines...) Expand all
31 EXPECT_EQ(3, length); 31 EXPECT_EQ(3, length);
32 EXPECT_STREQ("fo", buffer); 32 EXPECT_STREQ("fo", buffer);
33 length = OS::SNPrint(buffer, 256, "%s%c%d", "foo", 'Z', 42); 33 length = OS::SNPrint(buffer, 256, "%s%c%d", "foo", 'Z', 42);
34 EXPECT_EQ(6, length); 34 EXPECT_EQ(6, length);
35 EXPECT_STREQ("fooZ42", buffer); 35 EXPECT_STREQ("fooZ42", buffer);
36 length = OS::SNPrint(NULL, 0, "foo"); 36 length = OS::SNPrint(NULL, 0, "foo");
37 EXPECT_EQ(3, length); 37 EXPECT_EQ(3, length);
38 } 38 }
39 39
40 40
41 // This test is expected to crash when it runs.
42 UNIT_TEST_CASE(SNPrint_BadArgs) {
43 int width = kMaxInt32;
44 int num = 7;
45 OS::SNPrint(NULL, 0, "%*d%*d", width, num, width, num);
46 }
47
48
41 UNIT_TEST_CASE(OsFuncs) { 49 UNIT_TEST_CASE(OsFuncs) {
42 EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment())); 50 EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment()));
43 EXPECT(Utils::IsPowerOfTwo(OS::PreferredCodeAlignment())); 51 EXPECT(Utils::IsPowerOfTwo(OS::PreferredCodeAlignment()));
44 int procs = OS::NumberOfAvailableProcessors(); 52 int procs = OS::NumberOfAvailableProcessors();
45 EXPECT_LE(1, procs); 53 EXPECT_LE(1, procs);
46 EXPECT_LT(0U, OS::GetStackSizeLimit()); 54 EXPECT_LT(0U, OS::GetStackSizeLimit());
47 } 55 }
48 56
49 } // namespace dart 57 } // namespace dart
OLDNEW
« no previous file with comments | « vm/os_macos.cc ('k') | vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698