| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |