this repo has no description
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
2#include <cstring>
3
4#include "Python.h"
5#include "gtest/gtest.h"
6
7#include "capi-testing.h"
8
9namespace py {
10
11TEST(MysnprintfTest, Snprintf) {
12 char str[5];
13
14 std::memset(str, 0xFF, sizeof(str));
15 EXPECT_EQ(PyOS_snprintf(str, sizeof(str), "%d", 123), 3);
16 EXPECT_STREQ(str, "123");
17
18 std::memset(str, 0xFF, sizeof(str));
19 EXPECT_EQ(PyOS_snprintf(str, sizeof(str), "%d", 1234), 4);
20 EXPECT_STREQ(str, "1234");
21
22 std::memset(str, 0xFF, sizeof(str));
23 EXPECT_EQ(PyOS_snprintf(str, sizeof(str), "%d", 12345678), 8);
24 EXPECT_STREQ(str, "1234");
25}
26
27} // namespace py