forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSNPrintfBufTest.cpp
More file actions
42 lines (35 loc) · 1017 Bytes
/
SNPrintfBufTest.cpp
File metadata and controls
42 lines (35 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "hermes/Support/SNPrintfBuf.h"
#include "gtest/gtest.h"
using namespace hermes;
namespace {
TEST(SNPrintfBufTest, Basic) {
// Starting with a small size, writing more than that to cause reallocs:
// Final result is still what we expect.
SNPrintfBuf buf(10);
for (int i = 0; i < 9; i++) {
buf.printf("|next: %s", "123456789");
}
EXPECT_STREQ(
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789"
"|next: 123456789",
buf.c_str());
}
TEST(SNPrintfBufTest, ArgsWork) {
SNPrintfBuf buf(100);
buf.printf("a: %s, b: %d, c: %7.2f", "abc", 100, 200.0);
EXPECT_STREQ("a: abc, b: 100, c: 200.00", buf.c_str());
}
} // end anonymous namespace