1// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5#include "vm/os.h"
6#include "platform/assert.h"
7#include "platform/utils.h"
8#include "vm/globals.h"
9#include "vm/unit_test.h"
10
11namespace dart {
12
13VM_UNIT_TEST_CASE(SNPrint) {
14 char buffer[256];
15 int length;
16 length = Utils::SNPrint(buffer, 10, "%s", "foo");
17 EXPECT_EQ(3, length);
18 EXPECT_STREQ("foo", buffer);
19 length = Utils::SNPrint(buffer, 3, "%s", "foo");
20 EXPECT_EQ(3, length);
21 EXPECT_STREQ("fo", buffer);
22 length = Utils::SNPrint(buffer, 256, "%s%c%d", "foo", 'Z', 42);
23 EXPECT_EQ(6, length);
24 EXPECT_STREQ("fooZ42", buffer);
25 length = Utils::SNPrint(NULL, 0, "foo");
26 EXPECT_EQ(3, length);
27}
28
29VM_UNIT_TEST_CASE(OsFuncs) {
30 EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment()));
31 int procs = OS::NumberOfAvailableProcessors();
32 EXPECT_LE(1, procs);
33}
34
35} // namespace dart
36