2013-02-27 12:51:21 +00:00
|
|
|
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
2011-10-05 05:20:07 +00:00
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2017-07-13 15:08:33 +00:00
|
|
|
#include "vm/os.h"
|
2012-01-16 12:28:10 +00:00
|
|
|
#include "platform/assert.h"
|
2012-01-16 13:23:40 +00:00
|
|
|
#include "platform/utils.h"
|
2011-10-05 05:20:07 +00:00
|
|
|
#include "vm/globals.h"
|
|
|
|
#include "vm/unit_test.h"
|
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
2017-01-31 23:16:38 +00:00
|
|
|
VM_UNIT_TEST_CASE(SNPrint) {
|
2011-10-05 05:20:07 +00:00
|
|
|
char buffer[256];
|
|
|
|
int length;
|
2018-03-01 02:07:46 +00:00
|
|
|
length = Utils::SNPrint(buffer, 10, "%s", "foo");
|
2011-10-05 05:20:07 +00:00
|
|
|
EXPECT_EQ(3, length);
|
|
|
|
EXPECT_STREQ("foo", buffer);
|
2018-03-01 02:07:46 +00:00
|
|
|
length = Utils::SNPrint(buffer, 3, "%s", "foo");
|
2011-10-05 05:20:07 +00:00
|
|
|
EXPECT_EQ(3, length);
|
|
|
|
EXPECT_STREQ("fo", buffer);
|
2018-03-01 02:07:46 +00:00
|
|
|
length = Utils::SNPrint(buffer, 256, "%s%c%d", "foo", 'Z', 42);
|
2011-10-05 05:20:07 +00:00
|
|
|
EXPECT_EQ(6, length);
|
|
|
|
EXPECT_STREQ("fooZ42", buffer);
|
2018-03-01 02:07:46 +00:00
|
|
|
length = Utils::SNPrint(NULL, 0, "foo");
|
2011-10-05 05:20:07 +00:00
|
|
|
EXPECT_EQ(3, length);
|
|
|
|
}
|
|
|
|
|
2017-01-31 23:16:38 +00:00
|
|
|
VM_UNIT_TEST_CASE(OsFuncs) {
|
2011-10-05 05:20:07 +00:00
|
|
|
EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment()));
|
|
|
|
int procs = OS::NumberOfAvailableProcessors();
|
|
|
|
EXPECT_LE(1, procs);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dart
|